diff --git a/MudEngine/Commands/CommandLogin.cs b/MudEngine/Commands/CommandLogin.cs index 6a073b6..f84c66e 100644 --- a/MudEngine/Commands/CommandLogin.cs +++ b/MudEngine/Commands/CommandLogin.cs @@ -62,7 +62,8 @@ namespace MudEngine.Commands player.Load(savedFile); player.Send("Welcome back " + player.Name + "!"); } - player.CommandSystem.ExecuteCommand("Look", player); + + //player.CommandSystem.ExecuteCommand("Look", player); //Handled in BaseCharacter.Initialize() now. return new CommandResults(); } } diff --git a/MudEngine/Commands/CommandWalk.cs b/MudEngine/Commands/CommandWalk.cs index a3cbda9..c89e3e6 100644 --- a/MudEngine/Commands/CommandWalk.cs +++ b/MudEngine/Commands/CommandWalk.cs @@ -39,7 +39,9 @@ namespace MudEngine.Commands } } } - return new CommandResults("Unable to travel in that direction."); + player.Send("Unable to travel in that direction."); + + return null; } } } diff --git a/MudEngine/GameManagement/Game.cs b/MudEngine/GameManagement/Game.cs index c97405d..0290090 100644 --- a/MudEngine/GameManagement/Game.cs +++ b/MudEngine/GameManagement/Game.cs @@ -207,7 +207,7 @@ namespace MudEngine.GameManagement //Instance all of the Games Objects. CurrencyList = new List(); scriptEngine = new Scripting.ScriptEngine(this); - RealmCollection = new List(); + RealmCollection = new List(); //Prepare the Save Paths for all of our Game objects. SaveDataPaths paths = new SaveDataPaths(); @@ -227,6 +227,12 @@ namespace MudEngine.GameManagement ServerType = ProtocolType.Tcp; ServerPort = 555; MaximumPlayers = 1000; + + //Setup the player arrays + //used to be in Start + PlayerCollection = new BaseCharacter[MaximumPlayers]; + for (int i = 0; i < MaximumPlayers; i++) + PlayerCollection[i] = new BaseCharacter(this); } #endregion @@ -237,6 +243,9 @@ namespace MudEngine.GameManagement public bool Start() { Log.Write("Game Initializing..."); + if (!Directory.Exists(DataPaths.Players)) + Directory.CreateDirectory(DataPaths.Players); + //First, compile and execute all of the script files. scriptEngine.ScriptType = ScriptEngine.ScriptTypes.SourceFiles; scriptEngine.Initialize(); @@ -365,11 +374,6 @@ namespace MudEngine.GameManagement /// private void StartServer() { - //This is handled by the Game() Constructor - //PlayerCollection = new List(MaximumPlayers); - 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/GameObjects/Characters/BaseCharacter.cs b/MudEngine/GameObjects/Characters/BaseCharacter.cs index 90ba8f3..0e938a1 100644 --- a/MudEngine/GameObjects/Characters/BaseCharacter.cs +++ b/MudEngine/GameObjects/Characters/BaseCharacter.cs @@ -200,8 +200,6 @@ namespace MudEngine.GameObjects.Characters } } - ExecuteCommand("Login"); - //Set the players initial room if ((ActiveGame.InitialRealm == null) || (ActiveGame.InitialRealm.InitialZone == null) || (ActiveGame.InitialRealm.InitialZone.InitialRoom == null)) { @@ -211,6 +209,9 @@ namespace MudEngine.GameObjects.Characters } else CurrentRoom = ActiveGame.InitialRealm.InitialZone.InitialRoom; + + ExecuteCommand("Login"); + ExecuteCommand("Look"); //MUST happen after Room setup is completed, otherwise the player default Abyss Room is printed. } internal void Receive(string data) { diff --git a/MudEngine/Scripting/ScriptEngine.cs b/MudEngine/Scripting/ScriptEngine.cs index eef82cb..db29663 100644 --- a/MudEngine/Scripting/ScriptEngine.cs +++ b/MudEngine/Scripting/ScriptEngine.cs @@ -165,7 +165,9 @@ namespace MudEngine.Scripting CompilerParameters param = new CompilerParameters(new string[] {"mscorlib.dll", "System.dll", "MudEngine.dll"}); param.GenerateExecutable = false; param.GenerateInMemory = true; - param.OutputAssembly = Path.Combine(oldPath, "Scripts.dll"); + if (!param.GenerateInMemory) + param.OutputAssembly = Path.Combine(oldPath, "Scripts.dll"); + param.IncludeDebugInformation = false; param.TreatWarningsAsErrors = true; @@ -288,6 +290,9 @@ namespace MudEngine.Scripting private void InitializeSourceFiles() { + if (!Directory.Exists(ScriptPath)) + Directory.CreateDirectory(ScriptPath); + string[] scripts = Directory.GetFiles(ScriptPath, "*.cs", SearchOption.AllDirectories); if (scripts.Length == 0) diff --git a/MudServer/Program.cs b/MudServer/Program.cs index 5d424f8..e4d152a 100644 --- a/MudServer/Program.cs +++ b/MudServer/Program.cs @@ -17,6 +17,7 @@ namespace MudServer { static void Main(string[] args) { + Log.Write("Launching..."); ScriptEngine scriptEngine; Game game; @@ -26,29 +27,32 @@ namespace MudServer Log.Write("Settings.ini missing!"); FileManager.WriteLine("Settings.ini", "Scripts", "ScriptPath"); FileManager.WriteLine("Settings.ini", ".cs", "ScriptExtension"); + Log.Write("Settings.ini re-created with default values"); } + Log.Write("Loading settings..."); scriptEngine = new ScriptEngine(new Game(), ScriptEngine.ScriptTypes.SourceFiles); scriptEngine.ScriptPath = FileManager.GetData("Settings.ini", "ScriptPath"); scriptEngine.ScriptExtension = FileManager.GetData("Settings.ini", "ScriptExtension"); //scriptEngine.CompileScripts(); - + Log.Write("Initializing Script Engine for Script Compilation..."); scriptEngine.Initialize(); GameObject obj = scriptEngine.GetObjectOf("Game"); - Log.Write(Log.GetMessages()); + Console.WriteLine(Log.GetMessages()); Log.FlushMessages(); if (obj == null) { - Log.Write("Setting up the Engine Game Manager..."); + Log.Write("Setting up the Default Engine Game Manager..."); game = new Game(); obj = new GameObject(game, "Game"); scriptEngine = new ScriptEngine((Game)obj.Instance, ScriptEngine.ScriptTypes.Assembly); } else { + Log.Write("Setting up " + obj.GetProperty().GameTitle + " Manager..."); game = (Game)obj.Instance; scriptEngine = new ScriptEngine(game, ScriptEngine.ScriptTypes.Assembly); } @@ -60,6 +64,9 @@ namespace MudServer //MUST be called before game.Start() //scriptEngine.Initialize(); //game.scriptEngine = scriptEngine; //Pass this script engine off to the game to use now. + Log.Write("Starting " + obj.GetProperty().GameTitle + "..."); + Console.WriteLine(Log.GetMessages()); + Log.FlushMessages(); game.Start(); @@ -69,43 +76,6 @@ namespace MudServer Log.FlushMessages(); System.Threading.Thread.Sleep(1); } - - - /* - Game game = new Game(); - Zeroth realm = new Zeroth(game); - - realm.BuildZeroth(); - - //BaseCharacter serverAdmin = new BaseCharacter(game); - - //Setup the game - game.AutoSave = true; - game.BaseCurrencyName = "Copper"; - game.BaseCurrencyAmount = 1; - game.CompanyName = "Mud Designer"; - game.DayLength = 60 * 8; - game.GameTitle = "Test Mud Project"; - game.HideRoomNames = false; - game.PreCacheObjects = true; - game.ProjectPath = FileManager.GetDataPath(SaveDataTypes.Root); - game.TimeOfDay = Game.TimeOfDayOptions.Transition; - game.TimeOfDayTransition = 30; - game.Version = "0.1"; - game.Website = "http://MudDesigner.Codeplex.com"; - game.ServerType = ProtocolType.Tcp; - game.ServerPort = 555; - game.MaximumPlayers = 1000; - Game.IsDebug = false; - - game.Start(); - - while (game.IsRunning) - { - Console.Write(Log.GetMessages()); - Log.FlushMessages(); - System.Threading.Thread.Sleep(1); - */ } } }