116 if (HASBIT(valid, tileh)) return 0; |
116 if (HASBIT(valid, tileh)) return 0; |
117 |
117 |
118 valid = |
118 valid = |
119 BRIDGE_FULL_LEVELED_FOUNDATION | M(SLOPE_N) | M(SLOPE_STEEP_N) | |
119 BRIDGE_FULL_LEVELED_FOUNDATION | M(SLOPE_N) | M(SLOPE_STEEP_N) | |
120 (axis == AXIS_X ? M(SLOPE_E) | M(SLOPE_STEEP_E) : M(SLOPE_W) | M(SLOPE_STEEP_W)); |
120 (axis == AXIS_X ? M(SLOPE_E) | M(SLOPE_STEEP_E) : M(SLOPE_W) | M(SLOPE_STEEP_W)); |
121 if (HASBIT(valid, tileh)) return _price.terraform; |
121 if (HASBIT(valid, tileh)) return _eco->GetPrice(CEconomy::TERRAFORM); |
122 |
122 |
123 return CMD_ERROR; |
123 return CMD_ERROR; |
124 } |
124 } |
125 |
125 |
126 static int32 CheckBridgeSlopeSouth(Axis axis, Slope tileh) |
126 static int32 CheckBridgeSlopeSouth(Axis axis, Slope tileh) |
131 if (HASBIT(valid, tileh)) return 0; |
131 if (HASBIT(valid, tileh)) return 0; |
132 |
132 |
133 valid = |
133 valid = |
134 BRIDGE_FULL_LEVELED_FOUNDATION | M(SLOPE_S) | M(SLOPE_STEEP_S) | |
134 BRIDGE_FULL_LEVELED_FOUNDATION | M(SLOPE_S) | M(SLOPE_STEEP_S) | |
135 (axis == AXIS_X ? M(SLOPE_W) | M(SLOPE_STEEP_W) : M(SLOPE_E) | M(SLOPE_STEEP_E)); |
135 (axis == AXIS_X ? M(SLOPE_W) | M(SLOPE_STEEP_W) : M(SLOPE_E) | M(SLOPE_STEEP_E)); |
136 if (HASBIT(valid, tileh)) return _price.terraform; |
136 if (HASBIT(valid, tileh)) return _eco->GetPrice(CEconomy::TERRAFORM); |
137 |
137 |
138 return CMD_ERROR; |
138 return CMD_ERROR; |
139 } |
139 } |
140 #undef M |
140 #undef M |
141 |
141 |
291 /* Do not allow replacing another player's bridges. */ |
291 /* Do not allow replacing another player's bridges. */ |
292 if (!IsTileOwner(tile_start, _current_player) && !IsTileOwner(tile_start, OWNER_TOWN)) { |
292 if (!IsTileOwner(tile_start, _current_player) && !IsTileOwner(tile_start, OWNER_TOWN)) { |
293 return_cmd_error(STR_1024_AREA_IS_OWNED_BY_ANOTHER); |
293 return_cmd_error(STR_1024_AREA_IS_OWNED_BY_ANOTHER); |
294 } |
294 } |
295 |
295 |
296 cost = (bridge_len + 1) * _price.clear_bridge; // The cost of clearing the current bridge. |
296 cost = (bridge_len + 1) * _eco->GetPrice(CEconomy::CLEAR_BRIDGE); // The cost of clearing the current bridge. |
297 replace_bridge = true; |
297 replace_bridge = true; |
298 replaced_bridge_type = GetBridgeType(tile_start); |
298 replaced_bridge_type = GetBridgeType(tile_start); |
299 } else { |
299 } else { |
300 /* Build a new bridge. */ |
300 /* Build a new bridge. */ |
301 |
301 |
485 |
485 |
486 if (!_cheats.crossing_tunnels.value && IsTunnelInWay(end_tile, start_z)) { |
486 if (!_cheats.crossing_tunnels.value && IsTunnelInWay(end_tile, start_z)) { |
487 return_cmd_error(STR_5003_ANOTHER_TUNNEL_IN_THE_WAY); |
487 return_cmd_error(STR_5003_ANOTHER_TUNNEL_IN_THE_WAY); |
488 } |
488 } |
489 |
489 |
490 cost += _price.build_tunnel; |
490 cost += _eco->GetPrice(CEconomy::BUILD_TUNNEL); |
491 cost += cost >> 3; // add a multiplier for longer tunnels |
491 cost += cost >> 3; // add a multiplier for longer tunnels |
492 if (cost >= 400000000) cost = 400000000; |
492 if (cost >= 400000000) cost = 400000000; |
493 } |
493 } |
494 |
494 |
495 /* Add the cost of the entrance */ |
495 /* Add the cost of the entrance */ |
496 cost += _price.build_tunnel + ret; |
496 cost += _eco->GetPrice(CEconomy::BUILD_TUNNEL) + ret; |
497 |
497 |
498 // if the command fails from here on we want the end tile to be highlighted |
498 // if the command fails from here on we want the end tile to be highlighted |
499 _build_tunnel_endtile = end_tile; |
499 _build_tunnel_endtile = end_tile; |
500 |
500 |
501 // slope of end tile must be complementary to the slope of the start tile |
501 // slope of end tile must be complementary to the slope of the start tile |
504 if (CmdFailed(ret)) return_cmd_error(STR_5005_UNABLE_TO_EXCAVATE_LAND); |
504 if (CmdFailed(ret)) return_cmd_error(STR_5005_UNABLE_TO_EXCAVATE_LAND); |
505 } else { |
505 } else { |
506 ret = DoCommand(end_tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
506 ret = DoCommand(end_tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
507 if (CmdFailed(ret)) return ret; |
507 if (CmdFailed(ret)) return ret; |
508 } |
508 } |
509 cost += _price.build_tunnel + ret; |
509 cost += _eco->GetPrice(CEconomy::BUILD_TUNNEL) + ret; |
510 |
510 |
511 if (flags & DC_EXEC) { |
511 if (flags & DC_EXEC) { |
512 if (GB(p1, 9, 1) == TRANSPORT_RAIL) { |
512 if (GB(p1, 9, 1) == TRANSPORT_RAIL) { |
513 MakeRailTunnel(start_tile, _current_player, direction, (RailType)GB(p1, 0, 4)); |
513 MakeRailTunnel(start_tile, _current_player, direction, (RailType)GB(p1, 0, 4)); |
514 MakeRailTunnel(end_tile, _current_player, ReverseDiagDir(direction), (RailType)GB(p1, 0, 4)); |
514 MakeRailTunnel(end_tile, _current_player, ReverseDiagDir(direction), (RailType)GB(p1, 0, 4)); |
605 UpdateSignalsOnSegment(endtile, dir); |
605 UpdateSignalsOnSegment(endtile, dir); |
606 track = AxisToTrack(DiagDirToAxis(dir)); |
606 track = AxisToTrack(DiagDirToAxis(dir)); |
607 YapfNotifyTrackLayoutChange(tile, track); |
607 YapfNotifyTrackLayoutChange(tile, track); |
608 YapfNotifyTrackLayoutChange(endtile, track); |
608 YapfNotifyTrackLayoutChange(endtile, track); |
609 } |
609 } |
610 return _price.clear_tunnel * (length + 1); |
610 return _eco->GetPrice(CEconomy::CLEAR_TUNNEL) * (length + 1); |
611 } |
611 } |
612 |
612 |
613 |
613 |
614 static bool IsVehicleOnBridge(TileIndex starttile, TileIndex endtile, uint z) |
614 static bool IsVehicleOnBridge(TileIndex starttile, TileIndex endtile, uint z) |
615 { |
615 { |
677 track = AxisToTrack(DiagDirToAxis(direction)); |
677 track = AxisToTrack(DiagDirToAxis(direction)); |
678 YapfNotifyTrackLayoutChange(tile, track); |
678 YapfNotifyTrackLayoutChange(tile, track); |
679 YapfNotifyTrackLayoutChange(endtile, track); |
679 YapfNotifyTrackLayoutChange(endtile, track); |
680 } |
680 } |
681 |
681 |
682 return (DistanceManhattan(tile, endtile) + 1) * _price.clear_bridge; |
682 return (DistanceManhattan(tile, endtile) + 1) * _eco->GetPrice(CEconomy::CLEAR_BRIDGE); |
683 } |
683 } |
684 |
684 |
685 static int32 ClearTile_TunnelBridge(TileIndex tile, byte flags) |
685 static int32 ClearTile_TunnelBridge(TileIndex tile, byte flags) |
686 { |
686 { |
687 if (IsTunnel(tile)) { |
687 if (IsTunnel(tile)) { |
721 |
721 |
722 track = AxisToTrack(DiagDirToAxis(GetTunnelDirection(tile))); |
722 track = AxisToTrack(DiagDirToAxis(GetTunnelDirection(tile))); |
723 YapfNotifyTrackLayoutChange(tile, track); |
723 YapfNotifyTrackLayoutChange(tile, track); |
724 YapfNotifyTrackLayoutChange(endtile, track); |
724 YapfNotifyTrackLayoutChange(endtile, track); |
725 } |
725 } |
726 return (length + 1) * (_price.build_rail >> 1); |
726 return (length + 1) * (_eco->GetPrice(CEconomy::PRICE_RAIL_BUILD) / 2); |
727 } else if (IsBridge(tile) && GetBridgeTransportType(tile) == TRANSPORT_RAIL) { |
727 } else if (IsBridge(tile) && GetBridgeTransportType(tile) == TRANSPORT_RAIL) { |
728 |
728 |
729 if (!CheckTileOwnership(tile)) return CMD_ERROR; |
729 if (!CheckTileOwnership(tile)) return CMD_ERROR; |
730 |
730 |
731 endtile = GetOtherBridgeEnd(tile); |
731 endtile = GetOtherBridgeEnd(tile); |