diff --git a/OpenRA.Mods.Common/Traits/BotModules/McvManagerBotModule.cs b/OpenRA.Mods.Common/Traits/BotModules/McvManagerBotModule.cs index 2be41d3949..9e972a5faf 100644 --- a/OpenRA.Mods.Common/Traits/BotModules/McvManagerBotModule.cs +++ b/OpenRA.Mods.Common/Traits/BotModules/McvManagerBotModule.cs @@ -229,7 +229,10 @@ namespace OpenRA.Mods.Common.Traits return new List() { new MiniYamlNode("InitialBaseCenter", FieldSaver.FormatValue(initialBaseCenter)), - new MiniYamlNode("ActiveMCVs", FieldSaver.FormatValue(activeMCVs.Select(a => a.ActorID).ToArray())) + new MiniYamlNode("ActiveMCVs", FieldSaver.FormatValue(activeMCVs + .Where(a => !unitCannotBeOrdered(a)) + .Select(a => a.ActorID) + .ToArray())) }; } @@ -247,7 +250,7 @@ namespace OpenRA.Mods.Common.Traits { activeMCVs.Clear(); activeMCVs.AddRange(FieldLoader.GetValue("ActiveMCVs", activeMCVsNode.Value.Value) - .Select(a => world.GetActorById(a))); + .Select(a => world.GetActorById(a)).Where(a => a != null)); } } } diff --git a/OpenRA.Mods.Common/Traits/BotModules/SquadManagerBotModule.cs b/OpenRA.Mods.Common/Traits/BotModules/SquadManagerBotModule.cs index 3bc1d54b18..1780cc4936 100644 --- a/OpenRA.Mods.Common/Traits/BotModules/SquadManagerBotModule.cs +++ b/OpenRA.Mods.Common/Traits/BotModules/SquadManagerBotModule.cs @@ -357,8 +357,14 @@ namespace OpenRA.Mods.Common.Traits { new MiniYamlNode("Squads", "", Squads.Select(s => new MiniYamlNode("Squad", s.Serialize())).ToList()), new MiniYamlNode("InitialBaseCenter", FieldSaver.FormatValue(initialBaseCenter)), - new MiniYamlNode("UnitsHangingAroundTheBase", FieldSaver.FormatValue(unitsHangingAroundTheBase.Select(a => a.ActorID).ToArray())), - new MiniYamlNode("ActiveUnits", FieldSaver.FormatValue(activeUnits.Select(a => a.ActorID).ToArray())), + new MiniYamlNode("UnitsHangingAroundTheBase", FieldSaver.FormatValue(unitsHangingAroundTheBase + .Where(a => !unitCannotBeOrdered(a)) + .Select(a => a.ActorID) + .ToArray())), + new MiniYamlNode("ActiveUnits", FieldSaver.FormatValue(activeUnits + .Where(a => !unitCannotBeOrdered(a)) + .Select(a => a.ActorID) + .ToArray())), new MiniYamlNode("RushTicks", FieldSaver.FormatValue(rushTicks)), new MiniYamlNode("AssignRolesTicks", FieldSaver.FormatValue(assignRolesTicks)), new MiniYamlNode("AttackForceTicks", FieldSaver.FormatValue(attackForceTicks)), @@ -380,7 +386,7 @@ namespace OpenRA.Mods.Common.Traits { unitsHangingAroundTheBase.Clear(); unitsHangingAroundTheBase.AddRange(FieldLoader.GetValue("UnitsHangingAroundTheBase", unitsHangingAroundTheBaseNode.Value.Value) - .Select(a => self.World.GetActorById(a))); + .Select(a => self.World.GetActorById(a)).Where(a => a != null)); } var activeUnitsNode = data.FirstOrDefault(n => n.Key == "ActiveUnits"); @@ -388,7 +394,7 @@ namespace OpenRA.Mods.Common.Traits { activeUnits.Clear(); activeUnits.AddRange(FieldLoader.GetValue("ActiveUnits", activeUnitsNode.Value.Value) - .Select(a => self.World.GetActorById(a))); + .Select(a => self.World.GetActorById(a)).Where(a => a != null)); } var rushTicksNode = data.FirstOrDefault(n => n.Key == "RushTicks");