119 |
119 |
120 Town *t = NULL; |
120 Town *t = NULL; |
121 switch (GetTileType(tile)) { |
121 switch (GetTileType(tile)) { |
122 case MP_ROAD: |
122 case MP_ROAD: |
123 if (_game_mode != GM_EDITOR && GetRoadOwner(tile, rt) == OWNER_TOWN) t = GetTownByTile(tile); |
123 if (_game_mode != GM_EDITOR && GetRoadOwner(tile, rt) == OWNER_TOWN) t = GetTownByTile(tile); |
|
124 if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; |
124 break; |
125 break; |
125 |
126 |
126 case MP_STATION: |
127 case MP_STATION: |
127 if (!IsDriveThroughStopTile(tile)) return CMD_ERROR; |
128 if (!IsDriveThroughStopTile(tile)) return CMD_ERROR; |
|
129 if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; |
128 break; |
130 break; |
129 |
131 |
130 case MP_TUNNELBRIDGE: |
132 case MP_TUNNELBRIDGE: |
131 if ((IsTunnel(tile) && GetTunnelTransportType(tile) != TRANSPORT_ROAD) || |
133 { |
132 (IsBridge(tile) && GetBridgeTransportType(tile) != TRANSPORT_ROAD)) return CMD_ERROR; |
134 TileIndex endtile; |
133 break; |
135 if (IsTunnel(tile)) { |
|
136 if (GetTunnelTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR; |
|
137 endtile = GetOtherTunnelEnd(tile); |
|
138 } else { |
|
139 if (GetBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR; |
|
140 endtile = GetOtherBridgeEnd(tile); |
|
141 } |
|
142 |
|
143 if (GetVehicleTunnelBridge(tile, endtile) != NULL) return CMD_ERROR; |
|
144 } break; |
134 |
145 |
135 default: |
146 default: |
136 return CMD_ERROR; |
147 return CMD_ERROR; |
137 } |
148 } |
138 |
149 |
140 RoadTypes rts = GetRoadTypes(tile); |
151 RoadTypes rts = GetRoadTypes(tile); |
141 /* The tile doesn't have the given road type */ |
152 /* The tile doesn't have the given road type */ |
142 if (!HasBit(rts, rt)) return CMD_ERROR; |
153 if (!HasBit(rts, rt)) return CMD_ERROR; |
143 |
154 |
144 if (!CheckAllowRemoveRoad(tile, pieces, &edge_road, rt)) return CMD_ERROR; |
155 if (!CheckAllowRemoveRoad(tile, pieces, &edge_road, rt)) return CMD_ERROR; |
145 |
|
146 if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; |
|
147 |
156 |
148 /* check if you're allowed to remove the street owned by a town |
157 /* check if you're allowed to remove the street owned by a town |
149 * removal allowance depends on difficulty setting */ |
158 * removal allowance depends on difficulty setting */ |
150 if (!CheckforTownRating(flags, t, ROAD_REMOVE)) return CMD_ERROR; |
159 if (!CheckforTownRating(flags, t, ROAD_REMOVE)) return CMD_ERROR; |
151 |
160 |
500 /* Don't allow "upgrading" the roadstop when vehicles are already driving on it */ |
509 /* Don't allow "upgrading" the roadstop when vehicles are already driving on it */ |
501 if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; |
510 if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; |
502 break; |
511 break; |
503 |
512 |
504 case MP_TUNNELBRIDGE: |
513 case MP_TUNNELBRIDGE: |
505 if ((IsTunnel(tile) && GetTunnelTransportType(tile) != TRANSPORT_ROAD) || |
514 { |
506 (IsBridge(tile) && GetBridgeTransportType(tile) != TRANSPORT_ROAD)) return CMD_ERROR; |
515 TileIndex endtile; |
507 if (HasBit(GetRoadTypes(tile), rt)) return_cmd_error(STR_1007_ALREADY_BUILT); |
516 if (IsTunnel(tile)) { |
508 /* Don't allow "upgrading" the bridge/tunnel when vehicles are already driving on it */ |
517 if (GetTunnelTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR; |
509 if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; |
518 endtile = GetOtherTunnelEnd(tile); |
510 break; |
519 } else { |
|
520 if (GetBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR; |
|
521 endtile = GetOtherBridgeEnd(tile); |
|
522 } |
|
523 if (HasBit(GetRoadTypes(tile), rt)) return_cmd_error(STR_1007_ALREADY_BUILT); |
|
524 /* Don't allow "upgrading" the bridge/tunnel when vehicles are already driving on it */ |
|
525 if (GetVehicleTunnelBridge(tile, endtile) != NULL) return CMD_ERROR; |
|
526 } break; |
511 |
527 |
512 default: |
528 default: |
513 do_clear:; |
529 do_clear:; |
514 ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
530 ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
515 if (CmdFailed(ret)) return ret; |
531 if (CmdFailed(ret)) return ret; |