summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2010-03-02 03:31:02 +0000
committermichi_cc <michi_cc@openttd.org>2010-03-02 03:31:02 +0000
commite4824c42931e6d02024ac777204ecfdf892d278f (patch)
treef94469e07417e42b3da08dcc30a661c8aca0002d
parent3cda09170cf9e2560029393f2b688d7afec70cf4 (diff)
downloadopenttd-e4824c42931e6d02024ac777204ecfdf892d278f.tar.xz
(svn r19301) -Feature: [YAPF] Consider the railtype imposed speed limit for pathfinding.
-rw-r--r--src/pathfinder/follow_track.hpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/pathfinder/follow_track.hpp b/src/pathfinder/follow_track.hpp
index 4c0fa7805..6fdebc3e6 100644
--- a/src/pathfinder/follow_track.hpp
+++ b/src/pathfinder/follow_track.hpp
@@ -428,12 +428,17 @@ public:
int min_speed = 0;
int max_speed = INT_MAX; // no limit
- /* for now we handle only on-bridge speed limit */
+ /* Check for on-bridge speed limit */
if (!IsWaterTT() && IsBridgeTile(m_old_tile)) {
int spd = GetBridgeSpec(GetBridgeType(m_old_tile))->speed;
if (IsRoadTT()) spd *= 2;
if (max_speed > spd) max_speed = spd;
}
+ /* Check for speed limit imposed by railtype */
+ if (IsRailTT()) {
+ uint16 rail_speed = GetRailTypeInfo(GetRailType(m_old_tile))->max_speed;
+ if (rail_speed > 0) max_speed = min(max_speed, rail_speed);
+ }
/* if min speed was requested, return it */
if (pmin_speed) *pmin_speed = min_speed;