New Command Order. GUI changes to settings no longer produce messages in chat. Can't enter commands in chat any more.
This commit is contained in:
@@ -182,6 +182,11 @@ namespace OpenRA
|
||||
return new Order("TeamChat", null, text) { IsImmediate = true };
|
||||
}
|
||||
|
||||
public static Order Command(string text)
|
||||
{
|
||||
return new Order("Command", null, text) { IsImmediate = true };
|
||||
}
|
||||
|
||||
public static Order StartProduction(Player subject, string item, int count)
|
||||
{
|
||||
return new Order("StartProduction", subject.PlayerActor, new int2( count, 0 ), item );
|
||||
|
||||
@@ -428,37 +428,26 @@ namespace OpenRA.Server
|
||||
{
|
||||
switch (so.Name)
|
||||
{
|
||||
case "Chat":
|
||||
if (!HandleAsCommand(conn, so))
|
||||
foreach (var c in conns.Except(conn).ToArray())
|
||||
DispatchOrdersToClient(c, GetClient(conn).Index, 0, so.Serialize());
|
||||
break;
|
||||
//TODO: send to those with the same team
|
||||
case "TeamChat":
|
||||
if (!HandleAsCommand(conn, so))
|
||||
foreach (var c in conns.Except(conn).ToArray())
|
||||
DispatchOrdersToClient(c, GetClient(conn).Index, 0, so.Serialize());
|
||||
break;
|
||||
case "Command":
|
||||
{
|
||||
if(GameStarted)
|
||||
SendChatTo(conn, "Cannot change state when game started.");
|
||||
else if (GetClient(conn).State == Session.ClientState.Ready && so.Data != "ready")
|
||||
SendChatTo(conn, "Cannot change state when marked as ready.");
|
||||
else if (!InterpretCommand(conn, so.Data))
|
||||
{
|
||||
Console.WriteLine("Bad server command: {0}", so.Data);
|
||||
SendChatTo(conn, "Bad server command.");
|
||||
};
|
||||
}
|
||||
break;
|
||||
case "Chat": case "TeamChat":
|
||||
foreach (var c in conns.Except(conn).ToArray())
|
||||
DispatchOrdersToClient(c, GetClient(conn).Index, 0, so.Serialize());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static bool HandleAsCommand(Connection conn, ServerOrder so)
|
||||
{
|
||||
if (!so.Data.StartsWith("/")) return false;
|
||||
|
||||
var cmd = so.Data.Substring(1);
|
||||
if(GameStarted)
|
||||
SendChatTo(conn, "Cannot change state when game started.");
|
||||
else if (GetClient(conn).State == Session.ClientState.Ready && cmd != "ready")
|
||||
SendChatTo(conn, "Cannot change state when marked as ready.");
|
||||
else if (!InterpretCommand(conn, cmd))
|
||||
{
|
||||
Console.WriteLine("Bad server command: {0}", cmd);
|
||||
SendChatTo(conn, "Bad server command.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static Session.Client GetClient(Connection conn)
|
||||
{
|
||||
return lobbyInfo.Clients.First(c => c.Index == conn.PlayerIndex);
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
{
|
||||
var owned = Game.LobbyInfo.Clients.Any(c => c.SpawnPoint == sp);
|
||||
if (sp == 0 || !owned)
|
||||
Game.IssueOrder(Order.Chat("/spawn {0}".F(sp)));
|
||||
Game.IssueOrder(Order.Command("spawn {0}".F(sp)));
|
||||
};
|
||||
|
||||
map.SpawnColors = () =>
|
||||
@@ -95,8 +95,8 @@ namespace OpenRA.Widgets.Delegates
|
||||
lockTeamsCheckbox.OnMouseDown = mi =>
|
||||
{
|
||||
if (Game.IsHost)
|
||||
Game.IssueOrder(Order.Chat(
|
||||
"/lockteams {0}".F(!Game.LobbyInfo.GlobalSettings.LockTeams)));
|
||||
Game.IssueOrder(Order.Command(
|
||||
"lockteams {0}".F(!Game.LobbyInfo.GlobalSettings.LockTeams)));
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -162,7 +162,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
if (name.Text == c.Name)
|
||||
return true;
|
||||
|
||||
Game.IssueOrder(Order.Chat( "/name "+name.Text ));
|
||||
Game.IssueOrder(Order.Command( "name "+name.Text ));
|
||||
Game.Settings.PlayerName = name.Text;
|
||||
Game.Settings.Save();
|
||||
Chrome.selectedWidget = null;
|
||||
@@ -238,7 +238,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
newIndex = (newIndex + d) % Game.world.PlayerColors().Count();
|
||||
|
||||
Game.IssueOrder(
|
||||
Order.Chat("/pal " + newIndex));
|
||||
Order.Command("pal " + newIndex));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -258,7 +258,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
if (nextCountry == null)
|
||||
nextCountry = countries.First();
|
||||
|
||||
Game.IssueOrder(Order.Chat("/race " + nextCountry));
|
||||
Game.IssueOrder(Order.Command("race " + nextCountry));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -268,7 +268,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
//HACK: Can't set this as part of the fuction as LocalClient/State not initalised yet
|
||||
Chrome.rootWidget.GetWidget("SERVER_LOBBY").GetWidget<ButtonWidget>("CHANGEMAP_BUTTON").Visible
|
||||
= (Game.IsHost && Game.LocalClient.State == Session.ClientState.Ready);
|
||||
Game.IssueOrder(Order.Chat("/ready"));
|
||||
Game.IssueOrder(Order.Command("ready"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
var newIndex = (Game.LocalClient.Team + d) % (Game.world.Map.PlayerCount+1);
|
||||
|
||||
Game.IssueOrder(
|
||||
Order.Chat("/team " + newIndex));
|
||||
Order.Command("team " + newIndex));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
bg.GetWidget<LabelWidget>("CURMAP_PLAYERS").GetText = () => {return Map.PlayerCount.ToString();};
|
||||
|
||||
bg.GetWidget("BUTTON_OK").OnMouseUp = mi => {
|
||||
Game.IssueOrder(Order.Chat("/map " + Map.Uid));
|
||||
Game.IssueOrder(Order.Command("map " + Map.Uid));
|
||||
r.CloseWindow();
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace OpenRA
|
||||
localPlayerIndex = index;
|
||||
if (Game.LobbyInfo.Clients.Count > 0 && !string.IsNullOrEmpty(Game.Settings.PlayerName)
|
||||
&& Game.LobbyInfo.Clients[index].Name != Game.Settings.PlayerName)
|
||||
Game.IssueOrder(Order.Chat("/name " + Game.Settings.PlayerName));
|
||||
Game.IssueOrder(Order.Command("name " + Game.Settings.PlayerName));
|
||||
}
|
||||
|
||||
public readonly Actor WorldActor;
|
||||
|
||||
Reference in New Issue
Block a user