diff --git a/OpenRA.Mods.Common/Traits/BotModules/SupportPowerBotModule.cs b/OpenRA.Mods.Common/Traits/BotModules/SupportPowerBotModule.cs index 1b6a75262f..ae217c882f 100644 --- a/OpenRA.Mods.Common/Traits/BotModules/SupportPowerBotModule.cs +++ b/OpenRA.Mods.Common/Traits/BotModules/SupportPowerBotModule.cs @@ -40,9 +40,10 @@ namespace OpenRA.Mods.Common.Traits { readonly World world; readonly Player player; + readonly Dictionary waitingPowers = new Dictionary(); + readonly Dictionary powerDecisions = new Dictionary(); + readonly List stalePowers = new List(); SupportPowerManager supportPowerManager; - Dictionary waitingPowers = new Dictionary(); - Dictionary powerDecisions = new Dictionary(); public SupportPowerBotModule(Actor self, SupportPowerBotModuleInfo info) : base(info) @@ -108,6 +109,13 @@ namespace OpenRA.Mods.Common.Traits bot.QueueOrder(new Order(sp.Key, supportPowerManager.Self, Target.FromCell(world, attackLocation.Value), false) { SuppressVisualFeedback = true }); } } + + // Remove stale powers + stalePowers.AddRange(waitingPowers.Keys.Where(wp => !supportPowerManager.Powers.ContainsKey(wp.Key))); + foreach (var p in stalePowers) + waitingPowers.Remove(p); + + stalePowers.Clear(); } /// Scans the map in chunks, evaluating all actors in each.