equal
deleted
inserted
replaced
122 RoadType rt = (RoadType)GB(p1, 4, 2); |
122 RoadType rt = (RoadType)GB(p1, 4, 2); |
123 if (!IsValidRoadType(rt)) return CMD_ERROR; |
123 if (!IsValidRoadType(rt)) return CMD_ERROR; |
124 |
124 |
125 Town *t = NULL; |
125 Town *t = NULL; |
126 switch (GetTileType(tile)) { |
126 switch (GetTileType(tile)) { |
127 case MP_STREET: |
127 case MP_ROAD: |
128 if (_game_mode != GM_EDITOR && GetRoadOwner(tile, rt) == OWNER_TOWN) t = GetTownByTile(tile); |
128 if (_game_mode != GM_EDITOR && GetRoadOwner(tile, rt) == OWNER_TOWN) t = GetTownByTile(tile); |
129 break; |
129 break; |
130 |
130 |
131 case MP_STATION: |
131 case MP_STATION: |
132 if (!IsDriveThroughStopTile(tile)) return CMD_ERROR; |
132 if (!IsDriveThroughStopTile(tile)) return CMD_ERROR; |
152 |
152 |
153 /* check if you're allowed to remove the street owned by a town |
153 /* check if you're allowed to remove the street owned by a town |
154 * removal allowance depends on difficulty setting */ |
154 * removal allowance depends on difficulty setting */ |
155 if (!CheckforTownRating(flags, t, ROAD_REMOVE)) return CMD_ERROR; |
155 if (!CheckforTownRating(flags, t, ROAD_REMOVE)) return CMD_ERROR; |
156 |
156 |
157 if (!IsTileType(tile, MP_STREET)) { |
157 if (!IsTileType(tile, MP_ROAD)) { |
158 /* If it's the last roadtype, just clear the whole tile */ |
158 /* If it's the last roadtype, just clear the whole tile */ |
159 if (rts == RoadTypeToRoadTypes(rt)) return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
159 if (rts == RoadTypeToRoadTypes(rt)) return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
160 |
160 |
161 CommandCost cost; |
161 CommandCost cost; |
162 if (IsTileType(tile, MP_TUNNELBRIDGE)) { |
162 if (IsTileType(tile, MP_TUNNELBRIDGE)) { |
362 DisallowedRoadDirections toggle_drd = (DisallowedRoadDirections)GB(p1, 6, 2); |
362 DisallowedRoadDirections toggle_drd = (DisallowedRoadDirections)GB(p1, 6, 2); |
363 |
363 |
364 tileh = GetTileSlope(tile, NULL); |
364 tileh = GetTileSlope(tile, NULL); |
365 |
365 |
366 switch (GetTileType(tile)) { |
366 switch (GetTileType(tile)) { |
367 case MP_STREET: |
367 case MP_ROAD: |
368 switch (GetRoadTileType(tile)) { |
368 switch (GetRoadTileType(tile)) { |
369 case ROAD_TILE_NORMAL: { |
369 case ROAD_TILE_NORMAL: { |
370 if (HasRoadWorks(tile)) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS); |
370 if (HasRoadWorks(tile)) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS); |
371 if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; |
371 if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; |
372 |
372 |
479 return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
479 return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
480 } |
480 } |
481 cost.AddCost(ret); |
481 cost.AddCost(ret); |
482 } |
482 } |
483 |
483 |
484 if (IsTileType(tile, MP_STREET)) { |
484 if (IsTileType(tile, MP_ROAD)) { |
485 /* Don't put the pieces that already exist */ |
485 /* Don't put the pieces that already exist */ |
486 pieces &= ComplementRoadBits(existing); |
486 pieces &= ComplementRoadBits(existing); |
487 } |
487 } |
488 |
488 |
489 cost.AddCost(CountRoadBits(pieces) * _price.build_road); |
489 cost.AddCost(CountRoadBits(pieces) * _price.build_road); |
492 cost.MultiplyCost(DistanceManhattan(IsTunnel(tile) ? GetOtherTunnelEnd(tile) : GetOtherBridgeEnd(tile), tile)); |
492 cost.MultiplyCost(DistanceManhattan(IsTunnel(tile) ? GetOtherTunnelEnd(tile) : GetOtherBridgeEnd(tile), tile)); |
493 } |
493 } |
494 |
494 |
495 if (flags & DC_EXEC) { |
495 if (flags & DC_EXEC) { |
496 switch (GetTileType(tile)) { |
496 switch (GetTileType(tile)) { |
497 case MP_STREET: { |
497 case MP_ROAD: { |
498 RoadTileType rtt = GetRoadTileType(tile); |
498 RoadTileType rtt = GetRoadTileType(tile); |
499 if (existing == ROAD_NONE || rtt == ROAD_TILE_CROSSING) { |
499 if (existing == ROAD_NONE || rtt == ROAD_TILE_CROSSING) { |
500 SetRoadTypes(tile, GetRoadTypes(tile) | RoadTypeToRoadTypes(rt)); |
500 SetRoadTypes(tile, GetRoadTypes(tile) | RoadTypeToRoadTypes(rt)); |
501 SetRoadOwner(tile, rt, _current_player); |
501 SetRoadOwner(tile, rt, _current_player); |
502 if (_current_player == OWNER_TOWN && rt == ROADTYPE_ROAD) SetTownIndex(tile, p2); |
502 if (_current_player == OWNER_TOWN && rt == ROADTYPE_ROAD) SetTownIndex(tile, p2); |
527 default: |
527 default: |
528 MakeRoadNormal(tile, pieces, RoadTypeToRoadTypes(rt), p2, _current_player, _current_player, _current_player); |
528 MakeRoadNormal(tile, pieces, RoadTypeToRoadTypes(rt), p2, _current_player, _current_player, _current_player); |
529 break; |
529 break; |
530 } |
530 } |
531 |
531 |
532 if (rt != ROADTYPE_TRAM && IsTileType(tile, MP_STREET) && GetRoadTileType(tile) == ROAD_TILE_NORMAL) { |
532 if (rt != ROADTYPE_TRAM && IsTileType(tile, MP_ROAD) && GetRoadTileType(tile) == ROAD_TILE_NORMAL) { |
533 existing |= pieces; |
533 existing |= pieces; |
534 SetDisallowedRoadDirections(tile, (existing == ROAD_X || existing == ROAD_Y) ? |
534 SetDisallowedRoadDirections(tile, (existing == ROAD_X || existing == ROAD_Y) ? |
535 GetDisallowedRoadDirections(tile) ^ toggle_drd : DRD_NONE); |
535 GetDisallowedRoadDirections(tile) ^ toggle_drd : DRD_NONE); |
536 } |
536 } |
537 |
537 |