Filter invalid actor IDs when restoring selection save data.

This commit is contained in:
Paul Chote
2019-12-28 11:35:41 +00:00
committed by abcdefg30
parent 7ccc63b51c
commit 2bf16a34d6

View File

@@ -229,7 +229,7 @@ namespace OpenRA.Mods.Common.Traits
if (selectionNode != null) if (selectionNode != null)
{ {
var selected = FieldLoader.GetValue<uint[]>("Selection", selectionNode.Value.Value) var selected = FieldLoader.GetValue<uint[]>("Selection", selectionNode.Value.Value)
.Select(a => self.World.GetActorById(a)); .Select(a => self.World.GetActorById(a)).Where(a => a != null);
Combine(self.World, selected, false, false); Combine(self.World, selected, false, false);
} }
@@ -239,7 +239,7 @@ namespace OpenRA.Mods.Common.Traits
foreach (var n in groupsNode.Value.Nodes) foreach (var n in groupsNode.Value.Nodes)
{ {
var group = FieldLoader.GetValue<uint[]>(n.Key, n.Value.Value) var group = FieldLoader.GetValue<uint[]>(n.Key, n.Value.Value)
.Select(a => self.World.GetActorById(a)); .Select(a => self.World.GetActorById(a)).Where(a => a != null);
controlGroups[int.Parse(n.Key)].AddRange(group); controlGroups[int.Parse(n.Key)].AddRange(group);
} }
} }