summaryrefslogtreecommitdiff
path: root/src/yapf
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-08-02 22:51:23 +0000
committerrubidium <rubidium@openttd.org>2008-08-02 22:51:23 +0000
commit968a0e907c6567d447aa2905c6c21cf04b432e0f (patch)
tree2f2a53054931bc9d6aed327ba48b1805e8aa268f /src/yapf
parent27cfb68d939d527dbe6c8c342539ed0cb355e95e (diff)
downloadopenttd-968a0e907c6567d447aa2905c6c21cf04b432e0f.tar.xz
(svn r13942) -Codechange [YAPP]: Add a penalty for double slips to YAPF. (michi_cc)
Diffstat (limited to 'src/yapf')
-rw-r--r--src/yapf/yapf_costrail.hpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/yapf/yapf_costrail.hpp b/src/yapf/yapf_costrail.hpp
index 7ff99bb60..f959f1a3e 100644
--- a/src/yapf/yapf_costrail.hpp
+++ b/src/yapf/yapf_costrail.hpp
@@ -105,6 +105,16 @@ public:
return cost;
}
+ FORCEINLINE int SwitchCost(TileIndex tile1, TileIndex tile2, DiagDirection exitdir)
+ {
+ if (IsTileType(tile1, MP_RAILWAY) && IsTileType(tile2, MP_RAILWAY)) {
+ bool t1 = KillFirstBit(GetTrackBits(tile1) & DiagdirReachesTracks(ReverseDiagDir(exitdir))) != TRACK_BIT_NONE;
+ bool t2 = KillFirstBit(GetTrackBits(tile2) & DiagdirReachesTracks(exitdir)) != TRACK_BIT_NONE;
+ if (t1 && t2) return Yapf().PfGetSettings().rail_doubleslip_penalty;
+ }
+ return 0;
+ }
+
/** Return one tile cost (base cost + level crossing penalty). */
FORCEINLINE int OneTileCost(TileIndex& tile, Trackdir trackdir)
{
@@ -305,6 +315,7 @@ public:
for (;;) {
/* Transition cost (cost of the move from previous tile) */
transition_cost = Yapf().CurveCost(prev.td, cur.td);
+ transition_cost += Yapf().SwitchCost(prev.tile, cur.tile, TrackdirToExitdir(prev.td));
/* First transition cost counts against segment entry cost, other transitions
* inside segment will come to segment cost (and will be cached) */