From aafb49b3c42de938e29bf4cd7f27f4ba55ba921c Mon Sep 17 00:00:00 2001 From: rubidium Date: Mon, 28 May 2007 22:11:42 +0000 Subject: [PATCH] (svn r9968) [0.5] -Backport from trunk (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. --- tunnelbridge_cmd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c index e021ec0dc6..d5c13a59ef 100644 --- a/tunnelbridge_cmd.c +++ b/tunnelbridge_cmd.c @@ -1349,7 +1349,13 @@ static void ChangeTileOwner_TunnelBridge(TileIndex tile, PlayerID old_player, Pl SetTileOwner(tile, OWNER_NONE); } } 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. */ + SetTileOwner(tile, OWNER_NONE); + } } } }