00001 /* $Id$ */ 00002 00003 /* 00004 * This file is part of OpenTTD. 00005 * 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. 00006 * 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. 00007 * 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/>. 00008 */ 00009 00012 #ifndef YAPF_COSTBASE_HPP 00013 #define YAPF_COSTBASE_HPP 00014 00016 struct CYapfCostBase { 00023 inline static bool stSlopeCost(TileIndex tile, Trackdir td) 00024 { 00025 if (IsDiagonalTrackdir(td)) { 00026 if (IsBridgeTile(tile)) { 00027 /* it is bridge ramp, check if we are entering the bridge */ 00028 if (GetTunnelBridgeDirection(tile) != TrackdirToExitdir(td)) return false; // no, we are leaving it, no penalty 00029 /* we are entering the bridge */ 00030 Slope tile_slope = GetTileSlope(tile); 00031 Axis axis = DiagDirToAxis(GetTunnelBridgeDirection(tile)); 00032 return !HasBridgeFlatRamp(tile_slope, axis); 00033 } else { 00034 /* not bridge ramp */ 00035 if (IsTunnelTile(tile)) return false; // tunnel entry/exit doesn't slope 00036 Slope tile_slope = GetTileSlope(tile); 00037 return IsUphillTrackdir(tile_slope, td); // slopes uphill => apply penalty 00038 } 00039 } 00040 return false; 00041 } 00042 }; 00043 00044 #endif /* YAPF_COSTBASE_HPP */