equal
deleted
inserted
replaced
121 if (HasBit(valid, tileh)) return CommandCost(); |
121 if (HasBit(valid, tileh)) return CommandCost(); |
122 |
122 |
123 valid = |
123 valid = |
124 BRIDGE_FULL_LEVELED_FOUNDATION | M(SLOPE_N) | M(SLOPE_STEEP_N) | |
124 BRIDGE_FULL_LEVELED_FOUNDATION | M(SLOPE_N) | M(SLOPE_STEEP_N) | |
125 (axis == AXIS_X ? M(SLOPE_E) | M(SLOPE_STEEP_E) : M(SLOPE_W) | M(SLOPE_STEEP_W)); |
125 (axis == AXIS_X ? M(SLOPE_E) | M(SLOPE_STEEP_E) : M(SLOPE_W) | M(SLOPE_STEEP_W)); |
126 if (HasBit(valid, tileh)) return CommandCost(_price.terraform); |
126 if (HasBit(valid, tileh)) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); |
127 |
127 |
128 return CMD_ERROR; |
128 return CMD_ERROR; |
129 } |
129 } |
130 |
130 |
131 static CommandCost CheckBridgeSlopeSouth(Axis axis, Slope tileh) |
131 static CommandCost CheckBridgeSlopeSouth(Axis axis, Slope tileh) |
136 if (HasBit(valid, tileh)) return CommandCost(); |
136 if (HasBit(valid, tileh)) return CommandCost(); |
137 |
137 |
138 valid = |
138 valid = |
139 BRIDGE_FULL_LEVELED_FOUNDATION | M(SLOPE_S) | M(SLOPE_STEEP_S) | |
139 BRIDGE_FULL_LEVELED_FOUNDATION | M(SLOPE_S) | M(SLOPE_STEEP_S) | |
140 (axis == AXIS_X ? M(SLOPE_W) | M(SLOPE_STEEP_W) : M(SLOPE_E) | M(SLOPE_STEEP_E)); |
140 (axis == AXIS_X ? M(SLOPE_W) | M(SLOPE_STEEP_W) : M(SLOPE_E) | M(SLOPE_STEEP_E)); |
141 if (HasBit(valid, tileh)) return CommandCost(_price.terraform); |
141 if (HasBit(valid, tileh)) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); |
142 |
142 |
143 return CMD_ERROR; |
143 return CMD_ERROR; |
144 } |
144 } |
145 #undef M |
145 #undef M |
146 |
146 |
195 uint z_end; |
195 uint z_end; |
196 TileIndex tile; |
196 TileIndex tile; |
197 TileIndexDiff delta; |
197 TileIndexDiff delta; |
198 uint bridge_len; |
198 uint bridge_len; |
199 Axis direction; |
199 Axis direction; |
200 CommandCost cost, terraformcost, ret; |
200 CommandCost cost(EXPENSES_CONSTRUCTION); |
|
201 CommandCost terraformcost, ret; |
201 bool allow_on_slopes; |
202 bool allow_on_slopes; |
202 bool replace_bridge = false; |
203 bool replace_bridge = false; |
203 uint replaced_bridge_type; |
204 uint replaced_bridge_type; |
204 |
|
205 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
|
206 |
205 |
207 /* unpack parameters */ |
206 /* unpack parameters */ |
208 bridge_type = GB(p2, 0, 8); |
207 bridge_type = GB(p2, 0, 8); |
209 |
208 |
210 if (p1 >= MapSize()) return CMD_ERROR; |
209 if (p1 >= MapSize()) return CMD_ERROR; |
456 DiagDirection direction; |
455 DiagDirection direction; |
457 Slope start_tileh; |
456 Slope start_tileh; |
458 Slope end_tileh; |
457 Slope end_tileh; |
459 uint start_z; |
458 uint start_z; |
460 uint end_z; |
459 uint end_z; |
461 CommandCost cost; |
460 CommandCost cost(EXPENSES_CONSTRUCTION); |
462 CommandCost ret; |
461 CommandCost ret; |
463 |
462 |
464 _build_tunnel_endtile = 0; |
463 _build_tunnel_endtile = 0; |
465 if (!HasBit(p1, 9)) { |
464 if (!HasBit(p1, 9)) { |
466 if (!ValParamRailtype(p1)) return CMD_ERROR; |
465 if (!ValParamRailtype(p1)) return CMD_ERROR; |
576 static CommandCost DoClearTunnel(TileIndex tile, uint32 flags) |
575 static CommandCost DoClearTunnel(TileIndex tile, uint32 flags) |
577 { |
576 { |
578 Town *t = NULL; |
577 Town *t = NULL; |
579 TileIndex endtile; |
578 TileIndex endtile; |
580 |
579 |
581 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
|
582 |
|
583 if (!CheckAllowRemoveTunnelBridge(tile)) return CMD_ERROR; |
580 if (!CheckAllowRemoveTunnelBridge(tile)) return CMD_ERROR; |
584 |
581 |
585 endtile = GetOtherTunnelEnd(tile); |
582 endtile = GetOtherTunnelEnd(tile); |
586 |
583 |
587 if (GetVehicleTunnelBridge(tile, endtile) != NULL) return CMD_ERROR; |
584 if (GetVehicleTunnelBridge(tile, endtile) != NULL) return CMD_ERROR; |
615 UpdateSignalsOnSegment(endtile, dir); |
612 UpdateSignalsOnSegment(endtile, dir); |
616 track = AxisToTrack(DiagDirToAxis(dir)); |
613 track = AxisToTrack(DiagDirToAxis(dir)); |
617 YapfNotifyTrackLayoutChange(tile, track); |
614 YapfNotifyTrackLayoutChange(tile, track); |
618 YapfNotifyTrackLayoutChange(endtile, track); |
615 YapfNotifyTrackLayoutChange(endtile, track); |
619 } |
616 } |
620 return CommandCost(_price.clear_tunnel * (DistanceManhattan(tile, endtile) + 1)); |
617 return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_tunnel * (DistanceManhattan(tile, endtile) + 1)); |
621 } |
618 } |
622 |
619 |
623 |
620 |
624 static CommandCost DoClearBridge(TileIndex tile, uint32 flags) |
621 static CommandCost DoClearBridge(TileIndex tile, uint32 flags) |
625 { |
622 { |
626 DiagDirection direction; |
623 DiagDirection direction; |
627 TileIndexDiff delta; |
624 TileIndexDiff delta; |
628 TileIndex endtile; |
625 TileIndex endtile; |
629 Town *t = NULL; |
626 Town *t = NULL; |
630 |
|
631 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
|
632 |
627 |
633 if (!CheckAllowRemoveTunnelBridge(tile)) return CMD_ERROR; |
628 if (!CheckAllowRemoveTunnelBridge(tile)) return CMD_ERROR; |
634 |
629 |
635 endtile = GetOtherBridgeEnd(tile); |
630 endtile = GetOtherBridgeEnd(tile); |
636 |
631 |
671 track = AxisToTrack(DiagDirToAxis(direction)); |
666 track = AxisToTrack(DiagDirToAxis(direction)); |
672 YapfNotifyTrackLayoutChange(tile, track); |
667 YapfNotifyTrackLayoutChange(tile, track); |
673 YapfNotifyTrackLayoutChange(endtile, track); |
668 YapfNotifyTrackLayoutChange(endtile, track); |
674 } |
669 } |
675 |
670 |
676 return CommandCost((DistanceManhattan(tile, endtile) + 1) * _price.clear_bridge); |
671 return CommandCost(EXPENSES_CONSTRUCTION, (DistanceManhattan(tile, endtile) + 1) * _price.clear_bridge); |
677 } |
672 } |
678 |
673 |
679 static CommandCost ClearTile_TunnelBridge(TileIndex tile, byte flags) |
674 static CommandCost ClearTile_TunnelBridge(TileIndex tile, byte flags) |
680 { |
675 { |
681 if (IsTunnel(tile)) { |
676 if (IsTunnel(tile)) { |
1396 |
1391 |
1397 z_old += ApplyFoundationToSlope(GetBridgeFoundation(tileh_old, axis), &tileh_old); |
1392 z_old += ApplyFoundationToSlope(GetBridgeFoundation(tileh_old, axis), &tileh_old); |
1398 z_new += ApplyFoundationToSlope(GetBridgeFoundation(tileh_new, axis), &tileh_new); |
1393 z_new += ApplyFoundationToSlope(GetBridgeFoundation(tileh_new, axis), &tileh_new); |
1399 |
1394 |
1400 /* Surface slope remains unchanged? */ |
1395 /* Surface slope remains unchanged? */ |
1401 if ((z_old == z_new) && (tileh_old == tileh_new)) return _price.terraform; |
1396 if ((z_old == z_new) && (tileh_old == tileh_new)) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); |
1402 } |
1397 } |
1403 } |
1398 } |
1404 |
1399 |
1405 return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
1400 return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
1406 } |
1401 } |