diff options
author | frosch <frosch@openttd.org> | 2008-02-28 17:34:34 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2008-02-28 17:34:34 +0000 |
commit | 4ec7f33f8cac235d5564eadd3cdb70d1ed94997f (patch) | |
tree | b6a5956820cbae3751e4b56fd28c9a38cd3cad1d /src/pathfind.cpp | |
parent | 36678c0ae8eb65bd6c678fc7860b78de7fb0121b (diff) | |
download | openttd-4ec7f33f8cac235d5564eadd3cdb70d1ed94997f.tar.xz |
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
Diffstat (limited to 'src/pathfind.cpp')
-rw-r--r-- | src/pathfind.cpp | 23 |
1 files changed, 2 insertions, 21 deletions
diff --git a/src/pathfind.cpp b/src/pathfind.cpp index ad2b40fae..84569bbe0 100644 --- a/src/pathfind.cpp +++ b/src/pathfind.cpp @@ -540,24 +540,6 @@ static bool NtpCheck(NewTrackPathFinder *tpf, TileIndex tile, uint dir, uint len } -static const uint16 _is_upwards_slope[15] = { - 0, ///< no tileh - (1 << TRACKDIR_X_SW) | (1 << TRACKDIR_Y_NW), ///< 1 - (1 << TRACKDIR_X_SW) | (1 << TRACKDIR_Y_SE), ///< 2 - (1 << TRACKDIR_X_SW), ///< 3 - (1 << TRACKDIR_X_NE) | (1 << TRACKDIR_Y_SE), ///< 4 - 0, ///< 5 - (1 << TRACKDIR_Y_SE), ///< 6 - 0, ///< 7 - (1 << TRACKDIR_X_NE) | (1 << TRACKDIR_Y_NW), ///< 8, - (1 << TRACKDIR_Y_NW), ///< 9 - 0, ///< 10 - 0, ///< 11, - (1 << TRACKDIR_X_NE), ///< 12 - 0, ///< 13 - 0, ///< 14 -}; - static uint DistanceMoo(TileIndex t0, TileIndex t1) { const uint dx = Delta(TileX(t0), TileX(t1)); @@ -727,9 +709,8 @@ start_at: si.cur_length += _length_of_track[track]; - /* Check if this rail is an upwards slope. If it is, then add a penalty. - * Small optimization here.. if (track&7)>1 then it can't be a slope so we avoid calling GetTileSlope */ - if ((track & 7) <= 1 && (_is_upwards_slope[GetTileSlope(tile, NULL)] & (1 << track)) ) { + /* Check if this rail is an upwards slope. If it is, then add a penalty. */ + if (IsDiagonalTrackdir(track) && IsUphillTrackdir(GetTileSlope(tile, NULL), track)) { // upwards slope. add some penalty. si.cur_length += 4 * DIAG_FACTOR; } |