summaryrefslogtreecommitdiff
path: root/src/tunnelbridge_cmd.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-01-23 22:34:04 +0000
committersmatz <smatz@openttd.org>2008-01-23 22:34:04 +0000
commit5a7c9037709772e4678ee57d9b42f5332bd66f97 (patch)
treeae76a3390a465cf3bfc011e2b32d53d5ae55c298 /src/tunnelbridge_cmd.cpp
parentb5641ae0f2ca3723af7fe7f68c4ac45e113e8421 (diff)
downloadopenttd-5a7c9037709772e4678ee57d9b42f5332bd66f97.tar.xz
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
Diffstat (limited to 'src/tunnelbridge_cmd.cpp')
-rw-r--r--src/tunnelbridge_cmd.cpp20
1 files changed, 5 insertions, 15 deletions
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index a8eee3054..aebc76581 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -32,6 +32,7 @@
#include "vehicle_func.h"
#include "sound_func.h"
#include "signal_func.h"
+#include "tunnelbridge.h"
#include "table/sprites.h"
#include "table/strings.h"
@@ -160,17 +161,6 @@ static CommandCost CheckBridgeSlopeSouth(Axis axis, Slope *tileh, uint *z)
return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
}
-
-uint32 GetBridgeLength(TileIndex begin, TileIndex end)
-{
- int x1 = TileX(begin);
- int y1 = TileY(begin);
- int x2 = TileX(end);
- int y2 = TileY(end);
-
- return abs(x2 + y2 - x1 - y1) - 1;
-}
-
bool CheckBridge_Stuff(byte bridge_type, uint bridge_len)
{
const Bridge *b = &_bridge[bridge_type];
@@ -633,7 +623,7 @@ static CommandCost DoClearTunnel(TileIndex tile, uint32 flags)
DoClearSquare(endtile);
}
}
- return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_tunnel * (DistanceManhattan(tile, endtile) + 1));
+ return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_tunnel * (GetTunnelBridgeLength(tile, endtile) + 2));
}
@@ -693,7 +683,7 @@ static CommandCost DoClearBridge(TileIndex tile, uint32 flags)
}
}
- return CommandCost(EXPENSES_CONSTRUCTION, (DistanceManhattan(tile, endtile) + 1) * _price.clear_bridge);
+ return CommandCost(EXPENSES_CONSTRUCTION, (GetTunnelBridgeLength(tile, endtile) + 2) * _price.clear_bridge);
}
static CommandCost ClearTile_TunnelBridge(TileIndex tile, byte flags)
@@ -1018,8 +1008,8 @@ void DrawBridgeMiddle(const TileInfo* ti)
axis = GetBridgeAxis(ti->tile);
piece = CalcBridgePiece(
- DistanceManhattan(ti->tile, rampnorth),
- DistanceManhattan(ti->tile, rampsouth)
+ GetTunnelBridgeLength(ti->tile, rampnorth) + 1,
+ GetTunnelBridgeLength(ti->tile, rampsouth) + 1
);
type = GetBridgeType(rampsouth);