Bug in TrackdirBitsToTrackBits()

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
Hazelrah
Traffic Manager
Traffic Manager
Posts: 196
Joined: 13 Apr 2005 05:41

Bug in TrackdirBitsToTrackBits()

Post by Hazelrah »

Currently TrackdirBitsToTrackBits() is defined as follows:

Code: Select all

static inline TrackBits TrackdirBitsToTrackBits(TrackdirBits bits) { return (TrackBits)(bits | (bits >> 8)); }
This algorithm puts the right trackbits in the lower 8 bits, but then fails to remove the upper 8 bits, actually making it an invalid TrackBits. I believe it should be:

Code: Select all

static inline TrackBits TrackdirBitsToTrackBits(TrackdirBits bits) { return (TrackBits)((bits | (bits >> 8)) & TRACK_BIT_MASK); }
Or was this done on purpose for some reason?

-Hazelrah
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 6 guests