summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-05-28 21:32:26 +0000
committerrubidium <rubidium@openttd.org>2007-05-28 21:32:26 +0000
commitdf1bbe55e2096d327d412870768884c6be12685c (patch)
tree451676aaa38a9bfa39ce242979b56d5d2e91def6
parentc5d073a84f359a03c910b7a91ac8b356e7927ecc (diff)
downloadopenttd-df1bbe55e2096d327d412870768884c6be12685c.tar.xz
(svn r9966) -Fix: bridges and tunnels were not always removed on bankruptcy, thus leaving tunnels/bridges with an invalid owner that would crash the game when clicking with the query tool on them.
-rw-r--r--src/tunnelbridge_cmd.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index 96a00160a..81ebff29d 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -1325,7 +1325,14 @@ static void ChangeTileOwner_TunnelBridge(TileIndex tile, PlayerID old_player, Pl
if (new_player != PLAYER_SPECTATOR) {
SetTileOwner(tile, new_player);
} else {
- DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
+ if (CmdFailed(DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) {
+ /* When clearing the bridge/tunnel failed there are still vehicles on/in
+ * the bridge/tunnel. As all *our* vehicles are already removed, they
+ * must be of another owner. Therefor this must be a road bridge/tunnel.
+ * In that case we can safely reassign the ownership to OWNER_NONE. */
+ assert((IsTunnel(tile) ? GetTunnelTransportType(tile) : GetBridgeTransportType(tile)) == TRANSPORT_ROAD);
+ SetTileOwner(tile, OWNER_NONE);
+ }
}
}