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)
{
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);

View file

@ -180,7 +180,7 @@ namespace MudEngine.GameManagement
CurrencyList = new List<Currency>();
scriptEngine = new Scripting.ScriptEngine(this);
RealmCollection = new List<Realm>();
PlayerCollection = new List<BaseCharacter>();
//PlayerCollection = new List<BaseCharacter>();
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<BaseCharacter> PlayerCollection;
//public BaseCharacter[] PlayerCollection;
//public List<BaseCharacter> 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<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.Initialize(ServerPort, ref PlayerCollection);
Server.Start();

View file

@ -30,15 +30,15 @@ namespace MudEngine.Networking
stage = 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)
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;
}

View file

@ -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);

View file

@ -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();