From 968a0e907c6567d447aa2905c6c21cf04b432e0f Mon Sep 17 00:00:00 2001 From: rubidium Date: Sat, 2 Aug 2008 22:51:23 +0000 Subject: (svn r13942) -Codechange [YAPP]: Add a penalty for double slips to YAPF. (michi_cc) --- src/yapf/yapf_costrail.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/yapf') 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) */ -- cgit v1.2.3-70-g09d2