summaryrefslogtreecommitdiff
path: root/src/yapf/yapf_costrail.hpp
diff options
context:
space:
mode:
authorKUDr <kudr@openttd.org>2007-02-24 00:17:46 +0000
committerKUDr <kudr@openttd.org>2007-02-24 00:17:46 +0000
commit029ceda0f1c2f11231a0662cc45057f8452f645a (patch)
treea567351d7e9a2e7575b410393280573e0ba04d98 /src/yapf/yapf_costrail.hpp
parent433b8054e9e63da606ccee3a23ec958d03200c75 (diff)
downloadopenttd-029ceda0f1c2f11231a0662cc45057f8452f645a.tar.xz
(svn r8869) [YAPF] -Fix: Large Train Stations/Trains makes OpenTTD crash (Jigsaw_Psyche)
Diffstat (limited to 'src/yapf/yapf_costrail.hpp')
-rw-r--r--src/yapf/yapf_costrail.hpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/yapf/yapf_costrail.hpp b/src/yapf/yapf_costrail.hpp
index b776815dc..4335c8a5b 100644
--- a/src/yapf/yapf_costrail.hpp
+++ b/src/yapf/yapf_costrail.hpp
@@ -66,7 +66,7 @@ public:
}
/** return one tile cost. If tile is a tunnel entry, it is moved to the end of tunnel */
- FORCEINLINE int OneTileCost(TileIndex& tile, Trackdir trackdir)
+ FORCEINLINE int OneTileCost(TileIndex prev_tile, TileIndex& tile, Trackdir trackdir)
{
int cost = 0;
// set base cost
@@ -79,11 +79,6 @@ public:
cost += Yapf().PfGetSettings().rail_crossing_penalty;
break;
- case MP_STATION:
- // penalty for passing station tiles
- cost += Yapf().PfGetSettings().rail_station_penalty;
- break;
-
default:
break;
}
@@ -178,7 +173,7 @@ public:
/** Called by YAPF to calculate the cost from the origin to the given node.
* Calculates only the cost of given node, adds it to the parent node cost
* and stores the result into Node::m_cost member */
- FORCEINLINE bool PfCalcCost(Node& n)
+ FORCEINLINE bool PfCalcCost(Node &n, const TrackFollower &tf)
{
assert(!n.flags_u.flags_s.m_targed_seen);
CPerfStart perf_cost(Yapf().m_perf_cost);
@@ -201,8 +196,13 @@ public:
bool target_seen = Yapf().PfDetectDestination(tile, trackdir);
+ if (tf.m_is_station) {
+ // station tiles have an extra penalty
+ segment_cost += Yapf().PfGetSettings().rail_station_penalty * (tf.m_tiles_skipped + 1);
+ }
+
while (true) {
- segment_cost += Yapf().OneTileCost(tile, trackdir);
+ segment_cost += Yapf().OneTileCost(prev_tile, tile, trackdir);
segment_cost += Yapf().CurveCost(prev_trackdir, trackdir);
segment_cost += Yapf().SlopeCost(tile, trackdir);
segment_cost += Yapf().SignalCost(n, tile, trackdir);