MudEngine:

- Realm, Room and Zone editing no longer closes the menu once a task is finished. Use the Exit menu option to close the editing menu
 - Revised how the Game checks for existing InitialLocations. If a InitialLocation does not exist, but is created during server runtime, new players will automatically be placed there without the need to restart the server.
 - Improved the List command.
This commit is contained in:
Scionwest_cp 2010-09-12 16:18:28 -07:00
parent b3238d0227
commit 304b2d07eb
7 changed files with 155 additions and 91 deletions

View file

@ -21,7 +21,8 @@ namespace MudEngine.Commands
public List<String> Help { get; set; } public List<String> Help { get; set; }
private Realm realm; private Realm realm;
BaseCharacter player; private BaseCharacter player;
private Boolean isEditing;
public CommandEditRealm() public CommandEditRealm()
{ {
@ -63,6 +64,11 @@ namespace MudEngine.Commands
//Otherwise, the Realm does exist and was retrieved. //Otherwise, the Realm does exist and was retrieved.
//Lets build our Editing menu's and allow for Realm Editing. //Lets build our Editing menu's and allow for Realm Editing.
else else
{
//Always re-build the menu so the user doesn't need to re-enter the edit command.
//When the user selects the exit option, the loop will end.
isEditing = true;
while (isEditing)
{ {
//Construct the main editing menu. //Construct the main editing menu.
BuildMenuMain(); BuildMenuMain();
@ -83,6 +89,7 @@ namespace MudEngine.Commands
//Parse the menu option that the admin supplied. //Parse the menu option that the admin supplied.
ParseMenuSelection(value); ParseMenuSelection(value);
}
//let the admin know that we have now exited the editor. //let the admin know that we have now exited the editor.
player.Send("Editing completed."); player.Send("Editing completed.");
} }
@ -238,6 +245,7 @@ namespace MudEngine.Commands
ParseInitialSelection(entry); ParseInitialSelection(entry);
break; break;
case 9: case 9:
isEditing = false;
break; break;
default: default:
break; break;
@ -322,7 +330,7 @@ namespace MudEngine.Commands
else if (input.ToLower().StartsWith("edit")) else if (input.ToLower().StartsWith("edit"))
{ {
//Retrieve the line number from the users input. //Retrieve the line number from the users input.
String editLine= input.Substring("edit".Length).Trim(); String editLine = input.Substring("edit".Length).Trim();
//If no line number was provided, cancel. //If no line number was provided, cancel.
if (String.IsNullOrEmpty(editLine)) if (String.IsNullOrEmpty(editLine))

View file

@ -21,7 +21,8 @@ namespace MudEngine.Commands
public List<String> Help { get; set; } public List<String> Help { get; set; }
private Room room; private Room room;
BaseCharacter player; private BaseCharacter player;
private Boolean isEditing;
public CommandEditRoom() public CommandEditRoom()
{ {
@ -81,6 +82,10 @@ namespace MudEngine.Commands
//Otherwise, the Room does exist and was retrieved. //Otherwise, the Room does exist and was retrieved.
//Lets build our Editing menu's and allow for Room Editing. //Lets build our Editing menu's and allow for Room Editing.
else else
{
isEditing = true;
while (isEditing)
{ {
//Construct the main editing menu. //Construct the main editing menu.
BuildMenuMain(); BuildMenuMain();
@ -101,6 +106,7 @@ namespace MudEngine.Commands
//Parse the menu option that the admin supplied. //Parse the menu option that the admin supplied.
ParseMenuSelection(value); ParseMenuSelection(value);
}
//let the admin know that we have now exited the editor. //let the admin know that we have now exited the editor.
player.Send("Editing completed."); player.Send("Editing completed.");
} }
@ -120,7 +126,7 @@ namespace MudEngine.Commands
player.Send("3: Senses"); player.Send("3: Senses");
player.Send("4: Initial Room"); player.Send("4: Initial Room");
player.Send("5: Settings"); player.Send("5: Settings");
player.Send("6: Doorways"); //player.Send("6: Doorways");
player.Send("9: Exit"); player.Send("9: Exit");
player.Send("Enter numeric selection: ", false); player.Send("Enter numeric selection: ", false);
} }
@ -262,6 +268,7 @@ namespace MudEngine.Commands
case 6: //Doorways case 6: //Doorways
break; break;
case 9: case 9:
isEditing = false;
break; break;
default: default:
break; break;
@ -694,7 +701,7 @@ namespace MudEngine.Commands
//Next, we need to loop through every Room within this Room //Next, we need to loop through every Room within this Room
//and update their Rooms names to match the new one //and update their Rooms names to match the new one
foreach(Realm r in player.ActiveGame.World.RealmCollection) foreach (Realm r in player.ActiveGame.World.RealmCollection)
{ {
foreach (Zone z in r.ZoneCollection) foreach (Zone z in r.ZoneCollection)
{ {

View file

@ -21,7 +21,8 @@ namespace MudEngine.Commands
public List<String> Help { get; set; } public List<String> Help { get; set; }
private Zone zone; private Zone zone;
BaseCharacter player; private BaseCharacter player;
private Boolean isEditing;
public CommandEditZone() public CommandEditZone()
{ {
@ -75,6 +76,11 @@ namespace MudEngine.Commands
//Otherwise, the Zone does exist and was retrieved. //Otherwise, the Zone does exist and was retrieved.
//Lets build our Editing menu's and allow for Zone Editing. //Lets build our Editing menu's and allow for Zone Editing.
else else
{
//Always re-build the menu so the user doesn't need to re-enter the edit command.
//When the user selects the exit option, the loop will end.
isEditing = true;
while (isEditing)
{ {
//Construct the main editing menu. //Construct the main editing menu.
BuildMenuMain(); BuildMenuMain();
@ -95,6 +101,7 @@ namespace MudEngine.Commands
//Parse the menu option that the admin supplied. //Parse the menu option that the admin supplied.
ParseMenuSelection(value); ParseMenuSelection(value);
}
//let the admin know that we have now exited the editor. //let the admin know that we have now exited the editor.
player.Send("Editing completed."); player.Send("Editing completed.");
} }
@ -113,7 +120,7 @@ namespace MudEngine.Commands
player.Send("2: Names"); player.Send("2: Names");
player.Send("3: Senses"); player.Send("3: Senses");
player.Send("4: Initial Zone"); player.Send("4: Initial Zone");
player.Send("5: Settings"); // player.Send("5: Settings");
player.Send("9: Exit"); player.Send("9: Exit");
player.Send("Enter numeric selection: ", false); player.Send("Enter numeric selection: ", false);
} }
@ -253,6 +260,7 @@ namespace MudEngine.Commands
case 5: //Settings case 5: //Settings
break; break;
case 9: case 9:
isEditing = false;
break; break;
default: default:
break; break;

View file

@ -195,6 +195,7 @@ namespace MudEngine.GameManagement
scriptEngine = new Scripting.ScriptEngine(this); scriptEngine = new Scripting.ScriptEngine(this);
World = new GameWorld(this); World = new GameWorld(this);
WorldTime = new GameTime(this); WorldTime = new GameTime(this);
InitialRealm = new Realm(this);
//Prepare the Save Paths for all of our Game objects. //Prepare the Save Paths for all of our Game objects.
DataPaths = new SaveDataPaths("World", "Player"); DataPaths = new SaveDataPaths("World", "Player");
@ -279,6 +280,17 @@ namespace MudEngine.GameManagement
//Load the game and world if it was previously saved. //Load the game and world if it was previously saved.
Load(); Load();
String[] env = InitialRealm.InitialZone.InitialRoom.RoomLocation.Split('>');
if (env.Length == 3)
{
if ((String.IsNullOrEmpty(env[0])) || (String.IsNullOrEmpty(env[1])) || (String.IsNullOrEmpty(env[2])))
{
Log.Write("Error: No starting location defined!");
}
}
else
Log.Write("Error: No starting location defined!");
Log.Write("Game startup complete."); Log.Write("Game startup complete.");
return true; return true;
} }
@ -429,6 +441,16 @@ namespace MudEngine.GameManagement
//Restore the world. //Restore the world.
World.Load(); World.Load();
//Check if any the initial room exists or not.
if ((this.InitialRealm == null) || (this.InitialRealm.InitialZone == null) || (this.InitialRealm.InitialZone.InitialRoom == null))
{
Log.Write("ERROR: No initial location defined. Game startup failed!");
Log.Write("Players will start in the Abyss. Each player will contain their own instance of this room.");
//return false;
}
else
Log.Write("Initial Location loaded: " + this.InitialRealm.InitialZone.InitialRoom.RoomLocationWithoutExtension);
Log.Write("Game Restore complete."); Log.Write("Game Restore complete.");
} }

View file

@ -74,17 +74,6 @@ namespace MudEngine.GameManagement
break; break;
} }
} }
//Check if any the initial room exists or not.
if ((_Game.InitialRealm == null) || (_Game.InitialRealm.InitialZone == null) || (_Game.InitialRealm.InitialZone.InitialRoom == null))
{
Log.Write("ERROR: No initial location defined. Game startup failed!");
Log.Write("Players will start in the Abyss. Each player will contain their own instance of this room.");
//return false;
}
else
Log.Write("Initial Location loaded: " + _Game.InitialRealm.InitialZone.InitialRoom.RoomLocationWithoutExtension);
} }
public void Save() public void Save()

View file

@ -70,7 +70,7 @@ namespace MudEngine.GameObjects.Environment
{ {
get get
{ {
return this.Realm + ">" + Zone + ">" + Filename; return this.Realm + ">" + this.Zone + ">" + this.Filename;
} }
} }

View file

@ -57,11 +57,20 @@ public class CommandList : IGameCommand
switch (data[0]) switch (data[0])
{ {
case "realms": case "realms":
if (player.ActiveGame.World.RealmCollection.Count == 0)
player.Send("There are currently no loaded Realm files.");
else
{
player.Send("Currently loaded Realm files:"); player.Send("Currently loaded Realm files:");
foreach (Realm r in player.ActiveGame.World.RealmCollection) foreach (Realm r in player.ActiveGame.World.RealmCollection)
player.Send(r.Filename + " | ", false); player.Send(r.Filename + " | ", false);
}
break; break;
case "players": case "players":
if (System.IO.Directory.GetFiles(player.ActiveGame.DataPaths.Players, "*.character").Length == 0)
player.Send("There are currently no characters created on this server.");
else
{
player.Send("Players with created characters:"); player.Send("Players with created characters:");
BaseCharacter p = new BaseCharacter(player.ActiveGame); BaseCharacter p = new BaseCharacter(player.ActiveGame);
foreach (String file in System.IO.Directory.GetFiles(player.ActiveGame.DataPaths.Players, "*.character")) foreach (String file in System.IO.Directory.GetFiles(player.ActiveGame.DataPaths.Players, "*.character"))
@ -69,14 +78,35 @@ public class CommandList : IGameCommand
p.Load(file); p.Load(file);
player.Send(p.Name + " | ", false); player.Send(p.Name + " | ", false);
} }
}
break; break;
case "zones": case "zones":
player.Send("Currently loaded Zones. This spans across every Realm in the world."); if (player.ActiveGame.World.RealmCollection.Count == 0)
{
player.Send("There are currently no Zones created on this server.");
}
else
{
List<String> names = new List<String>();
foreach (Realm r in player.ActiveGame.World.RealmCollection) foreach (Realm r in player.ActiveGame.World.RealmCollection)
{ {
foreach (Zone z in r.ZoneCollection) foreach (Zone z in r.ZoneCollection)
{ {
player.Send(System.IO.Path.GetFileNameWithoutExtension(r.Filename) + ">" + System.IO.Path.GetFileNameWithoutExtension(z.Filename)); names.Add(System.IO.Path.GetFileNameWithoutExtension(r.Filename) + ">" + System.IO.Path.GetFileNameWithoutExtension(z.Filename));
}
}
if (names.Count == 0)
{
player.Send("There are currently no Zones created on this server.");
}
else
{
player.Send("Currently loaded Zones. This spans across every Realm in the world.");
foreach (String name in names)
{
player.Send(name);
}
} }
} }
break; break;