Allow custom commands to be parsed when the player is in a ready state.

This commit is contained in:
Paul Chote
2010-11-08 17:28:59 +13:00
parent d33806e932
commit ed4c588701
3 changed files with 30 additions and 15 deletions

View File

@@ -253,12 +253,6 @@ namespace OpenRA.Server
switch (so.Name)
{
case "Command":
{
if (GameStarted)
SendChatTo(conn, "Cannot change state when game started. ({0})".F(so.Data));
else if (GetClient(conn).State == Session.ClientState.Ready && !(so.Data == "ready" || so.Data == "startgame"))
SendChatTo(conn, "Cannot change state when marked as ready.");
else
{
bool handled = false;
foreach (var t in ServerTraits.WithInterface<IInterpretCommand>())
@@ -271,7 +265,6 @@ namespace OpenRA.Server
SendChatTo(conn, "Unknown server command: {0}".F(so.Data));
}
}
}
break;
case "Chat":

View File

@@ -22,6 +22,17 @@ namespace OpenRA.Server.Traits
public bool InterpretCommand(Connection conn, Session.Client client, string cmd)
{
if (Server.GameStarted)
{
Server.SendChatTo(conn, "Cannot change state when game started. ({0})".F(cmd));
return false;
}
else if (client.State == Session.ClientState.Ready && !(cmd == "ready" || cmd == "startgame"))
{
Server.SendChatTo(conn, "Cannot change state when marked as ready.");
return false;
}
var dict = new Dictionary<string, Func<string, bool>>
{
{ "ready",

View File

@@ -20,6 +20,17 @@ namespace OpenRA.Server.Traits
{
public bool InterpretCommand(Connection conn, Session.Client client, string cmd)
{
if (Server.GameStarted)
{
Server.SendChatTo(conn, "Cannot change state when game started. ({0})".F(cmd));
return false;
}
else if (client.State == Session.ClientState.Ready && !(cmd == "ready" || cmd == "startgame"))
{
Server.SendChatTo(conn, "Cannot change state when marked as ready.");
return false;
}
var dict = new Dictionary<string, Func<string, bool>>
{
{ "name",