HPF is aware of map projection changes.
An event is added to Map to indicate when the cell projection is changed. This is important as this can mean Map.Contains(CPos) could now return different results for the cell. The HierarchicalPathFinder is made aware of these changes so it can rebuild any out-of-date information. This fixes prevent a crash if a cell that was previously outside the map changes height and becomes inside the map. The local path search will explore the cell as it is inside the map - but if the HPF was unaware if had been updated, it will still consider the cell to be outside the map and unreachable, resulting in a crash.
This commit is contained in:
committed by
Paul Chote
parent
d8ebb96077
commit
39e48d9e8d
@@ -281,6 +281,10 @@ namespace OpenRA.Mods.Common.Pathfinder
|
||||
// When we build the cost table, it depends on the movement costs of the cells at that time.
|
||||
// When this changes, we must update the cost table.
|
||||
locomotor.CellCostChanged += RequireCostRefreshInCell;
|
||||
|
||||
// If the map projection changes, the result of Map.Contains(CPos) may change.
|
||||
// We need to rebuild grids to account for this possibility.
|
||||
this.world.Map.CellProjectionChanged += RequireProjectionRefreshInCell;
|
||||
}
|
||||
|
||||
public (
|
||||
@@ -619,6 +623,14 @@ namespace OpenRA.Mods.Common.Pathfinder
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When map projection changes for a cell, marks the grid it belongs to as out of date.
|
||||
/// </summary>
|
||||
void RequireProjectionRefreshInCell(CPos cell)
|
||||
{
|
||||
dirtyGridIndexes.Add(GridIndex(cell));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="BlockedByActor.Immovable"/> defines immovability based on the mobile trait. The blocking rules
|
||||
/// in <see cref="Locomotor.CanMoveFreelyInto(Actor, CPos, SubCell, BlockedByActor, Actor)"/> allow units to
|
||||
|
||||
Reference in New Issue
Block a user