1
0
Fork 0

(svn r5106) - Backport from trunk (r4964):

Fix NTP over bridges: don't check the rail type when on a bridge
release/0.4
Darkvater 2006-06-04 21:40:21 +00:00
parent 00f2b3e713
commit f026c645e3
1 changed files with 14 additions and 3 deletions

View File

@ -672,6 +672,13 @@ static const byte _length_of_track[16] = {
DIAG_FACTOR,DIAG_FACTOR,STR_FACTOR,STR_FACTOR,STR_FACTOR,STR_FACTOR,0,0
};
static inline bool IsBridgeMiddle(TileIndex t) {return HASBIT(_m[t].m5, 6);}
static inline uint GetBridgeAxis(TileIndex t) {return GB(_m[t].m5, 0, 1);}
static inline uint DiagDirToAxis(DiagDirection d) {return (d & 1);}
static inline bool IsBridge(TileIndex t) {return HASBIT(_m[t].m5, 7);}
static inline bool IsBridgeTile(TileIndex t) {return IsTileType(t, MP_TUNNELBRIDGE) && IsBridge(t);}
static inline RailType GetRailTypeCrossing(TileIndex t) {return (RailType)GB(_m[t].m4, 0, 4);}
// new more optimized pathfinder for trains...
// Tile is the tile the train is at.
// direction is the tile the train is moving towards.
@ -766,9 +773,13 @@ start_at:
// Check that the tile contains exactly one track
if (bits == 0 || KILL_FIRST_BIT(bits) != 0) break;
if (IsTileType(tile, MP_STREET) ? !HASBIT(tpf->railtypes, GB(_m[tile].m4, 0, 4)) : !HASBIT(tpf->railtypes, GetRailType(tile))) {
bits = 0;
break;
/* Check the rail type only if the train is *NOT* on top of
* a bridge. */
if (!(IsBridgeTile(tile) && IsBridgeMiddle(tile) && GetBridgeAxis(tile) == DiagDirToAxis(direction))) {
if (IsTileType(tile, MP_STREET) ? !HASBIT(tpf->railtypes, GetRailTypeCrossing(tile)) : !HASBIT(tpf->railtypes, GetRailType(tile))) {
bits = 0;
break;
}
}
///////////////////