equal
deleted
inserted
replaced
6 struct CYapfCostBase { |
6 struct CYapfCostBase { |
7 static const TrackdirBits c_upwards_slopes[16]; |
7 static const TrackdirBits c_upwards_slopes[16]; |
8 |
8 |
9 FORCEINLINE static bool stSlopeCost(TileIndex tile, Trackdir td) |
9 FORCEINLINE static bool stSlopeCost(TileIndex tile, Trackdir td) |
10 { |
10 { |
11 if (IsDiagonalTrackdir(td) && !IsTunnelTile(tile)) { |
11 if (IsDiagonalTrackdir(td)) { |
12 uint tile_slope = GetTileSlope(tile, NULL) & 0x0F; |
12 if (IsBridgeTile(tile) && IsBridgeRamp(tile)) { |
13 if ((c_upwards_slopes[tile_slope] & TrackdirToTrackdirBits(td)) != 0) { |
13 // it is bridge ramp, check if we are entering the bridge |
|
14 if (GetBridgeRampDirection(tile) != TrackdirToExitdir(td)) return false; // no, we are living it, no penalty |
|
15 // we are entering the bridge |
|
16 // if the tile slope is downwards, then bridge ramp has not upward slope |
|
17 uint tile_slope = GetTileSlope(tile, NULL) & 0x0F; |
|
18 if ((c_upwards_slopes[tile_slope] & TrackdirToTrackdirBits(ReverseTrackdir(td))) != 0) return false; // tile under ramp goes down, no penalty |
|
19 // tile under ramp isn't going down, so ramp must go up |
14 return true; |
20 return true; |
|
21 } else { |
|
22 // not bridge ramp |
|
23 if (IsTunnelTile(tile)) return false; // tunnel entry/exit doesn't slope |
|
24 uint tile_slope = GetTileSlope(tile, NULL) & 0x0F; |
|
25 if ((c_upwards_slopes[tile_slope] & TrackdirToTrackdirBits(td)) != 0) return true; // slopes uphill => apply penalty |
15 } |
26 } |
16 } |
27 } |
17 return false; |
28 return false; |
18 } |
29 } |
19 }; |
30 }; |