summaryrefslogtreecommitdiff
path: root/src/track_func.h
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
commit4ec7f33f8cac235d5564eadd3cdb70d1ed94997f (patch)
treeb6a5956820cbae3751e4b56fd28c9a38cd3cad1d /src/track_func.h
parent36678c0ae8eb65bd6c678fc7860b78de7fb0121b (diff)
downloadopenttd-4ec7f33f8cac235d5564eadd3cdb70d1ed94997f.tar.xz
(svn r12313) -Fix: YAPF and NTP did not apply penalty for uphill tracks on steep slopes.
Diffstat (limited to 'src/track_func.h')
-rw-r--r--src/track_func.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/track_func.h b/src/track_func.h
index 38a1bba66..88d8d423e 100644
--- a/src/track_func.h
+++ b/src/track_func.h
@@ -574,4 +574,20 @@ static inline bool IsStraightRoadTrackdir(Trackdir dir)
return (dir & 0x06) == 0;
}
+/**
+ * Checks whether a trackdir on a specific slope is going uphill.
+ *
+ * Valid for rail and road tracks.
+ * Valid for tile-slopes (under foundation) and foundation-slopes (on foundation).
+ *
+ * @param slope The slope of the tile.
+ * @param dir The trackdir of interest.
+ * @return true iff the track goes upwards.
+ */
+static inline bool IsUphillTrackdir(Slope slope, Trackdir dir)
+{
+ extern const TrackdirBits _uphill_trackdirs[];
+ return HasBit(_uphill_trackdirs[RemoveHalftileSlope(slope)], dir);
+}
+
#endif /* TRACK_FUNC_H */