diff options
author | rubidium <rubidium@openttd.org> | 2013-03-31 20:07:32 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2013-03-31 20:07:32 +0000 |
commit | 99866912207a456e41715f87b91c558396af0ea8 (patch) | |
tree | 0a8b30170c33b33d767012fec03aef078beb9b1d | |
parent | 28a54208a37f4b43f6da1525366415ba072feebc (diff) | |
download | openttd-99866912207a456e41715f87b91c558396af0ea8.tar.xz |
(svn r25132) -Fix [FS#5510, FS#5516]: station rebuilding could leave reserved tiles which caused crashes later on
-rw-r--r-- | src/station_cmd.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index b2f6ba3aa..3a0275fad 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -1319,8 +1319,16 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32 TILE_AREA_LOOP(tile, update_reservation_area) { DiagDirection dir = AxisToDiagDir(axis); TileIndexDiff tile_offset = TileOffsByDiagDir(dir); - TileIndex platform_begin = tile - tile_offset * (st->GetPlatformLength(tile, ReverseDiagDir(dir)) - 1); - TileIndex platform_end = tile + tile_offset * (st->GetPlatformLength(tile, dir) - 1); + TileIndex platform_begin = tile; + TileIndex platform_end = tile; + + /* We can only account for tiles that are reachable from this tile, so ignore primarily blocked tiles while finding the platform begin and end. */ + for (TileIndex next_tile = platform_begin - tile_offset; IsCompatibleTrainStationTile(next_tile, platform_begin); next_tile -= tile_offset) { + platform_begin = next_tile; + } + for (TileIndex next_tile = platform_end + tile_offset; IsCompatibleTrainStationTile(next_tile, platform_end); next_tile += tile_offset) { + platform_end = next_tile; + } /* If there is at least on reservation on the platform, we reserve the whole platform. */ bool reservation = false; |