equal
deleted
inserted
replaced
424 switch (GetTileType(tile)) { |
424 switch (GetTileType(tile)) { |
425 case MP_ROAD: |
425 case MP_ROAD: |
426 switch (GetRoadTileType(tile)) { |
426 switch (GetRoadTileType(tile)) { |
427 case ROAD_TILE_NORMAL: { |
427 case ROAD_TILE_NORMAL: { |
428 if (HasRoadWorks(tile)) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS); |
428 if (HasRoadWorks(tile)) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS); |
429 if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; |
|
430 |
429 |
431 all_bits = GetAllRoadBits(tile); |
430 all_bits = GetAllRoadBits(tile); |
432 if (!HasTileRoadType(tile, rt)) break; |
431 if (!HasTileRoadType(tile, rt)) break; |
433 |
432 |
434 existing = GetRoadBits(tile, rt); |
433 existing = GetRoadBits(tile, rt); |
441 if ((existing & pieces) == pieces) { |
440 if ((existing & pieces) == pieces) { |
442 /* We only want to set the (dis)allowed road directions */ |
441 /* We only want to set the (dis)allowed road directions */ |
443 if (toggle_drd != DRD_NONE && rt != ROADTYPE_TRAM && GetRoadOwner(tile, ROADTYPE_ROAD) == _current_player) { |
442 if (toggle_drd != DRD_NONE && rt != ROADTYPE_TRAM && GetRoadOwner(tile, ROADTYPE_ROAD) == _current_player) { |
444 if (crossing) return_cmd_error(STR_ERR_ONEWAY_ROADS_CAN_T_HAVE_JUNCTION); |
443 if (crossing) return_cmd_error(STR_ERR_ONEWAY_ROADS_CAN_T_HAVE_JUNCTION); |
445 |
444 |
|
445 if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; |
|
446 |
446 /* Ignore half built tiles */ |
447 /* Ignore half built tiles */ |
447 if (flags & DC_EXEC && rt != ROADTYPE_TRAM && (existing == ROAD_X || existing == ROAD_Y)) { |
448 if (flags & DC_EXEC && rt != ROADTYPE_TRAM && (existing == ROAD_X || existing == ROAD_Y)) { |
448 SetDisallowedRoadDirections(tile, GetDisallowedRoadDirections(tile) ^ toggle_drd); |
449 SetDisallowedRoadDirections(tile, GetDisallowedRoadDirections(tile) ^ toggle_drd); |
449 MarkTileDirtyByTile(tile); |
450 MarkTileDirtyByTile(tile); |
450 } |
451 } |
456 |
457 |
457 case ROAD_TILE_CROSSING: |
458 case ROAD_TILE_CROSSING: |
458 if (HasTileRoadType(tile, rt)) return_cmd_error(STR_1007_ALREADY_BUILT); |
459 if (HasTileRoadType(tile, rt)) return_cmd_error(STR_1007_ALREADY_BUILT); |
459 all_bits = GetCrossingRoadBits(tile); |
460 all_bits = GetCrossingRoadBits(tile); |
460 if (pieces & ComplementRoadBits(all_bits)) goto do_clear; |
461 if (pieces & ComplementRoadBits(all_bits)) goto do_clear; |
461 if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; |
|
462 break; |
462 break; |
463 |
463 |
464 default: |
464 default: |
465 case ROAD_TILE_DEPOT: |
465 case ROAD_TILE_DEPOT: |
466 goto do_clear; |
466 goto do_clear; |
507 } |
507 } |
508 |
508 |
509 case MP_STATION: |
509 case MP_STATION: |
510 if (!IsDriveThroughStopTile(tile)) return CMD_ERROR; |
510 if (!IsDriveThroughStopTile(tile)) return CMD_ERROR; |
511 if (HasTileRoadType(tile, rt)) return_cmd_error(STR_1007_ALREADY_BUILT); |
511 if (HasTileRoadType(tile, rt)) return_cmd_error(STR_1007_ALREADY_BUILT); |
512 /* Don't allow adding roadtype to the roadstop when vehicles are already driving on it */ |
|
513 if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; |
|
514 break; |
512 break; |
515 |
513 |
516 case MP_TUNNELBRIDGE: |
514 case MP_TUNNELBRIDGE: |
517 if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR; |
515 if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR; |
518 if (HasTileRoadType(tile, rt)) return_cmd_error(STR_1007_ALREADY_BUILT); |
516 if (HasTileRoadType(tile, rt)) return_cmd_error(STR_1007_ALREADY_BUILT); |
557 } |
555 } |
558 } |
556 } |
559 } |
557 } |
560 } |
558 } |
561 } |
559 } |
|
560 |
|
561 if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; |
562 |
562 |
563 cost.AddCost(CountBits(pieces) * _price.build_road); |
563 cost.AddCost(CountBits(pieces) * _price.build_road); |
564 if (IsTileType(tile, MP_TUNNELBRIDGE)) { |
564 if (IsTileType(tile, MP_TUNNELBRIDGE)) { |
565 /* Pay for *every* tile of the bridge or tunnel */ |
565 /* Pay for *every* tile of the bridge or tunnel */ |
566 cost.MultiplyCost(GetTunnelBridgeLength(GetOtherTunnelBridgeEnd(tile), tile) + 2); |
566 cost.MultiplyCost(GetTunnelBridgeLength(GetOtherTunnelBridgeEnd(tile), tile) + 2); |
632 bool had_bridge = false; |
632 bool had_bridge = false; |
633 bool had_tunnel = false; |
633 bool had_tunnel = false; |
634 bool had_success = false; |
634 bool had_success = false; |
635 DisallowedRoadDirections drd = DRD_NORTHBOUND; |
635 DisallowedRoadDirections drd = DRD_NORTHBOUND; |
636 |
636 |
|
637 _error_message = INVALID_STRING_ID; |
|
638 |
637 if (p1 >= MapSize()) return CMD_ERROR; |
639 if (p1 >= MapSize()) return CMD_ERROR; |
638 |
640 |
639 start_tile = p1; |
641 start_tile = p1; |
640 RoadType rt = (RoadType)GB(p2, 3, 2); |
642 RoadType rt = (RoadType)GB(p2, 3, 2); |
641 if (!IsValidRoadType(rt) || !ValParamRoadType(rt)) return CMD_ERROR; |
643 if (!IsValidRoadType(rt) || !ValParamRoadType(rt)) return CMD_ERROR; |
669 if (tile == start_tile && HasBit(p2, 0)) bits &= ROAD_SE | ROAD_SW; |
671 if (tile == start_tile && HasBit(p2, 0)) bits &= ROAD_SE | ROAD_SW; |
670 |
672 |
671 ret = DoCommand(tile, drd << 6 | rt << 4 | bits, 0, flags, CMD_BUILD_ROAD); |
673 ret = DoCommand(tile, drd << 6 | rt << 4 | bits, 0, flags, CMD_BUILD_ROAD); |
672 if (CmdFailed(ret)) { |
674 if (CmdFailed(ret)) { |
673 if (_error_message != STR_1007_ALREADY_BUILT) return CMD_ERROR; |
675 if (_error_message != STR_1007_ALREADY_BUILT) return CMD_ERROR; |
674 _error_message = INVALID_STRING_ID; |
|
675 } else { |
676 } else { |
676 had_success = true; |
677 had_success = true; |
677 /* Only pay for the upgrade on one side of the bridges and tunnels */ |
678 /* Only pay for the upgrade on one side of the bridges and tunnels */ |
678 if (IsTileType(tile, MP_TUNNELBRIDGE)) { |
679 if (IsTileType(tile, MP_TUNNELBRIDGE)) { |
679 if (IsBridge(tile)) { |
680 if (IsBridge(tile)) { |