Mercurial > hg > openttd
changeset 8075:8de1216a9e47 draft
(svn r11636) -Fix: it was possible to build/remove road/tram in tunnel/bridge when there was vehicle in it
author | smatz <smatz@openttd.org> |
---|---|
date | Sat, 15 Dec 2007 13:59:38 +0000 |
parents | 5a1a58696b87 |
children | acfeedbb9362 |
files | src/road_cmd.cpp |
diffstat | 1 files changed, 27 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -121,16 +121,27 @@ switch (GetTileType(tile)) { case MP_ROAD: if (_game_mode != GM_EDITOR && GetRoadOwner(tile, rt) == OWNER_TOWN) t = GetTownByTile(tile); + if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; break; case MP_STATION: if (!IsDriveThroughStopTile(tile)) return CMD_ERROR; + if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; break; case MP_TUNNELBRIDGE: - if ((IsTunnel(tile) && GetTunnelTransportType(tile) != TRANSPORT_ROAD) || - (IsBridge(tile) && GetBridgeTransportType(tile) != TRANSPORT_ROAD)) return CMD_ERROR; - break; + { + TileIndex endtile; + if (IsTunnel(tile)) { + if (GetTunnelTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR; + endtile = GetOtherTunnelEnd(tile); + } else { + if (GetBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR; + endtile = GetOtherBridgeEnd(tile); + } + + if (GetVehicleTunnelBridge(tile, endtile) != NULL) return CMD_ERROR; + } break; default: return CMD_ERROR; @@ -143,8 +154,6 @@ if (!CheckAllowRemoveRoad(tile, pieces, &edge_road, rt)) return CMD_ERROR; - if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; - /* check if you're allowed to remove the street owned by a town * removal allowance depends on difficulty setting */ if (!CheckforTownRating(flags, t, ROAD_REMOVE)) return CMD_ERROR; @@ -502,12 +511,19 @@ break; case MP_TUNNELBRIDGE: - if ((IsTunnel(tile) && GetTunnelTransportType(tile) != TRANSPORT_ROAD) || - (IsBridge(tile) && GetBridgeTransportType(tile) != TRANSPORT_ROAD)) return CMD_ERROR; - if (HasBit(GetRoadTypes(tile), rt)) return_cmd_error(STR_1007_ALREADY_BUILT); - /* Don't allow "upgrading" the bridge/tunnel when vehicles are already driving on it */ - if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; - break; + { + TileIndex endtile; + if (IsTunnel(tile)) { + if (GetTunnelTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR; + endtile = GetOtherTunnelEnd(tile); + } else { + if (GetBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR; + endtile = GetOtherBridgeEnd(tile); + } + if (HasBit(GetRoadTypes(tile), rt)) return_cmd_error(STR_1007_ALREADY_BUILT); + /* Don't allow "upgrading" the bridge/tunnel when vehicles are already driving on it */ + if (GetVehicleTunnelBridge(tile, endtile) != NULL) return CMD_ERROR; + } break; default: do_clear:;