tron@2186: /* $Id$ */ tron@2186: rubidium@8597: /** @file track_func.h Different conversion functions from one kind of track to another. */ tron@4041: rubidium@8597: #ifndef TRACK_FUNC_H rubidium@8597: #define TRACK_FUNC_H tron@4041: rubidium@8609: #include "core/bitmath_func.hpp" rubidium@8597: #include "track_type.h" rubidium@8597: #include "direction_type.h" rubidium@8604: #include "slope_func.h" tron@4041: rubidium@7892: /** rubidium@7892: * Convert an Axis to the corresponding Track tron@4158: * AXIS_X -> TRACK_X tron@4158: * AXIS_Y -> TRACK_Y tron@4158: * Uses the fact that they share the same internal encoding rubidium@7892: * rubidium@7892: * @param a the axis to convert rubidium@7892: * @return the track corresponding to the axis tron@4158: */ tron@4158: static inline Track AxisToTrack(Axis a) tron@4158: { tron@4158: return (Track)a; tron@4158: } tron@4158: tron@4158: tron@4041: tron@4158: /** tron@4158: * Maps a Track to the corresponding TrackBits value rubidium@7892: * @param track the track to convert rubidium@7892: * @return the converted TrackBits value of the track tron@4158: */ tron@4158: static inline TrackBits TrackToTrackBits(Track track) tron@4158: { tron@4158: return (TrackBits)(1 << track); tron@4158: } tron@4158: rubidium@7892: /** rubidium@7892: * Maps an Axis to the corresponding TrackBits value rubidium@7892: * @param a the axis to convert rubidium@7892: * @return the converted TrackBits value of the axis rubidium@7892: */ tron@4158: static inline TrackBits AxisToTrackBits(Axis a) tron@4158: { tron@4158: return TrackToTrackBits(AxisToTrack(a)); tron@4158: } tron@4158: rubidium@8199: /** rubidium@8199: * Returns a single horizontal/vertical trackbit, that is in a specific tile corner. rubidium@8199: * rubidium@8199: * @param corner The corner of a tile. rubidium@8199: * @return The TrackBits of the track in the corner. rubidium@8199: */ rubidium@8199: static inline TrackBits CornerToTrackBits(Corner corner) rubidium@8199: { rubidium@8199: extern const TrackBits _corner_to_trackbits[]; rubidium@8199: assert(IsValidCorner(corner)); rubidium@8199: return _corner_to_trackbits[corner]; rubidium@8199: } rubidium@8199: tron@4158: matthijs@1942: matthijs@1948: /** matthijs@1948: * Maps a Trackdir to the corresponding TrackdirBits value rubidium@7892: * @param trackdir the track direction to convert rubidium@7892: * @return the converted TrackdirBits value matthijs@1948: */ rubidium@7892: static inline TrackdirBits TrackdirToTrackdirBits(Trackdir trackdir) rubidium@7892: { rubidium@7892: return (TrackdirBits)(1 << trackdir); rubidium@7892: } matthijs@1948: celestar@2232: /** rubidium@7892: * Removes first Track from TrackBits and returns it rubidium@7892: * rubidium@7892: * This function searchs for the first bit in the TrackBits, rubidium@7892: * remove this bit from the parameter and returns the found rubidium@7892: * bit as Track value. It returns INVALID_TRACK if the rubidium@7892: * parameter was TRACK_BIT_NONE or INVALID_TRACK_BIT. This rubidium@7892: * is basically used in while-loops to get up to 6 possible rubidium@7892: * tracks on a tile until the parameter becomes TRACK_BIT_NONE. rubidium@7892: * rubidium@7892: * @param tracks The value with the TrackBits rubidium@7892: * @return The first Track from the TrackBits value rubidium@7892: * @see FindFirstTrack rubidium@7892: */ KUDr@5849: static inline Track RemoveFirstTrack(TrackBits *tracks) rubidium@5838: { KUDr@5849: if (*tracks != TRACK_BIT_NONE && *tracks != INVALID_TRACK_BIT) { KUDr@5849: Track first = (Track)FIND_FIRST_BIT(*tracks); skidd13@8425: ClrBit(*tracks, first); rubidium@5838: return first; rubidium@5838: } rubidium@5838: return INVALID_TRACK; rubidium@5838: } rubidium@5838: rubidium@5838: /** rubidium@7892: * Removes first Trackdir from TrackdirBits and returns it rubidium@7892: * rubidium@7892: * This function searchs for the first bit in the TrackdirBits parameter, rubidium@7892: * remove this bit from the parameter and returns the fnound bit as rubidium@7892: * Trackdir value. It returns INVALID_TRACKDIR if the trackdirs is rubidium@7892: * TRACKDIR_BIT_NONE or INVALID_TRACKDIR_BIT. This is basically used in a rubidium@7892: * while-loop to get all track-directions step by step until the value rubidium@7892: * reaches TRACKDIR_BIT_NONE. rubidium@7892: * rubidium@7892: * @param trackdirs The value with the TrackdirBits rubidium@7892: * @return The first Trackdir from the TrackdirBits value rubidium@7892: * @see FindFirstTrackdir rubidium@7892: */ KUDr@5849: static inline Trackdir RemoveFirstTrackdir(TrackdirBits *trackdirs) rubidium@5838: { KUDr@5849: if (*trackdirs != TRACKDIR_BIT_NONE && *trackdirs != INVALID_TRACKDIR_BIT) { KUDr@5849: Trackdir first = (Trackdir)FindFirstBit2x64(*trackdirs); skidd13@8425: ClrBit(*trackdirs, first); rubidium@5838: return first; rubidium@5838: } rubidium@5838: return INVALID_TRACKDIR; rubidium@5838: } rubidium@5838: rubidium@5838: /** rubidium@7892: * Returns first Track from TrackBits or INVALID_TRACK rubidium@7892: * rubidium@7892: * This function returns the first Track found in the TrackBits value as Track-value. rubidium@7892: * It returns INVALID_TRACK if the parameter is TRACK_BIT_NONE or INVALID_TRACK_BIT. rubidium@7892: * rubidium@7892: * @param tracks The TrackBits value rubidium@7892: * @return The first Track found or INVALID_TRACK rubidium@7892: * @see RemoveFirstTrack rubidium@7892: */ rubidium@5838: static inline Track FindFirstTrack(TrackBits tracks) rubidium@5838: { rubidium@5838: return (tracks != TRACK_BIT_NONE && tracks != INVALID_TRACK_BIT) ? (Track)FIND_FIRST_BIT(tracks) : INVALID_TRACK; rubidium@5838: } rubidium@5838: rubidium@5838: /** rubidium@7892: * Converts TrackBits to Track. rubidium@7892: * rubidium@7892: * This function converts a TrackBits value to a Track value. As it rubidium@7892: * is not possible to convert two or more tracks to one track the rubidium@7892: * parameter must contain only one track or be the INVALID_TRACK_BIT value. rubidium@7892: * rubidium@7892: * @param tracks The TrackBits value to convert rubidium@7892: * @return The Track from the value or INVALID_TRACK rubidium@7892: * @pre tracks must contains only one Track or be INVALID_TRACK_BIT rubidium@7892: */ rubidium@5838: static inline Track TrackBitsToTrack(TrackBits tracks) rubidium@5838: { truelight@8329: assert(tracks == INVALID_TRACK_BIT || (tracks != TRACK_BIT_NONE && KillFirstBit(tracks & TRACK_BIT_MASK) == TRACK_BIT_NONE)); KUDr@7651: return tracks != INVALID_TRACK_BIT ? (Track)FIND_FIRST_BIT(tracks & TRACK_BIT_MASK) : INVALID_TRACK; rubidium@5838: } rubidium@5838: rubidium@5838: /** rubidium@7892: * Returns first Trackdir from TrackdirBits or INVALID_TRACKDIR rubidium@7892: * rubidium@7892: * This function returns the first Trackdir in the given TrackdirBits value or rubidium@7892: * INVALID_TRACKDIR if the value is TRACKDIR_BIT_NONE. The TrackdirBits must rubidium@7892: * not be INVALID_TRACKDIR_BIT. rubidium@7892: * rubidium@7892: * @param trackdirs The TrackdirBits value rubidium@7892: * @return The first Trackdir from the TrackdirBits or INVALID_TRACKDIR on TRACKDIR_BIT_NONE. rubidium@7892: * @pre trackdirs must not be INVALID_TRACKDIR_BIT rubidium@7892: * @see RemoveFirstTrackdir rubidium@7892: */ rubidium@5838: static inline Trackdir FindFirstTrackdir(TrackdirBits trackdirs) rubidium@5838: { rubidium@5838: assert((trackdirs & ~TRACKDIR_BIT_MASK) == TRACKDIR_BIT_NONE); rubidium@5838: return (trackdirs != TRACKDIR_BIT_NONE) ? (Trackdir)FindFirstBit2x64(trackdirs) : INVALID_TRACKDIR; rubidium@5838: } rubidium@5838: rubidium@5838: /** rubidium@7892: * Checks if a Track is valid. rubidium@7892: * rubidium@7892: * @param track The value to check rubidium@7892: * @return true if the given value is a valid track. rubidium@7892: * @note Use this in an assert() matthijs@1942: */ rubidium@7892: static inline bool IsValidTrack(Track track) rubidium@7892: { rubidium@7892: return track < TRACK_END; rubidium@7892: } matthijs@1942: celestar@2232: /** rubidium@7892: * Checks if a Trackdir is valid. rubidium@7892: * rubidium@7892: * @param trackdir The value to check rubidium@7892: * @return true if the given valie is a valid Trackdir rubidium@7892: * @note Use this in an assert() rubidium@7892: */ rubidium@7892: static inline bool IsValidTrackdir(Trackdir trackdir) rubidium@7892: { rubidium@7892: return (TrackdirToTrackdirBits(trackdir) & TRACKDIR_BIT_MASK) != 0; rubidium@7892: } rubidium@7892: matthijs@1942: matthijs@1942: /* matthijs@1942: * Functions describing logical relations between Tracks, TrackBits, Trackdirs matthijs@1942: * TrackdirBits, Direction and DiagDirections. matthijs@1942: */ matthijs@1942: matthijs@1942: /** matthijs@1944: * Maps a trackdir to the reverse trackdir. rubidium@7892: * rubidium@7892: * Returns the reverse trackdir of a Trackdir value. The reverse trackdir rubidium@7892: * is the same track with the other direction on it. rubidium@7892: * rubidium@7892: * @param trackdir The Trackdir value rubidium@7892: * @return The reverse trackdir rubidium@7892: * @pre trackdir must not be INVALID_TRACKDIR matthijs@1944: */ rubidium@5838: static inline Trackdir ReverseTrackdir(Trackdir trackdir) rubidium@5838: { rubidium@5838: assert(trackdir != INVALID_TRACKDIR); tron@3500: return (Trackdir)(trackdir ^ 8); matthijs@1948: } matthijs@1944: matthijs@2782: /** matthijs@2782: * Returns the Track that a given Trackdir represents rubidium@7892: * rubidium@7892: * This function filters the Track which is used in the Trackdir value and rubidium@7892: * returns it as a Track value. rubidium@7892: * rubidium@7892: * @param trackdir The trackdir value rubidium@7892: * @return The Track which is used in the value matthijs@2782: */ rubidium@7892: static inline Track TrackdirToTrack(Trackdir trackdir) rubidium@7892: { rubidium@7892: return (Track)(trackdir & 0x7); rubidium@7892: } matthijs@1944: matthijs@2782: /** rubidium@7892: * Returns a Trackdir for the given Track rubidium@7892: * rubidium@7892: * Since every Track corresponds to two Trackdirs, we choose the rubidium@7892: * one which points between NE and S. Note that the actual rubidium@7892: * implementation is quite futile, but this might change matthijs@1944: * in the future. rubidium@7892: * rubidium@7892: * @param track The given Track rubidium@7892: * @return The Trackdir from the given Track matthijs@1944: */ rubidium@7892: static inline Trackdir TrackToTrackdir(Track track) rubidium@7892: { rubidium@7892: return (Trackdir)track; rubidium@7892: } matthijs@1944: matthijs@2782: /** rubidium@7892: * Returns a TrackdirBit mask from a given Track rubidium@7892: * rubidium@7892: * The TrackdirBit mask contains the two TrackdirBits that matthijs@1944: * correspond with the given Track (one for each direction). rubidium@7892: * rubidium@7892: * @param track The track to get the TrackdirBits from rubidium@7892: * @return The TrackdirBits which the selected tracks matthijs@1944: */ tron@4077: static inline TrackdirBits TrackToTrackdirBits(Track track) tron@4077: { tron@4077: Trackdir td = TrackToTrackdir(track); tron@4077: return (TrackdirBits)(TrackdirToTrackdirBits(td) | TrackdirToTrackdirBits(ReverseTrackdir(td))); tron@4077: } matthijs@1944: matthijs@1944: /** rubidium@7892: * Discards all directional information from a TrackdirBits value rubidium@7892: * rubidium@7892: * Any Track which is present in either direction will be present in the result. rubidium@7892: * rubidium@7892: * @param bits The TrackdirBits to get the TrackBits from rubidium@7892: * @return The TrackBits matthijs@2782: */ tron@4077: static inline TrackBits TrackdirBitsToTrackBits(TrackdirBits bits) tron@4077: { matthijs@4281: return (TrackBits)((bits | (bits >> 8)) & TRACK_BIT_MASK); tron@4077: } matthijs@2782: matthijs@2782: /** matthijs@1942: * Maps a trackdir to the trackdir that you will end up on if you go straight rubidium@7892: * ahead. rubidium@7892: * rubidium@7892: * This will be the same trackdir for diagonal trackdirs, but a matthijs@1942: * different (alternating) one for straight trackdirs rubidium@7892: * rubidium@7892: * @param trackdir The given trackdir rubidium@7892: * @return The next Trackdir value of the next tile. matthijs@1942: */ tron@4077: static inline Trackdir NextTrackdir(Trackdir trackdir) tron@4077: { matthijs@1948: extern const Trackdir _next_trackdir[TRACKDIR_END]; matthijs@1948: return _next_trackdir[trackdir]; matthijs@1948: } matthijs@1942: matthijs@1942: /** matthijs@1942: * Maps a track to all tracks that make 90 deg turns with it. rubidium@7892: * rubidium@7892: * For the diagonal directions these are the complement of the rubidium@7892: * direction, for the straight directions these are the rubidium@7892: * two vertical or horizontal tracks, depend on the given direction rubidium@7892: * rubidium@7892: * @param track The given track rubidium@7892: * @return The TrackBits with the tracks marked which cross the given track by 90 deg. matthijs@1942: */ tron@4077: static inline TrackBits TrackCrossesTracks(Track track) tron@4077: { matthijs@1948: extern const TrackBits _track_crosses_tracks[TRACK_END]; matthijs@1948: return _track_crosses_tracks[track]; matthijs@1948: } matthijs@1942: matthijs@1942: /** matthijs@1942: * Maps a trackdir to the (4-way) direction the tile is exited when following matthijs@1942: * that trackdir. rubidium@7892: * rubidium@7892: * For the diagonal directions these are the same directions. For rubidium@7892: * the straight directions these are the directions from the imagined rubidium@7892: * base-tile to the bordering tile which will be joined if the given rubidium@7892: * straight direction is leaved from the base-tile. rubidium@7892: * rubidium@7892: * @param trackdir The given track direction rubidium@7892: * @return The direction which points to the resulting tile if following the Trackdir matthijs@1942: */ tron@4077: static inline DiagDirection TrackdirToExitdir(Trackdir trackdir) tron@4077: { matthijs@1948: extern const DiagDirection _trackdir_to_exitdir[TRACKDIR_END]; matthijs@1948: return _trackdir_to_exitdir[trackdir]; matthijs@1948: } matthijs@1942: matthijs@1942: /** matthijs@1942: * Maps a track and an (4-way) dir to the trackdir that represents the track matthijs@1942: * with the exit in the given direction. rubidium@7892: * rubidium@7892: * For the diagonal tracks the resulting track direction are clear for a given rubidium@7892: * DiagDirection. It either matches the direction or it returns INVALID_TRACKDIR, rubidium@7892: * as a TRACK_X cannot be applied with DIAG_SE. rubidium@7892: * For the straight tracks the resulting track direction will be the rubidium@7892: * direction which the DiagDirection is pointing. But this will be INVALID_TRACKDIR rubidium@7892: * if the DiagDirection is pointing 'away' the track. rubidium@7892: * rubidium@7892: * @param track The track to applie an direction on rubidium@7892: * @param diagdir The DiagDirection to applie on rubidium@7892: * @return The resulting track direction or INVALID_TRACKDIR if not possible. matthijs@1942: */ tron@4077: static inline Trackdir TrackExitdirToTrackdir(Track track, DiagDirection diagdir) tron@4077: { matthijs@1948: extern const Trackdir _track_exitdir_to_trackdir[TRACK_END][DIAGDIR_END]; matthijs@1948: return _track_exitdir_to_trackdir[track][diagdir]; matthijs@1948: } matthijs@1942: matthijs@1942: /** hackykid@2008: * Maps a track and an (4-way) dir to the trackdir that represents the track rubidium@7892: * with the entry in the given direction. rubidium@7892: * rubidium@7892: * For the diagonal tracks the return value is clear, its either the matching rubidium@7892: * track direction or INVALID_TRACKDIR. rubidium@7892: * For the straight tracks this returns the track direction which results if rubidium@7892: * you follow the DiagDirection and then turn by 45 deg left or right on the rubidium@7892: * next tile. The new direction on the new track will be the returning Trackdir rubidium@7892: * value. If the parameters makes no sense like the track TRACK_UPPER and the rubidium@7892: * diraction DIAGDIR_NE (target track cannot be reached) this function returns rubidium@7892: * INVALID_TRACKDIR. rubidium@7892: * rubidium@7892: * @param track The target track rubidium@7892: * @param diagdir The direction to "come from" rubidium@7892: * @return the resulting Trackdir or INVALID_TRACKDIR if not possible. hackykid@2008: */ tron@4077: static inline Trackdir TrackEnterdirToTrackdir(Track track, DiagDirection diagdir) tron@4077: { hackykid@2008: extern const Trackdir _track_enterdir_to_trackdir[TRACK_END][DIAGDIR_END]; hackykid@2008: return _track_enterdir_to_trackdir[track][diagdir]; hackykid@2008: } hackykid@2008: hackykid@2008: /** matthijs@1942: * Maps a track and a full (8-way) direction to the trackdir that represents matthijs@1942: * the track running in the given direction. matthijs@1942: */ tron@4077: static inline Trackdir TrackDirectionToTrackdir(Track track, Direction dir) tron@4077: { matthijs@1948: extern const Trackdir _track_direction_to_trackdir[TRACK_END][DIR_END]; matthijs@1948: return _track_direction_to_trackdir[track][dir]; matthijs@1948: } matthijs@1942: matthijs@1942: /** matthijs@1942: * Maps a (4-way) direction to the diagonal trackdir that runs in that matthijs@1942: * direction. rubidium@7892: * rubidium@7892: * @param diagdir The direction rubidium@7892: * @return The resulting Trackdir direction matthijs@1942: */ tron@4077: static inline Trackdir DiagdirToDiagTrackdir(DiagDirection diagdir) tron@4077: { matthijs@1948: extern const Trackdir _dir_to_diag_trackdir[DIAGDIR_END]; matthijs@1948: return _dir_to_diag_trackdir[diagdir]; matthijs@1948: } matthijs@1942: matthijs@2782: /** matthijs@2782: * Returns all trackdirs that can be reached when entering a tile from a given rubidium@7892: * (diagonal) direction. rubidium@7892: * rubidium@7892: * This will obviously include 90 degree turns, since no information is available rubidium@7892: * about the exact angle of entering rubidium@7892: * rubidium@7892: * @param diagdir The joining direction rubidium@7892: * @return The TrackdirBits which can be used from the given direction rubidium@7892: * @see DiagdirReachesTracks rubidium@7892: */ rubidium@6488: static inline TrackdirBits DiagdirReachesTrackdirs(DiagDirection diagdir) rubidium@6488: { rubidium@6488: extern const TrackdirBits _exitdir_reaches_trackdirs[DIAGDIR_END]; rubidium@6488: return _exitdir_reaches_trackdirs[diagdir]; rubidium@6488: } matthijs@2782: matthijs@2782: /** matthijs@2782: * Returns all tracks that can be reached when entering a tile from a given rubidium@7892: * (diagonal) direction. rubidium@7892: * rubidium@7892: * This will obviously include 90 degree turns, since no rubidium@7892: * information is available about the exact angle of entering rubidium@7892: * rubidium@7892: * @param diagdir The joining irection rubidium@7892: * @return The tracks which can be used rubidium@7892: * @see DiagdirReachesTrackdirs rubidium@7892: */ matthijs@2782: static inline TrackBits DiagdirReachesTracks(DiagDirection diagdir) { return TrackdirBitsToTrackBits(DiagdirReachesTrackdirs(diagdir)); } matthijs@2782: matthijs@1942: /** matthijs@1942: * Maps a trackdir to the trackdirs that can be reached from it (ie, when rubidium@7892: * entering the next tile. rubidium@7892: * rubidium@7892: * This will include 90 degree turns! rubidium@7892: * rubidium@7892: * @param trackdir The track direction which will be leaved rubidium@7892: * @return The track directions which can be used from this direction (in the next tile) matthijs@1942: */ rubidium@6488: static inline TrackdirBits TrackdirReachesTrackdirs(Trackdir trackdir) rubidium@6488: { rubidium@6488: extern const TrackdirBits _exitdir_reaches_trackdirs[DIAGDIR_END]; rubidium@6488: return _exitdir_reaches_trackdirs[TrackdirToExitdir(trackdir)]; rubidium@6488: } matthijs@1942: /* Note that there is no direct table for this function (there used to be), matthijs@1942: * but it uses two simpeler tables to achieve the result */ matthijs@2782: matthijs@1942: /** matthijs@1942: * Maps a trackdir to all trackdirs that make 90 deg turns with it. rubidium@7892: * rubidium@7892: * For the diagonal tracks this returns the track direction bits rubidium@7892: * of the other axis in both directions, which cannot be joined by rubidium@7892: * the given track direction. rubidium@7892: * For the straight tracks this returns all possible 90 deg turns rubidium@7892: * either on the current tile (which no train can joined) or on the rubidium@7892: * bordering tiles. rubidium@7892: * rubidium@7892: * @param trackdir The track direction rubidium@7892: * @return The TrackdirBits which are (more or less) 90 deg turns. matthijs@1942: */ rubidium@6488: static inline TrackdirBits TrackdirCrossesTrackdirs(Trackdir trackdir) rubidium@6488: { matthijs@1948: extern const TrackdirBits _track_crosses_trackdirs[TRACKDIR_END]; matthijs@1948: return _track_crosses_trackdirs[TrackdirToTrack(trackdir)]; matthijs@1948: } matthijs@1942: rubidium@7892: /** rubidium@7892: * Checks if a given Track is diagonal rubidium@7892: * rubidium@7892: * @param track The given track to check rubidium@7892: * @return true if diagonal, else false rubidium@7892: */ rubidium@7892: static inline bool IsDiagonalTrack(Track track) rubidium@7892: { rubidium@7892: return (track == TRACK_X) || (track == TRACK_Y); rubidium@7892: } hackykid@2008: rubidium@7892: /** rubidium@7892: * Checks if a given Trackdir is diagonal. rubidium@7892: * rubidium@7892: * @param trackdir The given trackdir rubidium@7892: * @return true if the trackdir use a diagonal track rubidium@7892: */ rubidium@7892: static inline bool IsDiagonalTrackdir(Trackdir trackdir) rubidium@7892: { rubidium@7892: return IsDiagonalTrack(TrackdirToTrack(trackdir)); rubidium@7892: } matthijs@1967: celestar@3355: matthijs@2782: /** matthijs@2782: * Checks if the given tracks overlap, ie form a crossing. Basically this matthijs@2782: * means when there is more than one track on the tile, exept when there are matthijs@2782: * two parallel tracks. matthijs@2782: * @param bits The tracks present. matthijs@2782: * @return Whether the tracks present overlap in any way. matthijs@2782: */ matthijs@2782: static inline bool TracksOverlap(TrackBits bits) matthijs@2782: { tron@4077: /* With no, or only one track, there is no overlap */ truelight@8329: if (bits == TRACK_BIT_NONE || KillFirstBit(bits) == TRACK_BIT_NONE) return false; tron@4077: /* We know that there are at least two tracks present. When there are more tron@4077: * than 2 tracks, they will surely overlap. When there are two, they will tron@4077: * always overlap unless they are lower & upper or right & left. */ tron@3258: return bits != TRACK_BIT_HORZ && bits != TRACK_BIT_VERT; matthijs@2782: } matthijs@2782: rubidium@8598: /** rubidium@8598: * Checks whether the trackdir means that we are reversing. rubidium@8598: * @param dir the trackdir to check rubidium@8598: * @return true if it is a reversing road trackdir rubidium@8598: */ rubidium@8598: static inline bool IsReversingRoadTrackdir(Trackdir dir) rubidium@8598: { rubidium@8598: return (dir & 0x07) >= 6; rubidium@8598: } rubidium@8598: rubidium@8598: /** rubidium@8598: * Checks whether the given trackdir is a straight road rubidium@8598: * @param dir the trackdir to check rubidium@8598: * @return true if it is a straight road trackdir rubidium@8598: */ rubidium@8598: static inline bool IsStraightRoadTrackdir(Trackdir dir) rubidium@8598: { rubidium@8598: return (dir & 0x06) == 0; rubidium@8598: } rubidium@8598: rubidium@8599: #endif /* TRACK_FUNC_H */