equal
deleted
inserted
replaced
30 #include "date_func.h" |
30 #include "date_func.h" |
31 #include "functions.h" |
31 #include "functions.h" |
32 #include "vehicle_func.h" |
32 #include "vehicle_func.h" |
33 #include "sound_func.h" |
33 #include "sound_func.h" |
34 #include "signal_func.h" |
34 #include "signal_func.h" |
|
35 #include "tunnelbridge.h" |
35 |
36 |
36 #include "table/sprites.h" |
37 #include "table/sprites.h" |
37 #include "table/strings.h" |
38 #include "table/strings.h" |
38 #include "table/bridge_land.h" |
39 #include "table/bridge_land.h" |
39 |
40 |
158 if (f == FOUNDATION_NONE) return CommandCost(); |
159 if (f == FOUNDATION_NONE) return CommandCost(); |
159 |
160 |
160 return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); |
161 return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); |
161 } |
162 } |
162 |
163 |
163 |
|
164 uint32 GetBridgeLength(TileIndex begin, TileIndex end) |
|
165 { |
|
166 int x1 = TileX(begin); |
|
167 int y1 = TileY(begin); |
|
168 int x2 = TileX(end); |
|
169 int y2 = TileY(end); |
|
170 |
|
171 return abs(x2 + y2 - x1 - y1) - 1; |
|
172 } |
|
173 |
|
174 bool CheckBridge_Stuff(byte bridge_type, uint bridge_len) |
164 bool CheckBridge_Stuff(byte bridge_type, uint bridge_len) |
175 { |
165 { |
176 const Bridge *b = &_bridge[bridge_type]; |
166 const Bridge *b = &_bridge[bridge_type]; |
177 uint max; // max possible length of a bridge (with patch 100) |
167 uint max; // max possible length of a bridge (with patch 100) |
178 |
168 |
631 } else { |
621 } else { |
632 DoClearSquare(tile); |
622 DoClearSquare(tile); |
633 DoClearSquare(endtile); |
623 DoClearSquare(endtile); |
634 } |
624 } |
635 } |
625 } |
636 return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_tunnel * (DistanceManhattan(tile, endtile) + 1)); |
626 return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_tunnel * (GetTunnelBridgeLength(tile, endtile) + 2)); |
637 } |
627 } |
638 |
628 |
639 |
629 |
640 static CommandCost DoClearBridge(TileIndex tile, uint32 flags) |
630 static CommandCost DoClearBridge(TileIndex tile, uint32 flags) |
641 { |
631 { |
691 YapfNotifyTrackLayoutChange(tile, track); |
681 YapfNotifyTrackLayoutChange(tile, track); |
692 YapfNotifyTrackLayoutChange(endtile, track); |
682 YapfNotifyTrackLayoutChange(endtile, track); |
693 } |
683 } |
694 } |
684 } |
695 |
685 |
696 return CommandCost(EXPENSES_CONSTRUCTION, (DistanceManhattan(tile, endtile) + 1) * _price.clear_bridge); |
686 return CommandCost(EXPENSES_CONSTRUCTION, (GetTunnelBridgeLength(tile, endtile) + 2) * _price.clear_bridge); |
697 } |
687 } |
698 |
688 |
699 static CommandCost ClearTile_TunnelBridge(TileIndex tile, byte flags) |
689 static CommandCost ClearTile_TunnelBridge(TileIndex tile, byte flags) |
700 { |
690 { |
701 if (IsTunnel(tile)) { |
691 if (IsTunnel(tile)) { |
1016 rampnorth = GetNorthernBridgeEnd(ti->tile); |
1006 rampnorth = GetNorthernBridgeEnd(ti->tile); |
1017 rampsouth = GetSouthernBridgeEnd(ti->tile); |
1007 rampsouth = GetSouthernBridgeEnd(ti->tile); |
1018 |
1008 |
1019 axis = GetBridgeAxis(ti->tile); |
1009 axis = GetBridgeAxis(ti->tile); |
1020 piece = CalcBridgePiece( |
1010 piece = CalcBridgePiece( |
1021 DistanceManhattan(ti->tile, rampnorth), |
1011 GetTunnelBridgeLength(ti->tile, rampnorth) + 1, |
1022 DistanceManhattan(ti->tile, rampsouth) |
1012 GetTunnelBridgeLength(ti->tile, rampsouth) + 1 |
1023 ); |
1013 ); |
1024 type = GetBridgeType(rampsouth); |
1014 type = GetBridgeType(rampsouth); |
1025 |
1015 |
1026 if (GetTunnelBridgeTransportType(rampsouth) == TRANSPORT_RAIL) { |
1016 if (GetTunnelBridgeTransportType(rampsouth) == TRANSPORT_RAIL) { |
1027 base_offset = GetRailTypeInfo(GetRailType(rampsouth))->bridge_offset; |
1017 base_offset = GetRailTypeInfo(GetRailType(rampsouth))->bridge_offset; |