458 if (CmdFailed(cost)) return_cmd_error(STR_1800_LAND_SLOPED_IN_WRONG_DIRECTION); |
458 if (CmdFailed(cost)) return_cmd_error(STR_1800_LAND_SLOPED_IN_WRONG_DIRECTION); |
459 |
459 |
460 if (cost && (!_patches.build_on_slopes || _is_old_ai_player)) |
460 if (cost && (!_patches.build_on_slopes || _is_old_ai_player)) |
461 return CMD_ERROR; |
461 return CMD_ERROR; |
462 |
462 |
463 if (!(ti.type == MP_STREET && (ti.map5 & 0xF0) == 0)) { |
463 if (ti.type != MP_STREET || (ti.map5 & 0xF0) != 0) { |
464 cost += DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
464 cost += DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
465 } else { |
465 } else { |
466 // Don't put the pieces that already exist |
466 // Don't put the pieces that already exist |
467 pieces &= ~ti.map5; |
467 pieces &= ~ti.map5; |
468 } |
468 } |
552 if (tile == start_tile && HASBIT(p2, 0)) bits &= ROAD_SE | ROAD_SW; |
552 if (tile == start_tile && HASBIT(p2, 0)) bits &= ROAD_SE | ROAD_SW; |
553 |
553 |
554 ret = DoCommandByTile(tile, bits, 0, flags, CMD_BUILD_ROAD); |
554 ret = DoCommandByTile(tile, bits, 0, flags, CMD_BUILD_ROAD); |
555 if (CmdFailed(ret)) { |
555 if (CmdFailed(ret)) { |
556 if (_error_message != STR_1007_ALREADY_BUILT) return CMD_ERROR; |
556 if (_error_message != STR_1007_ALREADY_BUILT) return CMD_ERROR; |
557 } else |
557 } else { |
558 cost += ret; |
558 cost += ret; |
|
559 } |
559 |
560 |
560 if (tile == end_tile) break; |
561 if (tile == end_tile) break; |
561 |
562 |
562 tile += HASBIT(p2, 2) ? TileDiffXY(0, 1) : TileDiffXY(1, 0); |
563 tile += HASBIT(p2, 2) ? TileDiffXY(0, 1) : TileDiffXY(1, 0); |
563 } |
564 } |
640 |
641 |
641 FindLandscapeHeight(&ti, x, y); |
642 FindLandscapeHeight(&ti, x, y); |
642 |
643 |
643 tile = ti.tile; |
644 tile = ti.tile; |
644 |
645 |
645 if (!EnsureNoVehicle(tile)) |
646 if (!EnsureNoVehicle(tile)) return CMD_ERROR; |
646 return CMD_ERROR; |
647 |
647 |
648 if (ti.tileh != 0 && ( |
648 if ((ti.tileh != 0) && ( |
649 !_patches.build_on_slopes || |
649 !_patches.build_on_slopes || |
650 IsSteepTileh(ti.tileh) || |
650 IsSteepTileh(ti.tileh) || |
651 !CanBuildDepotByTileh(p1, ti.tileh) |
651 !CanBuildDepotByTileh(p1, ti.tileh) |
652 )) { |
652 ) |
653 return_cmd_error(STR_0007_FLAT_LAND_REQUIRED); |
653 ) { |
|
654 return_cmd_error(STR_0007_FLAT_LAND_REQUIRED); |
|
655 } |
654 } |
656 |
655 |
657 cost = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
656 cost = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
658 if (CmdFailed(cost)) return CMD_ERROR; |
657 if (CmdFailed(cost)) return CMD_ERROR; |
659 |
658 |
660 dep = AllocateDepot(); |
659 dep = AllocateDepot(); |
661 if (dep == NULL) |
660 if (dep == NULL) return CMD_ERROR; |
662 return CMD_ERROR; |
|
663 |
661 |
664 if (flags & DC_EXEC) { |
662 if (flags & DC_EXEC) { |
665 if (IsLocalPlayer()) _last_built_road_depot_tile = tile; |
663 if (IsLocalPlayer()) _last_built_road_depot_tile = tile; |
666 |
664 |
667 dep->xy = tile; |
665 dep->xy = tile; |