Add: INR currency (#8136)
[openttd-github.git] / src / pathfinder / yapf / yapf_costbase.hpp
blob8da9257d91720cc64c3cc7e0370196b8b8a6e908
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
8 /** @file yapf_costbase.hpp Handling of cost determination. */
10 #ifndef YAPF_COSTBASE_HPP
11 #define YAPF_COSTBASE_HPP
13 /** Base implementation for cost accounting. */
14 struct CYapfCostBase {
15 /**
16 * Does the given track direction on the given tile yield an uphill penalty?
17 * @param tile The tile to check.
18 * @param td The track direction to check.
19 * @return True if there's a slope, otherwise false.
21 inline static bool stSlopeCost(TileIndex tile, Trackdir td)
23 if (IsDiagonalTrackdir(td)) {
24 if (IsBridgeTile(tile)) {
25 /* it is bridge ramp, check if we are entering the bridge */
26 if (GetTunnelBridgeDirection(tile) != TrackdirToExitdir(td)) return false; // no, we are leaving it, no penalty
27 /* we are entering the bridge */
28 Slope tile_slope = GetTileSlope(tile);
29 Axis axis = DiagDirToAxis(GetTunnelBridgeDirection(tile));
30 return !HasBridgeFlatRamp(tile_slope, axis);
31 } else {
32 /* not bridge ramp */
33 if (IsTunnelTile(tile)) return false; // tunnel entry/exit doesn't slope
34 Slope tile_slope = GetTileSlope(tile);
35 return IsUphillTrackdir(tile_slope, td); // slopes uphill => apply penalty
38 return false;
42 #endif /* YAPF_COSTBASE_HPP */