Change: Store station blocked/wires/pylons flags in map.

This stores three flags in unused map bits, and avoids having to look up
station graphics and custom station specs to determine blocked/wires/pylons
status.

This potentially affects rail pathfinding performance.

Savegame version is not bumped, as the flags can just be updated every
time.

(cherry picked from commit cb658e6cc6e1c114c1eaafaaa5b14849f04ca083)
This commit is contained in:
Peter Nelson
2023-09-25 20:22:36 +01:00
committed by Jonathan G Rennison
parent e162e7a331
commit b2a1ec96f1
8 changed files with 124 additions and 51 deletions

View File

@@ -872,46 +872,6 @@ const StationSpec *GetStationSpec(TileIndex t)
return specindex < st->speclist.size() ? st->speclist[specindex].spec : nullptr;
}
/**
* Check whether a rail station tile is NOT traversable.
* @param tile %Tile to test.
* @return Station tile is blocked.
* @note This could be cached (during build) in the map array to save on all the dereferencing.
*/
bool IsStationTileBlocked(TileIndex tile)
{
const StationSpec *statspec = GetStationSpec(tile);
return statspec != nullptr && HasBit(statspec->blocked, GetStationGfx(tile));
}
/**
* Check if a rail station tile shall have pylons when electrified.
* @param tile %Tile to test.
* @return Tile shall have pylons.
* @note This could be cached (during build) in the map array to save on all the dereferencing.
*/
bool CanStationTileHavePylons(TileIndex tile)
{
const StationSpec *statspec = GetStationSpec(tile);
uint gfx = GetStationGfx(tile);
/* Default stations do not draw pylons under roofs (gfx >= 4) */
return statspec != nullptr ? HasBit(statspec->pylons, gfx) : gfx < 4;
}
/**
* Check if a rail station tile shall have wires when electrified.
* @param tile %Tile to test.
* @return Tile shall have wires.
* @note This could be cached (during build) in the map array to save on all the dereferencing.
*/
bool CanStationTileHaveWires(TileIndex tile)
{
const StationSpec *statspec = GetStationSpec(tile);
return statspec == nullptr || !HasBit(statspec->wires, GetStationGfx(tile));
}
/** Wrapper for animation control, see GetStationCallback. */
uint16 GetAnimStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, BaseStation *st, TileIndex tile, int extra_data)
{