|
|
@ -14,8 +14,6 @@
|
|
|
|
template <TransportType Ttr_type_, bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
|
|
|
|
template <TransportType Ttr_type_, bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
|
|
|
|
struct CFollowTrackT
|
|
|
|
struct CFollowTrackT
|
|
|
|
{
|
|
|
|
{
|
|
|
|
typedef CFollowTrackT<Ttr_type_, T90deg_turns_allowed_, false> BaseNoMask;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum ErrorCode {
|
|
|
|
enum ErrorCode {
|
|
|
|
EC_NONE,
|
|
|
|
EC_NONE,
|
|
|
|
EC_OWNER,
|
|
|
|
EC_OWNER,
|
|
|
@ -79,7 +77,7 @@ struct CFollowTrackT
|
|
|
|
FORCEINLINE bool IsTram() {return IsRoadTT() && HasBit(m_veh->u.road.compatible_roadtypes, ROADTYPE_TRAM);}
|
|
|
|
FORCEINLINE bool IsTram() {return IsRoadTT() && HasBit(m_veh->u.road.compatible_roadtypes, ROADTYPE_TRAM);}
|
|
|
|
FORCEINLINE static bool IsRoadTT() {return TT() == TRANSPORT_ROAD;}
|
|
|
|
FORCEINLINE static bool IsRoadTT() {return TT() == TRANSPORT_ROAD;}
|
|
|
|
FORCEINLINE static bool Allow90degTurns() {return T90deg_turns_allowed_;}
|
|
|
|
FORCEINLINE static bool Allow90degTurns() {return T90deg_turns_allowed_;}
|
|
|
|
FORCEINLINE static bool MaskReservedTracks() {return IsRailTT() && Tmask_reserved_tracks;}
|
|
|
|
FORCEINLINE static bool DoTrackMasking() {return IsRailTT() && Tmask_reserved_tracks;}
|
|
|
|
|
|
|
|
|
|
|
|
/** Tests if a tile is a road tile with a single tramtrack (tram can reverse) */
|
|
|
|
/** Tests if a tile is a road tile with a single tramtrack (tram can reverse) */
|
|
|
|
FORCEINLINE DiagDirection GetSingleTramBit(TileIndex tile)
|
|
|
|
FORCEINLINE DiagDirection GetSingleTramBit(TileIndex tile)
|
|
|
@ -124,32 +122,37 @@ struct CFollowTrackT
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (MaskReservedTracks()) {
|
|
|
|
return true;
|
|
|
|
if (m_is_station) {
|
|
|
|
}
|
|
|
|
/* Check skipped station tiles as well. */
|
|
|
|
|
|
|
|
TileIndexDiff diff = TileOffsByDiagDir(m_exitdir);
|
|
|
|
inline bool MaskReservedTracks()
|
|
|
|
for (TileIndex tile = m_new_tile - diff * m_tiles_skipped; tile != m_new_tile; tile += diff) {
|
|
|
|
{
|
|
|
|
if (GetRailwayStationReservation(tile)) {
|
|
|
|
if (!DoTrackMasking()) return true;
|
|
|
|
m_new_td_bits = TRACKDIR_BIT_NONE;
|
|
|
|
|
|
|
|
m_err = EC_RESERVED;
|
|
|
|
if (m_is_station) {
|
|
|
|
return false;
|
|
|
|
/* Check skipped station tiles as well. */
|
|
|
|
}
|
|
|
|
TileIndexDiff diff = TileOffsByDiagDir(m_exitdir);
|
|
|
|
|
|
|
|
for (TileIndex tile = m_new_tile - diff * m_tiles_skipped; tile != m_new_tile; tile += diff) {
|
|
|
|
|
|
|
|
if (GetRailwayStationReservation(tile)) {
|
|
|
|
|
|
|
|
m_new_td_bits = TRACKDIR_BIT_NONE;
|
|
|
|
|
|
|
|
m_err = EC_RESERVED;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TrackBits reserved = GetReservedTrackbits(m_new_tile);
|
|
|
|
TrackBits reserved = GetReservedTrackbits(m_new_tile);
|
|
|
|
/* Mask already reserved trackdirs. */
|
|
|
|
/* Mask already reserved trackdirs. */
|
|
|
|
m_new_td_bits &= ~TrackBitsToTrackdirBits(reserved);
|
|
|
|
m_new_td_bits &= ~TrackBitsToTrackdirBits(reserved);
|
|
|
|
/* Mask out all trackdirs that conflict with the reservation. */
|
|
|
|
/* Mask out all trackdirs that conflict with the reservation. */
|
|
|
|
uint bits = (uint)TrackdirBitsToTrackBits(m_new_td_bits);
|
|
|
|
uint bits = (uint)TrackdirBitsToTrackBits(m_new_td_bits);
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
|
FOR_EACH_SET_BIT(i, bits) {
|
|
|
|
FOR_EACH_SET_BIT(i, bits) {
|
|
|
|
if (TracksOverlap(reserved | TrackToTrackBits((Track)i))) m_new_td_bits &= ~TrackToTrackdirBits((Track)i);
|
|
|
|
if (TracksOverlap(reserved | TrackToTrackBits((Track)i))) m_new_td_bits &= ~TrackToTrackdirBits((Track)i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (m_new_td_bits == TRACKDIR_BIT_NONE) {
|
|
|
|
if (m_new_td_bits == TRACKDIR_BIT_NONE) {
|
|
|
|
m_err = EC_RESERVED;
|
|
|
|
m_err = EC_RESERVED;
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|