From 4579e8af062972b33971689a2680543bbb31230f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 26 Sep 2015 13:24:07 +0200 Subject: [PATCH] don't let the AI assign orders to units not in the world --- OpenRA.Mods.Common/AI/HackyAI.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/OpenRA.Mods.Common/AI/HackyAI.cs b/OpenRA.Mods.Common/AI/HackyAI.cs index 7d06ecf5b2..c6b4e0474d 100644 --- a/OpenRA.Mods.Common/AI/HackyAI.cs +++ b/OpenRA.Mods.Common/AI/HackyAI.cs @@ -182,7 +182,7 @@ namespace OpenRA.Mods.Common.AI readonly IPathFinder pathfinder; readonly Func isEnemyUnit; - readonly Predicate unitIsDeadOrHasNewOwner; + readonly Predicate unitCannotBeOrdered; Dictionary waitingPowers = new Dictionary(); Dictionary powerDecisions = new Dictionary(); @@ -236,7 +236,8 @@ namespace OpenRA.Mods.Common.AI Player.Stances[unit.Owner] == Stance.Enemy && !unit.Info.HasTraitInfo() && unit.Info.HasTraitInfo(); - unitIsDeadOrHasNewOwner = a => a.Owner != Player || a.IsDead; + + unitCannotBeOrdered = a => a.Owner != Player || a.IsDead || !a.IsInWorld; foreach (var decision in info.PowerDecisions) powerDecisions.Add(decision.OrderName, decision); @@ -606,7 +607,7 @@ namespace OpenRA.Mods.Common.AI { squads.RemoveAll(s => !s.IsValid); foreach (var s in squads) - s.Units.RemoveAll(unitIsDeadOrHasNewOwner); + s.Units.RemoveAll(unitCannotBeOrdered); } // Use of this function requires that one squad of this type. Hence it is a piece of shit @@ -625,8 +626,9 @@ namespace OpenRA.Mods.Common.AI void AssignRolesToIdleUnits(Actor self) { CleanSquads(); - activeUnits.RemoveAll(unitIsDeadOrHasNewOwner); - unitsHangingAroundTheBase.RemoveAll(unitIsDeadOrHasNewOwner); + + activeUnits.RemoveAll(unitCannotBeOrdered); + unitsHangingAroundTheBase.RemoveAll(unitCannotBeOrdered); if (--rushTicks <= 0) {