From 2152a139b0ba8ca05f28489e7c10ef6d0e659db4 Mon Sep 17 00:00:00 2001 From: Scionwest_cp Date: Thu, 29 Jul 2010 19:07:09 -0700 Subject: [PATCH] MudEngine: - Reverted Server code back to using player arrays rather than List<> so that the server will actually start and run again. --- MudEngine/Commands/CommandRestart.cs | 2 +- MudEngine/GameManagement/Game.cs | 13 ++++++------- MudEngine/Networking/Server.cs | 6 +++--- MudOfflineExample/Program.cs | 3 --- MudServer/Program.cs | 1 - 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/MudEngine/Commands/CommandRestart.cs b/MudEngine/Commands/CommandRestart.cs index 04e774a..39d8db7 100644 --- a/MudEngine/Commands/CommandRestart.cs +++ b/MudEngine/Commands/CommandRestart.cs @@ -25,7 +25,7 @@ namespace MudEngine.Commands { if (player.Role == SecurityRoles.Admin) { - for (int i = 0; i < player.ActiveGame.PlayerCollection.Count/*Length*/; i++) + for (int i = 0; i < player.ActiveGame.PlayerCollection.Length; i++) player.ActiveGame.PlayerCollection[i].Save(player.ActiveGame.PlayerCollection[i].Name + ".dat"); player.ActiveGame.Server.EndServer(); player.ActiveGame.Server.Initialize(555, ref player.ActiveGame.PlayerCollection); diff --git a/MudEngine/GameManagement/Game.cs b/MudEngine/GameManagement/Game.cs index e5bd835..a902590 100644 --- a/MudEngine/GameManagement/Game.cs +++ b/MudEngine/GameManagement/Game.cs @@ -180,7 +180,7 @@ namespace MudEngine.GameManagement CurrencyList = new List(); scriptEngine = new Scripting.ScriptEngine(this); RealmCollection = new List(); - PlayerCollection = new List(); + //PlayerCollection = new List(); GameTitle = "New Game"; _Filename = "Game.xml"; @@ -236,9 +236,6 @@ namespace MudEngine.GameManagement //Start the Telnet server if (IsMultiplayer) this.StartServer(); - else - //TODO: Need to load a previously saved character or allow for creation of one by user. - //PlayerCollection.Add(new BaseCharacter(this)); //If this is single player, then add a new character to the game. IsRunning = true; @@ -313,8 +310,8 @@ namespace MudEngine.GameManagement } //TODO: This should be internal only; C# property using get; internal set; so only MudEngine.dll may edit this collection - public List PlayerCollection; - //public BaseCharacter[] PlayerCollection; + //public List PlayerCollection; + public BaseCharacter[] PlayerCollection; public MudEngine.Networking.Server Server { get; internal set; } public ProtocolType ServerType = ProtocolType.Tcp; @@ -327,7 +324,9 @@ namespace MudEngine.GameManagement { //This is handled by the Game() Constructor //PlayerCollection = new List(MaximumPlayers); - PlayerCollection.Add(new BaseCharacter(this)); + PlayerCollection = new BaseCharacter[MaximumPlayers]; + for (int i = 0; i < MaximumPlayers; i++) + PlayerCollection[i] = new BaseCharacter(this); Server = new Networking.Server(); Server.Initialize(ServerPort, ref PlayerCollection); Server.Start(); diff --git a/MudEngine/Networking/Server.cs b/MudEngine/Networking/Server.cs index 407d810..d04b342 100644 --- a/MudEngine/Networking/Server.cs +++ b/MudEngine/Networking/Server.cs @@ -30,15 +30,15 @@ namespace MudEngine.Networking stage = 0; port = 0; } - public bool Initialize(int p, ref List/*BaseCharacter[]*/ pbs) + public bool Initialize(int p, ref /*List*/BaseCharacter[] pbs) { if (stage != 0) return false; if (p <= 0) return false; port = p; - clientThreads = new Thread[pbs.Capacity/*Length*/]; - players = pbs.ToArray(); + players = pbs; + clientThreads = new Thread[players.Length]; stage++; return true; } diff --git a/MudOfflineExample/Program.cs b/MudOfflineExample/Program.cs index 8b269a3..803c14f 100644 --- a/MudOfflineExample/Program.cs +++ b/MudOfflineExample/Program.cs @@ -45,9 +45,6 @@ namespace MUDGame //Player must be instanced AFTER BuildRealms as it needs Game.InitialRealm.InitialZone.InitialRoom //property so that it can set it's starting room correctly. player = new BaseCharacter(game); - //Add the player to the game. - //Note once the server is fully implemented the player will be generated automatically by Game. - game.PlayerCollection.Add(player); //Send game info to player Console.WriteLine(game.GameTitle); diff --git a/MudServer/Program.cs b/MudServer/Program.cs index 2e09183..d23db74 100644 --- a/MudServer/Program.cs +++ b/MudServer/Program.cs @@ -39,7 +39,6 @@ namespace MudServer game.ServerType = ProtocolType.Tcp; game.ServerPort = 555; game.MaximumPlayers = 1000; - game.PlayerCollection.Add(serverAdmin); Game.IsDebug = true; game.Start();