74 FORCEINLINE void FollowTileExit() |
74 FORCEINLINE void FollowTileExit() |
75 { |
75 { |
76 m_is_station = m_is_bridge = m_is_tunnel = false; |
76 m_is_station = m_is_bridge = m_is_tunnel = false; |
77 m_tiles_skipped = 0; |
77 m_tiles_skipped = 0; |
78 |
78 |
79 // extra handling for tunnels in our direction |
79 // extra handling for tunnels and bridges in our direction |
80 if (IsTunnelTile(m_old_tile)) { |
80 if (IsTileType(m_old_tile, MP_TUNNELBRIDGE)) { |
81 DiagDirection tunnel_enterdir = GetTunnelBridgeDirection(m_old_tile); |
81 DiagDirection enterdir = GetTunnelBridgeDirection(m_old_tile); |
82 if (tunnel_enterdir == m_exitdir) { |
82 if (enterdir == m_exitdir) { |
83 // we are entering the tunnel |
83 // we are entering the tunnel / bridge |
84 FindLengthOfTunnelResult flotr = FindLengthOfTunnel(m_old_tile, m_exitdir); |
84 if (IsTunnel(m_old_tile)) { |
85 m_new_tile = flotr.tile; |
85 m_is_tunnel = true; |
86 m_is_tunnel = true; |
86 m_new_tile = GetOtherTunnelEnd(m_old_tile); |
87 m_tiles_skipped = flotr.length - 1; |
87 } else { // IsBridge(m_old_tile) |
|
88 m_is_bridge = true; |
|
89 m_new_tile = GetOtherBridgeEnd(m_old_tile); |
|
90 } |
|
91 m_tiles_skipped = GetTunnelBridgeLength(m_new_tile, m_old_tile); |
88 return; |
92 return; |
89 } |
93 } |
90 assert(ReverseDiagDir(tunnel_enterdir) == m_exitdir); |
94 assert(ReverseDiagDir(enterdir) == m_exitdir); |
91 } |
|
92 |
|
93 // extra handling for bridge ramp in our direction |
|
94 if (IsBridgeTile(m_old_tile)) { |
|
95 DiagDirection bridge_enterdir = GetTunnelBridgeDirection(m_old_tile); |
|
96 if (bridge_enterdir == m_exitdir) { |
|
97 // we are entering the bridge ramp |
|
98 m_new_tile = GetOtherBridgeEnd(m_old_tile); |
|
99 uint32 bridge_length = GetBridgeLength(m_old_tile, m_new_tile); |
|
100 m_tiles_skipped = bridge_length; |
|
101 m_is_bridge = true; |
|
102 return; |
|
103 } |
|
104 assert(ReverseDiagDir(bridge_enterdir) == m_exitdir); |
|
105 } |
95 } |
106 |
96 |
107 // normal or station tile, do one step |
97 // normal or station tile, do one step |
108 TileIndexDiff diff = TileOffsByDiagDir(m_exitdir); |
98 TileIndexDiff diff = TileOffsByDiagDir(m_exitdir); |
109 m_new_tile = TILE_ADD(m_old_tile, diff); |
99 m_new_tile = TILE_ADD(m_old_tile, diff); |