muddesigner/MudEngine/Commands/CommandRestart.cs
Scionwest_cp bbd411fdd1 MudEngine:
- Removed the need for the old CommandResult Type to be a returned value on all commands. Command.Execute() is now just void.
 - All commands updated to now return a value. They use player.Send() to direct messages to the player instead.
 - Removed CommandClear from the project and made it a script so that developers can see how to write custom command scripts.
2010-08-15 13:06:51 -07:00

53 lines
No EOL
1.9 KiB
C#

//Microsoft.NET Framework
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
using System.Net.Sockets;
//MUD Engine
using MudEngine.GameObjects.Characters;
using MudEngine.GameManagement;
using MudEngine.GameObjects.Environment;
using MudEngine.GameObjects;
using MudEngine.FileSystem;
namespace MudEngine.Commands
{
class CommandRestart : IGameCommand
{
public String Name { get; set; }
public Boolean Override { get; set; }
public void Execute(String command, BaseCharacter player)
{
if (player.Role == SecurityRoles.Admin)
{
String path = player.ActiveGame.DataPaths.Players;
for (Int32 i = 0; i < player.ActiveGame.PlayerCollection.Length; i++)
{
String filename = Path.Combine(path, player.ActiveGame.PlayerCollection[i].Filename);
player.ActiveGame.PlayerCollection[i].Save(filename);
}
//player.ActiveGame.Server.EndServer(); //-Handled in Game.Shutdown() below.
player.ActiveGame.Shutdown();
player.ActiveGame.Start();
/* Game.Start() calls this, do we need a reference to the playercollection?
* They should be unloaded anyway and re-loaded during game.start to force a clean restart of all objects.
player.ActiveGame.Server.Initialize(555, ref player.ActiveGame.PlayerCollection);
*/
Log.Write("Server Restart Completed.");
//This is never printed as CommandResults is no longer outputted to the player console, player.Send is used
player.Send("Server Restarted.");
return;
}
player.Send("Access Denied.");
}
}
}