MudEngine:

- Reverted Server code back to using player arrays rather than List<> so that the server will actually start and run again.
This commit is contained in:
Scionwest_cp 2010-07-29 19:07:09 -07:00
parent 9b023a2092
commit 2152a139b0
5 changed files with 10 additions and 15 deletions

View file

@ -25,7 +25,7 @@ namespace MudEngine.Commands
{ {
if (player.Role == SecurityRoles.Admin) 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.PlayerCollection[i].Save(player.ActiveGame.PlayerCollection[i].Name + ".dat");
player.ActiveGame.Server.EndServer(); player.ActiveGame.Server.EndServer();
player.ActiveGame.Server.Initialize(555, ref player.ActiveGame.PlayerCollection); player.ActiveGame.Server.Initialize(555, ref player.ActiveGame.PlayerCollection);

View file

@ -180,7 +180,7 @@ namespace MudEngine.GameManagement
CurrencyList = new List<Currency>(); CurrencyList = new List<Currency>();
scriptEngine = new Scripting.ScriptEngine(this); scriptEngine = new Scripting.ScriptEngine(this);
RealmCollection = new List<Realm>(); RealmCollection = new List<Realm>();
PlayerCollection = new List<BaseCharacter>(); //PlayerCollection = new List<BaseCharacter>();
GameTitle = "New Game"; GameTitle = "New Game";
_Filename = "Game.xml"; _Filename = "Game.xml";
@ -236,9 +236,6 @@ namespace MudEngine.GameManagement
//Start the Telnet server //Start the Telnet server
if (IsMultiplayer) if (IsMultiplayer)
this.StartServer(); 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; 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 //TODO: This should be internal only; C# property using get; internal set; so only MudEngine.dll may edit this collection
public List<BaseCharacter> PlayerCollection; //public List<BaseCharacter> PlayerCollection;
//public BaseCharacter[] PlayerCollection; public BaseCharacter[] PlayerCollection;
public MudEngine.Networking.Server Server { get; internal set; } public MudEngine.Networking.Server Server { get; internal set; }
public ProtocolType ServerType = ProtocolType.Tcp; public ProtocolType ServerType = ProtocolType.Tcp;
@ -327,7 +324,9 @@ namespace MudEngine.GameManagement
{ {
//This is handled by the Game() Constructor //This is handled by the Game() Constructor
//PlayerCollection = new List<BaseCharacter>(MaximumPlayers); //PlayerCollection = new List<BaseCharacter>(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 = new Networking.Server();
Server.Initialize(ServerPort, ref PlayerCollection); Server.Initialize(ServerPort, ref PlayerCollection);
Server.Start(); Server.Start();

View file

@ -30,15 +30,15 @@ namespace MudEngine.Networking
stage = 0; stage = 0;
port = 0; port = 0;
} }
public bool Initialize(int p, ref List<BaseCharacter>/*BaseCharacter[]*/ pbs) public bool Initialize(int p, ref /*List<BaseCharacter>*/BaseCharacter[] pbs)
{ {
if (stage != 0) if (stage != 0)
return false; return false;
if (p <= 0) if (p <= 0)
return false; return false;
port = p; port = p;
clientThreads = new Thread[pbs.Capacity/*Length*/]; players = pbs;
players = pbs.ToArray(); clientThreads = new Thread[players.Length];
stage++; stage++;
return true; return true;
} }

View file

@ -45,9 +45,6 @@ namespace MUDGame
//Player must be instanced AFTER BuildRealms as it needs Game.InitialRealm.InitialZone.InitialRoom //Player must be instanced AFTER BuildRealms as it needs Game.InitialRealm.InitialZone.InitialRoom
//property so that it can set it's starting room correctly. //property so that it can set it's starting room correctly.
player = new BaseCharacter(game); 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 //Send game info to player
Console.WriteLine(game.GameTitle); Console.WriteLine(game.GameTitle);

View file

@ -39,7 +39,6 @@ namespace MudServer
game.ServerType = ProtocolType.Tcp; game.ServerType = ProtocolType.Tcp;
game.ServerPort = 555; game.ServerPort = 555;
game.MaximumPlayers = 1000; game.MaximumPlayers = 1000;
game.PlayerCollection.Add(serverAdmin);
Game.IsDebug = true; Game.IsDebug = true;
game.Start(); game.Start();