summaryrefslogtreecommitdiff
path: root/src/pathfind.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2008-02-28 17:34:34 +0000
committerfrosch <frosch@openttd.org>2008-02-28 17:34:34 +0000
commit35fd0dfd4ef6ddf466599404f1e3e81a7cf855ef (patch)
treeb6a5956820cbae3751e4b56fd28c9a38cd3cad1d /src/pathfind.cpp
parent86a4d377b1f0a2cdc540ce8f029151d799a35023 (diff)
downloadopenttd-35fd0dfd4ef6ddf466599404f1e3e81a7cf855ef.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.cpp23
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;
}