From cf427f8cb3e2de8d3ff6347c5cd398e01ba57729 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 7 Sep 2019 14:43:15 +0100 Subject: [PATCH] Drop invalid power references when loading save games. --- .../Traits/BotModules/SupportPowerBotModule.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Traits/BotModules/SupportPowerBotModule.cs b/OpenRA.Mods.Common/Traits/BotModules/SupportPowerBotModule.cs index 0743eefda5..1b6a75262f 100644 --- a/OpenRA.Mods.Common/Traits/BotModules/SupportPowerBotModule.cs +++ b/OpenRA.Mods.Common/Traits/BotModules/SupportPowerBotModule.cs @@ -208,8 +208,14 @@ namespace OpenRA.Mods.Common.Traits var waitingPowersNode = data.FirstOrDefault(n => n.Key == "WaitingPowers"); if (waitingPowersNode != null) + { foreach (var n in waitingPowersNode.Value.Nodes) - waitingPowers[supportPowerManager.Powers[n.Key]] = FieldLoader.GetValue("WaitingPowers", n.Value.Value); + { + SupportPowerInstance instance; + if (supportPowerManager.Powers.TryGetValue(n.Key, out instance)) + waitingPowers[instance] = FieldLoader.GetValue("WaitingPowers", n.Value.Value); + } + } } } }