(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead

This commit is contained in:
smatz
2008-01-23 22:34:04 +00:00
parent dbd4d7d6a8
commit 74af65e556
19 changed files with 90 additions and 98 deletions

View File

@@ -76,32 +76,22 @@ protected:
m_is_station = m_is_bridge = m_is_tunnel = false;
m_tiles_skipped = 0;
// extra handling for tunnels in our direction
if (IsTunnelTile(m_old_tile)) {
DiagDirection tunnel_enterdir = GetTunnelBridgeDirection(m_old_tile);
if (tunnel_enterdir == m_exitdir) {
// we are entering the tunnel
FindLengthOfTunnelResult flotr = FindLengthOfTunnel(m_old_tile, m_exitdir);
m_new_tile = flotr.tile;
m_is_tunnel = true;
m_tiles_skipped = flotr.length - 1;
// extra handling for tunnels and bridges in our direction
if (IsTileType(m_old_tile, MP_TUNNELBRIDGE)) {
DiagDirection enterdir = GetTunnelBridgeDirection(m_old_tile);
if (enterdir == m_exitdir) {
// we are entering the tunnel / bridge
if (IsTunnel(m_old_tile)) {
m_is_tunnel = true;
m_new_tile = GetOtherTunnelEnd(m_old_tile);
} else { // IsBridge(m_old_tile)
m_is_bridge = true;
m_new_tile = GetOtherBridgeEnd(m_old_tile);
}
m_tiles_skipped = GetTunnelBridgeLength(m_new_tile, m_old_tile);
return;
}
assert(ReverseDiagDir(tunnel_enterdir) == m_exitdir);
}
// extra handling for bridge ramp in our direction
if (IsBridgeTile(m_old_tile)) {
DiagDirection bridge_enterdir = GetTunnelBridgeDirection(m_old_tile);
if (bridge_enterdir == m_exitdir) {
// we are entering the bridge ramp
m_new_tile = GetOtherBridgeEnd(m_old_tile);
uint32 bridge_length = GetBridgeLength(m_old_tile, m_new_tile);
m_tiles_skipped = bridge_length;
m_is_bridge = true;
return;
}
assert(ReverseDiagDir(bridge_enterdir) == m_exitdir);
assert(ReverseDiagDir(enterdir) == m_exitdir);
}
// normal or station tile, do one step

View File

@@ -23,6 +23,7 @@
#include "../waypoint.h"
#include "../debug.h"
#include "../settings_type.h"
#include "../tunnelbridge.h"
extern uint64 _rdtsc();