equal
deleted
inserted
replaced
310 */ |
310 */ |
311 static inline Track RemoveFirstTrack(TrackBits *tracks) |
311 static inline Track RemoveFirstTrack(TrackBits *tracks) |
312 { |
312 { |
313 if (*tracks != TRACK_BIT_NONE && *tracks != INVALID_TRACK_BIT) { |
313 if (*tracks != TRACK_BIT_NONE && *tracks != INVALID_TRACK_BIT) { |
314 Track first = (Track)FIND_FIRST_BIT(*tracks); |
314 Track first = (Track)FIND_FIRST_BIT(*tracks); |
315 ClrBitT(*tracks, first); |
315 ClrBit(*tracks, first); |
316 return first; |
316 return first; |
317 } |
317 } |
318 return INVALID_TRACK; |
318 return INVALID_TRACK; |
319 } |
319 } |
320 |
320 |
334 */ |
334 */ |
335 static inline Trackdir RemoveFirstTrackdir(TrackdirBits *trackdirs) |
335 static inline Trackdir RemoveFirstTrackdir(TrackdirBits *trackdirs) |
336 { |
336 { |
337 if (*trackdirs != TRACKDIR_BIT_NONE && *trackdirs != INVALID_TRACKDIR_BIT) { |
337 if (*trackdirs != TRACKDIR_BIT_NONE && *trackdirs != INVALID_TRACKDIR_BIT) { |
338 Trackdir first = (Trackdir)FindFirstBit2x64(*trackdirs); |
338 Trackdir first = (Trackdir)FindFirstBit2x64(*trackdirs); |
339 ClrBitT(*trackdirs, first); |
339 ClrBit(*trackdirs, first); |
340 return first; |
340 return first; |
341 } |
341 } |
342 return INVALID_TRACKDIR; |
342 return INVALID_TRACKDIR; |
343 } |
343 } |
344 |
344 |
368 * @return The Track from the value or INVALID_TRACK |
368 * @return The Track from the value or INVALID_TRACK |
369 * @pre tracks must contains only one Track or be INVALID_TRACK_BIT |
369 * @pre tracks must contains only one Track or be INVALID_TRACK_BIT |
370 */ |
370 */ |
371 static inline Track TrackBitsToTrack(TrackBits tracks) |
371 static inline Track TrackBitsToTrack(TrackBits tracks) |
372 { |
372 { |
373 assert(tracks == INVALID_TRACK_BIT || (tracks != TRACK_BIT_NONE && KILL_FIRST_BIT(tracks & TRACK_BIT_MASK) == 0)); |
373 assert(tracks == INVALID_TRACK_BIT || (tracks != TRACK_BIT_NONE && KillFirstBit(tracks & TRACK_BIT_MASK) == TRACK_BIT_NONE)); |
374 return tracks != INVALID_TRACK_BIT ? (Track)FIND_FIRST_BIT(tracks & TRACK_BIT_MASK) : INVALID_TRACK; |
374 return tracks != INVALID_TRACK_BIT ? (Track)FIND_FIRST_BIT(tracks & TRACK_BIT_MASK) : INVALID_TRACK; |
375 } |
375 } |
376 |
376 |
377 /** |
377 /** |
378 * Returns first Trackdir from TrackdirBits or INVALID_TRACKDIR |
378 * Returns first Trackdir from TrackdirBits or INVALID_TRACKDIR |
757 * @param enginetype The RailType of the engine we are considering. |
757 * @param enginetype The RailType of the engine we are considering. |
758 * @param tiletype The RailType of the tile we are considering. |
758 * @param tiletype The RailType of the tile we are considering. |
759 */ |
759 */ |
760 static inline bool IsCompatibleRail(RailType enginetype, RailType tiletype) |
760 static inline bool IsCompatibleRail(RailType enginetype, RailType tiletype) |
761 { |
761 { |
762 return HASBIT(GetRailTypeInfo(enginetype)->compatible_railtypes, tiletype); |
762 return HasBit(GetRailTypeInfo(enginetype)->compatible_railtypes, tiletype); |
763 } |
763 } |
764 |
764 |
765 /** |
765 /** |
766 * Checks if an engine of the given RailType got power on a tile with a given |
766 * Checks if an engine of the given RailType got power on a tile with a given |
767 * RailType. This would normally just be an equality check, but for electric |
767 * RailType. This would normally just be an equality check, but for electric |
770 * @param enginetype The RailType of the engine we are considering. |
770 * @param enginetype The RailType of the engine we are considering. |
771 * @param tiletype The RailType of the tile we are considering. |
771 * @param tiletype The RailType of the tile we are considering. |
772 */ |
772 */ |
773 static inline bool HasPowerOnRail(RailType enginetype, RailType tiletype) |
773 static inline bool HasPowerOnRail(RailType enginetype, RailType tiletype) |
774 { |
774 { |
775 return HASBIT(GetRailTypeInfo(enginetype)->powered_railtypes, tiletype); |
775 return HasBit(GetRailTypeInfo(enginetype)->powered_railtypes, tiletype); |
776 } |
776 } |
777 |
777 |
778 /** |
778 /** |
779 * Checks if the given tracks overlap, ie form a crossing. Basically this |
779 * Checks if the given tracks overlap, ie form a crossing. Basically this |
780 * means when there is more than one track on the tile, exept when there are |
780 * means when there is more than one track on the tile, exept when there are |
783 * @return Whether the tracks present overlap in any way. |
783 * @return Whether the tracks present overlap in any way. |
784 */ |
784 */ |
785 static inline bool TracksOverlap(TrackBits bits) |
785 static inline bool TracksOverlap(TrackBits bits) |
786 { |
786 { |
787 /* With no, or only one track, there is no overlap */ |
787 /* With no, or only one track, there is no overlap */ |
788 if (bits == 0 || KILL_FIRST_BIT(bits) == 0) return false; |
788 if (bits == TRACK_BIT_NONE || KillFirstBit(bits) == TRACK_BIT_NONE) return false; |
789 /* We know that there are at least two tracks present. When there are more |
789 /* We know that there are at least two tracks present. When there are more |
790 * than 2 tracks, they will surely overlap. When there are two, they will |
790 * than 2 tracks, they will surely overlap. When there are two, they will |
791 * always overlap unless they are lower & upper or right & left. */ |
791 * always overlap unless they are lower & upper or right & left. */ |
792 return bits != TRACK_BIT_HORZ && bits != TRACK_BIT_VERT; |
792 return bits != TRACK_BIT_HORZ && bits != TRACK_BIT_VERT; |
793 } |
793 } |
819 void DrawCatenary(const TileInfo *ti); |
819 void DrawCatenary(const TileInfo *ti); |
820 void DrawCatenaryOnTunnel(const TileInfo *ti); |
820 void DrawCatenaryOnTunnel(const TileInfo *ti); |
821 |
821 |
822 Foundation GetRailFoundation(Slope tileh, TrackBits bits); |
822 Foundation GetRailFoundation(Slope tileh, TrackBits bits); |
823 |
823 |
|
824 void FloodHalftile(TileIndex t); |
|
825 |
824 int32 SettingsDisableElrail(int32 p1); ///< _patches.disable_elrail callback |
826 int32 SettingsDisableElrail(int32 p1); ///< _patches.disable_elrail callback |
825 |
827 |
826 #endif /* RAIL_H */ |
828 #endif /* RAIL_H */ |