MudEngine:

- CommandLogin no longer invokes the Look Command
 - Fixed CommandWalk no longer telling the player an invalid direction message when trying to walk to someplace that does not exist.
 - Moved PlayerCollection array referencing from Game.Start() to the Game's constructor so that scripts may change the player class during its startup.
 - BaseCharacter now invokes the Look command after Login command is completed.
 - ScriptEngine no longer sets the output path for a compiled script if the script is designated as compile to memory.
 - Fixed custom players not being able to access their own Methods and Properties during runtime.

MudServer:
 - Additional Console Log Messages added.
This commit is contained in:
Scionwest_cp 2010-08-06 23:37:52 -07:00
parent 88378584ac
commit 8b1be3d1eb
6 changed files with 34 additions and 51 deletions

View file

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

View file

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

View file

@ -207,7 +207,7 @@ namespace MudEngine.GameManagement
//Instance all of the Games Objects.
CurrencyList = new List<Currency>();
scriptEngine = new Scripting.ScriptEngine(this);
RealmCollection = new List<Realm>();
RealmCollection = new List<Realm>();
//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
/// </summary>
private void StartServer()
{
//This is handled by the Game() Constructor
//PlayerCollection = new List<BaseCharacter>(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();

View file

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

View file

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

View file

@ -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);
*/
}
}
}