More refactoring

This commit is contained in:
Paul Chote
2010-11-08 17:15:50 +13:00
parent e83838e9ff
commit d33806e932
4 changed files with 24 additions and 12 deletions

View File

@@ -16,8 +16,10 @@ using OpenRA.FileFormats;
namespace OpenRA.Server.Traits
{
public class LobbyCommands : IInterpretCommand, IStartServer, IClientJoined
public class LobbyCommands : IInterpretCommand, INotifyServerStart, IClientJoined
{
public static int MaxSpectators = 4; // How many spectators to allow // @todo Expose this as an option
public bool InterpretCommand(Connection conn, Session.Client client, string cmd)
{
var dict = new Dictionary<string, Func<string, bool>>
@@ -242,7 +244,7 @@ namespace OpenRA.Server.Traits
.ToList();
// Generate slots for spectators
for (int i = 0; i < Server.MaxSpectators; i++)
for (int i = 0; i < MaxSpectators; i++)
Server.lobbyInfo.Slots.Add(new Session.Slot
{
Spectator = true,

View File

@@ -15,7 +15,8 @@ namespace OpenRA.Server.Traits
// Returns true if order is handled
public interface IInterpretCommand { bool InterpretCommand(Connection conn, Session.Client client, string cmd); }
public interface INotifySyncLobbyInfo { void LobbyInfoSynced(); }
public interface IStartServer { void ServerStarted(); }
public interface INotifyServerStart { void ServerStarted(); }
public interface INotifyServerShutdown { void ServerShutdown(); }
public interface IStartGame { void GameStarted(); }
public interface IClientJoined { void ClientJoined(Connection conn); }
public interface ITick
@@ -25,7 +26,7 @@ namespace OpenRA.Server.Traits
}
public class DebugServerTrait : IInterpretCommand, IStartGame, INotifySyncLobbyInfo
public class DebugServerTrait : IInterpretCommand, IStartGame, INotifySyncLobbyInfo, INotifyServerStart, INotifyServerShutdown
{
public bool InterpretCommand(Connection conn, Session.Client client, string cmd)
{
@@ -42,5 +43,15 @@ namespace OpenRA.Server.Traits
{
Console.WriteLine("LobbyInfoSynced()");
}
public void ServerStarted()
{
Console.WriteLine("ServerStarted()");
}
public void ServerShutdown()
{
Console.WriteLine("ServerShutdown()");
}
}
}