mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r11636) -Fix: it was possible to build/remove road/tram in tunnel/bridge when there was vehicle in it
This commit is contained in:
parent
828c242291
commit
46724104fe
|
@ -121,16 +121,27 @@ CommandCost CmdRemoveRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
switch (GetTileType(tile)) {
|
switch (GetTileType(tile)) {
|
||||||
case MP_ROAD:
|
case MP_ROAD:
|
||||||
if (_game_mode != GM_EDITOR && GetRoadOwner(tile, rt) == OWNER_TOWN) t = GetTownByTile(tile);
|
if (_game_mode != GM_EDITOR && GetRoadOwner(tile, rt) == OWNER_TOWN) t = GetTownByTile(tile);
|
||||||
|
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MP_STATION:
|
case MP_STATION:
|
||||||
if (!IsDriveThroughStopTile(tile)) return CMD_ERROR;
|
if (!IsDriveThroughStopTile(tile)) return CMD_ERROR;
|
||||||
|
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MP_TUNNELBRIDGE:
|
case MP_TUNNELBRIDGE:
|
||||||
if ((IsTunnel(tile) && GetTunnelTransportType(tile) != TRANSPORT_ROAD) ||
|
{
|
||||||
(IsBridge(tile) && GetBridgeTransportType(tile) != TRANSPORT_ROAD)) return CMD_ERROR;
|
TileIndex endtile;
|
||||||
break;
|
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:
|
default:
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
|
@ -143,8 +154,6 @@ CommandCost CmdRemoveRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
if (!CheckAllowRemoveRoad(tile, pieces, &edge_road, rt)) return CMD_ERROR;
|
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
|
/* check if you're allowed to remove the street owned by a town
|
||||||
* removal allowance depends on difficulty setting */
|
* removal allowance depends on difficulty setting */
|
||||||
if (!CheckforTownRating(flags, t, ROAD_REMOVE)) return CMD_ERROR;
|
if (!CheckforTownRating(flags, t, ROAD_REMOVE)) return CMD_ERROR;
|
||||||
|
@ -502,12 +511,19 @@ CommandCost CmdBuildRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MP_TUNNELBRIDGE:
|
case MP_TUNNELBRIDGE:
|
||||||
if ((IsTunnel(tile) && GetTunnelTransportType(tile) != TRANSPORT_ROAD) ||
|
{
|
||||||
(IsBridge(tile) && GetBridgeTransportType(tile) != TRANSPORT_ROAD)) return CMD_ERROR;
|
TileIndex endtile;
|
||||||
if (HasBit(GetRoadTypes(tile), rt)) return_cmd_error(STR_1007_ALREADY_BUILT);
|
if (IsTunnel(tile)) {
|
||||||
/* Don't allow "upgrading" the bridge/tunnel when vehicles are already driving on it */
|
if (GetTunnelTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR;
|
||||||
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
|
endtile = GetOtherTunnelEnd(tile);
|
||||||
break;
|
} 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:
|
default:
|
||||||
do_clear:;
|
do_clear:;
|
||||||
|
|
Loading…
Reference in New Issue