src/yapf/yapf_costbase.hpp
changeset 5726 8f399788f6c9
parent 5573 afa6f92a71fd
child 6872 1c4a4a609f85
child 8579 3efbb430092e
equal deleted inserted replaced
5725:8ad0e96437e0 5726:8f399788f6c9
       
     1 /* $Id$ */
       
     2 
       
     3 #ifndef  YAPF_COSTBASE_HPP
       
     4 #define  YAPF_COSTBASE_HPP
       
     5 
       
     6 struct CYapfCostBase {
       
     7 	static const TrackdirBits   c_upwards_slopes[16];
       
     8 
       
     9 	FORCEINLINE static bool stSlopeCost(TileIndex tile, Trackdir td)
       
    10 	{
       
    11 		if (IsDiagonalTrackdir(td)) {
       
    12 			if (IsBridgeTile(tile)) {
       
    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
       
    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
       
    26 			}
       
    27 		}
       
    28 		return false;
       
    29 	}
       
    30 };
       
    31 
       
    32 struct CostRailSettings {
       
    33 	// look-ahead signal penalty
       
    34 };
       
    35 
       
    36 
       
    37 #endif /* YAPF_COSTBASE_HPP */