Lost players except Host can not pause game #12227

This commit is contained in:
rob-v
2017-04-02 12:03:55 +02:00
parent 739653ce37
commit a11ff104a2
2 changed files with 11 additions and 9 deletions

View File

@@ -35,19 +35,20 @@ namespace OpenRA.Mods.Common.Commands
public void InvokeCommand(string name, string arg) public void InvokeCommand(string name, string arg)
{ {
if (world.LocalPlayer == null)
return;
switch (name) switch (name)
{ {
case "pause": case "pause":
if (Game.IsHost || (world.LocalPlayer != null && world.LocalPlayer.WinState != WinState.Lost))
world.IssueOrder(new Order("PauseGame", null, false) world.IssueOrder(new Order("PauseGame", null, false)
{ {
TargetString = world.Paused ? "UnPause" : "Pause" TargetString = world.Paused ? "UnPause" : "Pause"
}); });
break; break;
case "surrender": case "surrender":
if (world.LocalPlayer != null)
world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false)); world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false));
break; break;
} }
} }

View File

@@ -241,7 +241,8 @@ namespace OpenRA.Mods.Common.Widgets
{ {
var key = Hotkey.FromKeyInput(e); var key = Hotkey.FromKeyInput(e);
if (key == Game.Settings.Keys.PauseKey && World.LocalPlayer != null) // Disable pausing for spectators if (key == Game.Settings.Keys.PauseKey
&& (Game.IsHost || (World.LocalPlayer != null && World.LocalPlayer.WinState != WinState.Lost))) // Disable pausing for spectators and defeated players
World.SetPauseState(!World.Paused); World.SetPauseState(!World.Paused);
else if (key == Game.Settings.Keys.SelectAllUnitsKey && !World.IsGameOver) else if (key == Game.Settings.Keys.SelectAllUnitsKey && !World.IsGameOver)
{ {