Filter invalid actors when loading and saving games.
This commit is contained in:
@@ -229,7 +229,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return new List<MiniYamlNode>()
|
return new List<MiniYamlNode>()
|
||||||
{
|
{
|
||||||
new MiniYamlNode("InitialBaseCenter", FieldSaver.FormatValue(initialBaseCenter)),
|
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.Clear();
|
||||||
activeMCVs.AddRange(FieldLoader.GetValue<uint[]>("ActiveMCVs", activeMCVsNode.Value.Value)
|
activeMCVs.AddRange(FieldLoader.GetValue<uint[]>("ActiveMCVs", activeMCVsNode.Value.Value)
|
||||||
.Select(a => world.GetActorById(a)));
|
.Select(a => world.GetActorById(a)).Where(a => a != null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -357,8 +357,14 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
new MiniYamlNode("Squads", "", Squads.Select(s => new MiniYamlNode("Squad", s.Serialize())).ToList()),
|
new MiniYamlNode("Squads", "", Squads.Select(s => new MiniYamlNode("Squad", s.Serialize())).ToList()),
|
||||||
new MiniYamlNode("InitialBaseCenter", FieldSaver.FormatValue(initialBaseCenter)),
|
new MiniYamlNode("InitialBaseCenter", FieldSaver.FormatValue(initialBaseCenter)),
|
||||||
new MiniYamlNode("UnitsHangingAroundTheBase", FieldSaver.FormatValue(unitsHangingAroundTheBase.Select(a => a.ActorID).ToArray())),
|
new MiniYamlNode("UnitsHangingAroundTheBase", FieldSaver.FormatValue(unitsHangingAroundTheBase
|
||||||
new MiniYamlNode("ActiveUnits", FieldSaver.FormatValue(activeUnits.Select(a => a.ActorID).ToArray())),
|
.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("RushTicks", FieldSaver.FormatValue(rushTicks)),
|
||||||
new MiniYamlNode("AssignRolesTicks", FieldSaver.FormatValue(assignRolesTicks)),
|
new MiniYamlNode("AssignRolesTicks", FieldSaver.FormatValue(assignRolesTicks)),
|
||||||
new MiniYamlNode("AttackForceTicks", FieldSaver.FormatValue(attackForceTicks)),
|
new MiniYamlNode("AttackForceTicks", FieldSaver.FormatValue(attackForceTicks)),
|
||||||
@@ -380,7 +386,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
unitsHangingAroundTheBase.Clear();
|
unitsHangingAroundTheBase.Clear();
|
||||||
unitsHangingAroundTheBase.AddRange(FieldLoader.GetValue<uint[]>("UnitsHangingAroundTheBase", unitsHangingAroundTheBaseNode.Value.Value)
|
unitsHangingAroundTheBase.AddRange(FieldLoader.GetValue<uint[]>("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");
|
var activeUnitsNode = data.FirstOrDefault(n => n.Key == "ActiveUnits");
|
||||||
@@ -388,7 +394,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
activeUnits.Clear();
|
activeUnits.Clear();
|
||||||
activeUnits.AddRange(FieldLoader.GetValue<uint[]>("ActiveUnits", activeUnitsNode.Value.Value)
|
activeUnits.AddRange(FieldLoader.GetValue<uint[]>("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");
|
var rushTicksNode = data.FirstOrDefault(n => n.Key == "RushTicks");
|
||||||
|
|||||||
Reference in New Issue
Block a user