65 |
65 |
66 CommandCost cost, ret; |
66 CommandCost cost, ret; |
67 |
67 |
68 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
68 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
69 |
69 |
70 if (!EnsureNoVehicle(tile)) return CMD_ERROR; |
|
71 |
|
72 Axis axis = Extract<Axis, 0>(p1); |
70 Axis axis = Extract<Axis, 0>(p1); |
73 |
71 |
74 tile2 = tile + (axis == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1)); |
72 tile2 = tile + (axis == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1)); |
75 if (!EnsureNoVehicle(tile2)) return CMD_ERROR; |
|
76 |
73 |
77 if (!IsClearWaterTile(tile) || !IsClearWaterTile(tile2)) |
74 if (!IsClearWaterTile(tile) || !IsClearWaterTile(tile2)) |
78 return_cmd_error(STR_3801_MUST_BE_BUILT_ON_WATER); |
75 return_cmd_error(STR_3801_MUST_BE_BUILT_ON_WATER); |
79 |
76 |
80 if (IsBridgeAbove(tile) || IsBridgeAbove(tile2)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); |
77 if (IsBridgeAbove(tile) || IsBridgeAbove(tile2)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); |
287 { |
284 { |
288 switch (GetWaterTileType(tile)) { |
285 switch (GetWaterTileType(tile)) { |
289 case WATER_TILE_CLEAR: |
286 case WATER_TILE_CLEAR: |
290 if (flags & DC_NO_WATER) return_cmd_error(STR_3807_CAN_T_BUILD_ON_WATER); |
287 if (flags & DC_NO_WATER) return_cmd_error(STR_3807_CAN_T_BUILD_ON_WATER); |
291 |
288 |
292 /* Make sure no vehicle is on the tile */ |
|
293 if (!EnsureNoVehicle(tile)) return CMD_ERROR; |
|
294 |
|
295 /* Make sure it's not an edge tile. */ |
289 /* Make sure it's not an edge tile. */ |
296 if (!IS_INT_INSIDE(TileX(tile), 1, MapMaxX() - 1) || |
290 if (!IS_INT_INSIDE(TileX(tile), 1, MapMaxX() - 1) || |
297 !IS_INT_INSIDE(TileY(tile), 1, MapMaxY() - 1)) { |
291 !IS_INT_INSIDE(TileY(tile), 1, MapMaxY() - 1)) { |
298 return_cmd_error(STR_0002_TOO_CLOSE_TO_EDGE_OF_MAP); |
292 return_cmd_error(STR_0002_TOO_CLOSE_TO_EDGE_OF_MAP); |
299 } |
293 } |
300 |
294 |
|
295 /* Make sure no vehicle is on the tile */ |
|
296 if (!EnsureNoVehicle(tile)) return CMD_ERROR; |
|
297 |
301 if (GetTileOwner(tile) != OWNER_WATER && GetTileOwner(tile) != OWNER_NONE && !CheckTileOwnership(tile)) return CMD_ERROR; |
298 if (GetTileOwner(tile) != OWNER_WATER && GetTileOwner(tile) != OWNER_NONE && !CheckTileOwnership(tile)) return CMD_ERROR; |
302 |
299 |
303 if (flags & DC_EXEC) DoClearSquare(tile); |
300 if (flags & DC_EXEC) DoClearSquare(tile); |
304 return CommandCost(_price.clear_water); |
301 return CommandCost(_price.clear_water); |
305 |
302 |
306 case WATER_TILE_COAST: { |
303 case WATER_TILE_COAST: { |
307 Slope slope = GetTileSlope(tile, NULL); |
304 Slope slope = GetTileSlope(tile, NULL); |
308 |
305 |
309 /* Make sure no vehicle is on the tile */ |
306 /* Make sure no vehicle is on the tile */ |
310 if (!EnsureNoVehicle(tile)) return CMD_ERROR; |
307 if (!EnsureNoVehicle(tile)) return CMD_ERROR; |
311 |
|
312 /* Make sure it's not an edge tile. */ |
|
313 if (!IS_INT_INSIDE(TileX(tile), 1, MapMaxX() - 1) || |
|
314 !IS_INT_INSIDE(TileY(tile), 1, MapMaxY() - 1)) { |
|
315 return_cmd_error(STR_0002_TOO_CLOSE_TO_EDGE_OF_MAP); |
|
316 } |
|
317 |
308 |
318 if (flags & DC_EXEC) DoClearSquare(tile); |
309 if (flags & DC_EXEC) DoClearSquare(tile); |
319 if (slope == SLOPE_N || slope == SLOPE_E || slope == SLOPE_S || slope == SLOPE_W) { |
310 if (slope == SLOPE_N || slope == SLOPE_E || slope == SLOPE_S || slope == SLOPE_W) { |
320 return CommandCost(_price.clear_water); |
311 return CommandCost(_price.clear_water); |
321 } else { |
312 } else { |