Codechange: Unify where rail station tile flags are set. (#12531)

This avoids repeating the logic in three places.
This commit is contained in:
Peter Nelson
2024-04-18 18:54:10 +01:00
committed by GitHub
parent 04a3bf76e8
commit 45886e50b2
4 changed files with 23 additions and 34 deletions

View File

@@ -276,16 +276,7 @@ CommandCost CmdBuildRailWaypoint(DoCommandFlag flags, TileIndex start_tile, Axis
MakeRailWaypoint(tile, wp->owner, wp->index, axis, layout[i], GetRailType(tile));
SetCustomStationSpecIndex(tile, map_spec_index);
/* Should be the same as layout but axis component could be wrong... */
StationGfx gfx = GetStationGfx(tile);
bool blocked = spec != nullptr && HasBit(spec->blocked, gfx);
/* Default stations do not draw pylons under roofs (gfx >= 4) */
bool pylons = spec != nullptr ? HasBit(spec->pylons, gfx) : gfx < 4;
bool wires = spec == nullptr || !HasBit(spec->wires, gfx);
SetStationTileBlocked(tile, blocked);
SetStationTileHavePylons(tile, pylons);
SetStationTileHaveWires(tile, wires);
SetRailStationTileFlags(tile, spec);
SetRailStationReservation(tile, reserved);
MarkTileDirtyByTile(tile);