src/yapf/yapf_costbase.hpp
changeset 9149 cd335504407b
parent 8875 ffcab947226b
child 10429 1b99254f9607
equal deleted inserted replaced
9148:778a53fe72f3 9149:cd335504407b
     2 
     2 
     3 #ifndef  YAPF_COSTBASE_HPP
     3 #ifndef  YAPF_COSTBASE_HPP
     4 #define  YAPF_COSTBASE_HPP
     4 #define  YAPF_COSTBASE_HPP
     5 
     5 
     6 struct CYapfCostBase {
     6 struct CYapfCostBase {
     7 	static const TrackdirBits   c_upwards_slopes[16];
       
     8 
       
     9 	FORCEINLINE static bool stSlopeCost(TileIndex tile, Trackdir td)
     7 	FORCEINLINE static bool stSlopeCost(TileIndex tile, Trackdir td)
    10 	{
     8 	{
    11 		if (IsDiagonalTrackdir(td)) {
     9 		if (IsDiagonalTrackdir(td)) {
    12 			if (IsBridgeTile(tile)) {
    10 			if (IsBridgeTile(tile)) {
    13 				// it is bridge ramp, check if we are entering the bridge
    11 				// it is bridge ramp, check if we are entering the bridge
    17 				Axis axis = DiagDirToAxis(GetTunnelBridgeDirection(tile));
    15 				Axis axis = DiagDirToAxis(GetTunnelBridgeDirection(tile));
    18 				return !HasBridgeFlatRamp(tile_slope, axis);
    16 				return !HasBridgeFlatRamp(tile_slope, axis);
    19 			} else {
    17 			} else {
    20 				// not bridge ramp
    18 				// not bridge ramp
    21 				if (IsTunnelTile(tile)) return false; // tunnel entry/exit doesn't slope
    19 				if (IsTunnelTile(tile)) return false; // tunnel entry/exit doesn't slope
    22 				uint tile_slope = GetTileSlope(tile, NULL) & 0x0F;
    20 				Slope tile_slope = GetTileSlope(tile, NULL);
    23 				if ((c_upwards_slopes[tile_slope] & TrackdirToTrackdirBits(td)) != 0) return true; // slopes uphill => apply penalty
    21 				return IsUphillTrackdir(tile_slope, td); // slopes uphill => apply penalty
    24 			}
    22 			}
    25 		}
    23 		}
    26 		return false;
    24 		return false;
    27 	}
    25 	}
    28 };
    26 };