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

@@ -1641,7 +1641,18 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32
SetStationTileRandomBits(tile, GB(Random(), 0, 4));
SetAnimationFrame(tile, 0);
if (!IsStationTileBlocked(tile)) c->infrastructure.rail[rt]++;
/* Should be the same as layout but axis component could be wrong... */
StationGfx gfx = GetStationGfx(tile);
bool blocked = statspec != nullptr && HasBit(statspec->blocked, gfx);
/* Default stations do not draw pylons under roofs (gfx >= 4) */
bool pylons = statspec != nullptr ? HasBit(statspec->pylons, gfx) : gfx < 4;
bool wires = statspec == nullptr || !HasBit(statspec->wires, gfx);
SetStationTileBlocked(tile, blocked);
SetStationTileHavePylons(tile, pylons);
SetStationTileHaveWires(tile, wires);
if (!blocked) c->infrastructure.rail[rt]++;
c->infrastructure.station++;
if (statspec != nullptr) {