--- a/src/yapf/follow_track.hpp Sun Feb 03 20:34:26 2008 +0000
+++ b/src/yapf/follow_track.hpp Mon Mar 10 15:26:39 2008 +0000
@@ -7,12 +7,32 @@
#include "yapf.hpp"
+
/** Track follower helper template class (can serve pathfinders and vehicle
* controllers). See 6 different typedefs below for 3 different transport
* types w/ of w/o 90-deg turns allowed */
template <TransportType Ttr_type_, bool T90deg_turns_allowed_ = true>
-struct CFollowTrackT : public FollowTrack_t
+struct CFollowTrackT
{
+ enum ErrorCode {
+ EC_NONE,
+ EC_OWNER,
+ EC_RAIL_TYPE,
+ EC_90DEG,
+ EC_NO_WAY,
+ };
+
+ const Vehicle* m_veh; ///< moving vehicle
+ TileIndex m_old_tile; ///< the origin (vehicle moved from) before move
+ Trackdir m_old_td; ///< the trackdir (the vehicle was on) before move
+ TileIndex m_new_tile; ///< the new tile (the vehicle has entered)
+ TrackdirBits m_new_td_bits; ///< the new set of available trackdirs
+ DiagDirection m_exitdir; ///< exit direction (leaving the old tile)
+ bool m_is_tunnel; ///< last turn passed tunnel
+ bool m_is_bridge; ///< last turn passed bridge ramp
+ bool m_is_station; ///< last turn passed station
+ int m_tiles_skipped; ///< number of skipped tunnel or station tiles
+ ErrorCode m_err;
CPerformanceTimer* m_pPerf;
FORCEINLINE CFollowTrackT(const Vehicle* v = NULL, CPerformanceTimer* pPerf = NULL)
@@ -44,7 +64,7 @@
/** Tests if a tile is a road tile with a single tramtrack (tram can reverse) */
FORCEINLINE DiagDirection GetSingleTramBit(TileIndex tile)
{
- if (IsTram() && IsTileType(tile, MP_ROAD) && GetRoadTileType(tile) == ROAD_TILE_NORMAL) {
+ if (IsTram() && IsNormalRoadTile(tile)) {
RoadBits rb = GetRoadBits(tile, ROADTYPE_TRAM);
switch (rb) {
case ROAD_NW: return DIAGDIR_NW;
@@ -64,7 +84,7 @@
m_old_tile = old_tile;
m_old_td = old_td;
m_err = EC_NONE;
- assert(((GetTileTrackStatus(m_old_tile, TT(), m_veh->u.road.compatible_roadtypes) & TrackdirToTrackdirBits(m_old_td)) != 0) ||
+ assert(((TrackStatusToTrackdirBits(GetTileTrackStatus(m_old_tile, TT(), m_veh->u.road.compatible_roadtypes)) & TrackdirToTrackdirBits(m_old_td)) != 0) ||
(GetSingleTramBit(m_old_tile) != INVALID_DIAGDIR)); // Disable the assertion for single tram bits
m_exitdir = TrackdirToExitdir(m_old_td);
if (ForcedReverse()) return true;
@@ -133,8 +153,7 @@
if (IsRailTT() && GetTileType(m_new_tile) == MP_RAILWAY && IsPlainRailTile(m_new_tile)) {
m_new_td_bits = (TrackdirBits)(GetTrackBits(m_new_tile) * 0x101);
} else {
- uint32 ts = GetTileTrackStatus(m_new_tile, TT(), m_veh->u.road.compatible_roadtypes);
- m_new_td_bits = (TrackdirBits)(ts & TRACKDIR_BIT_MASK);
+ m_new_td_bits = TrackStatusToTrackdirBits(GetTileTrackStatus(m_new_tile, TT(), m_veh->u.road.compatible_roadtypes));
if (m_new_td_bits == 0) {
/* GetTileTrackStatus() returns 0 for single tram bits.
@@ -342,7 +361,7 @@
// for now we handle only on-bridge speed limit
if (!IsWaterTT() && IsBridgeTile(m_old_tile)) {
- int spd = _bridge[GetBridgeType(m_old_tile)].speed;
+ int spd = GetBridgeSpec(GetBridgeType(m_old_tile))->speed;
if (IsRoadTT()) spd *= 2;
if (max_speed > spd) max_speed = spd;
}