1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2025-12-16 18:02:13 +01:00

Fix #14607: Bridge-over-station discrepancy depending on build order. (#14608)

When building a custom station, the callback-derived tile layout is ignored during the bridge height test. This caused a discrepancy between building a station under a bridge vs building a bridge over the same station.

Test the station tile layout callback during the bridge height test.
This commit is contained in:
Peter Nelson
2025-09-24 22:45:18 +01:00
committed by GitHub
parent 42c9f84d74
commit 80e58e751a

View File

@@ -1480,14 +1480,23 @@ CommandCost CmdBuildRailStation(DoCommandFlags flags, TileIndex tile_org, RailTy
RailStationTileLayout stl{statspec, numtracks, plat_len}; RailStationTileLayout stl{statspec, numtracks, plat_len};
auto it = stl.begin(); auto it = stl.begin();
TileIndex tile_track = tile_org; TileIndex tile_track = tile_org;
for (uint i = 0; i != numtracks; ++i) { for (uint i = 0; i != numtracks; ++i, tile_track += track_delta) {
TileIndex tile = tile_track; TileIndex tile = tile_track;
for (uint j = 0; j != plat_len; ++j) { for (uint j = 0; j != plat_len; ++j, tile += tile_delta, ++it) {
ret = IsRailStationBridgeAboveOk(tile, statspec, StationType::Rail, *it++ + axis); /* Don't check the layout if there's no bridge above anyway. */
if (!IsBridgeAbove(tile)) continue;
StationGfx gfx = *it + axis;
if (statspec != nullptr) {
uint32_t platinfo = GetPlatformInfo(AXIS_X, gfx, plat_len, numtracks, j, i, false);
/* As the station is not yet completely finished, the station does not yet exist. */
uint16_t callback = GetStationCallback(CBID_STATION_BUILD_TILE_LAYOUT, platinfo, 0, statspec, nullptr, tile);
if (callback != CALLBACK_FAILED && callback <= UINT8_MAX) gfx = (callback & ~1) + axis;
}
ret = IsRailStationBridgeAboveOk(tile, statspec, StationType::Rail, gfx);
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
tile += tile_delta;
} }
tile_track += track_delta;
} }
/* Check if we can allocate a custom stationspec to this station */ /* Check if we can allocate a custom stationspec to this station */