From c9b19ffe525da8862d9dcb502a0293054ab1299b Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Thu, 22 Mar 2018 20:12:45 +0000 Subject: [PATCH] Prevent attack move crashing if selected actors die. - Cancel attack move if all actors die. - Command bar no longer shows available actions from any dead units. --- OpenRA.Mods.Common/Traits/AttackMove.cs | 6 ++++++ OpenRA.Mods.Common/Widgets/Logic/Ingame/CommandBarLogic.cs | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Traits/AttackMove.cs b/OpenRA.Mods.Common/Traits/AttackMove.cs index 1dcbb75b6e..86d5c2b389 100644 --- a/OpenRA.Mods.Common/Traits/AttackMove.cs +++ b/OpenRA.Mods.Common/Traits/AttackMove.cs @@ -165,6 +165,12 @@ namespace OpenRA.Mods.Common.Traits } } + public override void Tick(World world) + { + if (subjects.All(s => s.Actor.IsDead)) + world.CancelInputMode(); + } + public override string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi) { var prefix = mi.Modifiers.HasModifier(Modifiers.Ctrl) ? "assaultmove" : "attackmove"; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/CommandBarLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/CommandBarLogic.cs index 468c2a0f9a..8006d4e8df 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/CommandBarLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/CommandBarLogic.cs @@ -267,7 +267,7 @@ namespace OpenRA.Mods.Common.Widgets return; selectedActors = world.Selection.Actors - .Where(a => a.Owner == world.LocalPlayer && a.IsInWorld) + .Where(a => a.Owner == world.LocalPlayer && a.IsInWorld && !a.IsDead) .ToArray(); attackMoveDisabled = !selectedActors.Any(a => a.Info.HasTraitInfo() && a.Info.HasTraitInfo());