Change: Store station blocked/wires/pylons flags in map. (#11337)

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.
This commit is contained in:
Peter Nelson
2023-09-30 12:30:25 +01:00
committed by GitHub
parent fd79d34ba9
commit b5dc9328f2
8 changed files with 124 additions and 51 deletions

View File

@@ -840,46 +840,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_t GetAnimStationCallback(CallbackID callback, uint32_t param1, uint32_t param2, const StationSpec *statspec, BaseStation *st, TileIndex tile, int)
{