Merge pull request #13050 from rob-v/DefeatedPlayersCanNotPauseGame

Lost players except Host can not pause game #12227
This commit is contained in:
abcdefg30
2017-04-18 17:00:04 +02:00
committed by GitHub
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)
{
if (world.LocalPlayer == null)
return;
switch (name)
{
case "pause":
world.IssueOrder(new Order("PauseGame", null, false)
{
TargetString = world.Paused ? "UnPause" : "Pause"
});
if (Game.IsHost || (world.LocalPlayer != null && world.LocalPlayer.WinState != WinState.Lost))
world.IssueOrder(new Order("PauseGame", null, false)
{
TargetString = world.Paused ? "UnPause" : "Pause"
});
break;
case "surrender":
world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false));
if (world.LocalPlayer != null)
world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false));
break;
}
}

View File

@@ -241,7 +241,8 @@ namespace OpenRA.Mods.Common.Widgets
{
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);
else if (key == Game.Settings.Keys.SelectAllUnitsKey && !World.IsGameOver)
{