Fix actors with no footprint leaving stale data when deleted.
This commit is contained in:
@@ -133,12 +133,13 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!preview.Bounds.IsEmpty)
|
if (!preview.Bounds.IsEmpty)
|
||||||
screenMap.Add(preview, preview.Bounds);
|
screenMap.Add(preview, preview.Bounds);
|
||||||
|
|
||||||
foreach (var kv in preview.Footprint)
|
|
||||||
AddPreviewLocation(preview, kv.Key);
|
|
||||||
|
|
||||||
// Fallback to the actor's CenterPosition for the ActorMap if it has no Footprint
|
// Fallback to the actor's CenterPosition for the ActorMap if it has no Footprint
|
||||||
if (!preview.Footprint.Any())
|
var footprint = preview.Footprint.Select(kv => kv.Key).ToArray();
|
||||||
AddPreviewLocation(preview, worldRenderer.World.Map.CellContaining(preview.CenterPosition));
|
if (!footprint.Any())
|
||||||
|
footprint = new[] { worldRenderer.World.Map.CellContaining(preview.CenterPosition) };
|
||||||
|
|
||||||
|
foreach (var cell in footprint)
|
||||||
|
AddPreviewLocation(preview, cell);
|
||||||
|
|
||||||
if (!initialSetup)
|
if (!initialSetup)
|
||||||
{
|
{
|
||||||
@@ -154,16 +155,21 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
previews.Remove(preview);
|
previews.Remove(preview);
|
||||||
screenMap.Remove(preview);
|
screenMap.Remove(preview);
|
||||||
|
|
||||||
foreach (var kv in preview.Footprint)
|
// Fallback to the actor's CenterPosition for the ActorMap if it has no Footprint
|
||||||
|
var footprint = preview.Footprint.Select(kv => kv.Key).ToArray();
|
||||||
|
if (!footprint.Any())
|
||||||
|
footprint = new[] { worldRenderer.World.Map.CellContaining(preview.CenterPosition) };
|
||||||
|
|
||||||
|
foreach (var cell in footprint)
|
||||||
{
|
{
|
||||||
List<EditorActorPreview> list;
|
List<EditorActorPreview> list;
|
||||||
if (!cellMap.TryGetValue(kv.Key, out list))
|
if (!cellMap.TryGetValue(cell, out list))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
list.Remove(preview);
|
list.Remove(preview);
|
||||||
|
|
||||||
if (!list.Any())
|
if (!list.Any())
|
||||||
cellMap.Remove(kv.Key);
|
cellMap.Remove(cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateNeighbours(preview.Footprint);
|
UpdateNeighbours(preview.Footprint);
|
||||||
|
|||||||
Reference in New Issue
Block a user