Allow custom commands to be parsed when the player is in a ready state.
This commit is contained in:
@@ -254,22 +254,15 @@ namespace OpenRA.Server
|
|||||||
{
|
{
|
||||||
case "Command":
|
case "Command":
|
||||||
{
|
{
|
||||||
if (GameStarted)
|
bool handled = false;
|
||||||
SendChatTo(conn, "Cannot change state when game started. ({0})".F(so.Data));
|
foreach (var t in ServerTraits.WithInterface<IInterpretCommand>())
|
||||||
else if (GetClient(conn).State == Session.ClientState.Ready && !(so.Data == "ready" || so.Data == "startgame"))
|
if ((handled = t.InterpretCommand(conn, GetClient(conn), so.Data)))
|
||||||
SendChatTo(conn, "Cannot change state when marked as ready.");
|
break;
|
||||||
else
|
|
||||||
|
if (!handled)
|
||||||
{
|
{
|
||||||
bool handled = false;
|
Log.Write("server", "Unknown server command: {0}", so.Data);
|
||||||
foreach (var t in ServerTraits.WithInterface<IInterpretCommand>())
|
SendChatTo(conn, "Unknown server command: {0}".F(so.Data));
|
||||||
if ((handled = t.InterpretCommand(conn, GetClient(conn), so.Data)))
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (!handled)
|
|
||||||
{
|
|
||||||
Log.Write("server", "Unknown server command: {0}", so.Data);
|
|
||||||
SendChatTo(conn, "Unknown server command: {0}".F(so.Data));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -22,6 +22,17 @@ namespace OpenRA.Server.Traits
|
|||||||
|
|
||||||
public bool InterpretCommand(Connection conn, Session.Client client, string cmd)
|
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>>
|
var dict = new Dictionary<string, Func<string, bool>>
|
||||||
{
|
{
|
||||||
{ "ready",
|
{ "ready",
|
||||||
|
|||||||
@@ -20,6 +20,17 @@ namespace OpenRA.Server.Traits
|
|||||||
{
|
{
|
||||||
public bool InterpretCommand(Connection conn, Session.Client client, string cmd)
|
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>>
|
var dict = new Dictionary<string, Func<string, bool>>
|
||||||
{
|
{
|
||||||
{ "name",
|
{ "name",
|
||||||
|
|||||||
Reference in New Issue
Block a user