From c3671662b69185e19a7a39a289cb34caf4e1269a Mon Sep 17 00:00:00 2001 From: Michael Lutz Date: Sun, 21 Dec 2008 00:02:25 +0100 Subject: -Feature(ette) [YAPF]: Add a configurable penalty for bridge speeds. --- src/saveload.cpp | 2 +- src/settings.cpp | 2 ++ src/settings_type.h | 2 ++ src/yapf/follow_track.hpp | 6 +++--- src/yapf/yapf_costrail.hpp | 4 ++-- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/saveload.cpp b/src/saveload.cpp index a01d813..ce11d38 100644 --- a/src/saveload.cpp +++ b/src/saveload.cpp @@ -37,7 +37,7 @@ #include "table/strings.h" -extern const uint16 SAVEGAME_VERSION = 103; +extern const uint16 SAVEGAME_VERSION = 104; SavegameType _savegame_type; ///< type of savegame we are loading diff --git a/src/settings.cpp b/src/settings.cpp index fbcf2cc..d288634 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1391,6 +1391,8 @@ const SettingDesc _patch_settings[] = { SDT_CONDVAR(GameSettings, pf.yapf.rail_pbs_station_penalty, SLE_UINT,100, SL_MAX_VERSION, 0, 0, 8 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL), SDT_CONDVAR(GameSettings, pf.yapf.rail_pbs_signal_back_penalty, SLE_UINT,100, SL_MAX_VERSION, 0, 0, 15 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL), SDT_CONDVAR(GameSettings, pf.yapf.rail_doubleslip_penalty, SLE_UINT,100, SL_MAX_VERSION, 0, 0, 1 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL), + SDT_CONDVAR(GameSettings, pf.yapf.rail_speed_lower_factor, SLE_UINT,104, SL_MAX_VERSION, 0, 0, 1 * YAPF_TILE_LENGTH, 0, 100000, 0, STR_NULL, NULL), + SDT_CONDVAR(GameSettings, pf.yapf.rail_speed_higher_factor, SLE_UINT,104, SL_MAX_VERSION, 0, 0, 1 * YAPF_TILE_LENGTH, 0, 100000, 0, STR_NULL, NULL), SDT_CONDVAR(GameSettings, pf.yapf.rail_longer_platform_penalty, SLE_UINT, 33, SL_MAX_VERSION, 0, 0, 8 * YAPF_TILE_LENGTH, 0, 20000, 0, STR_NULL, NULL), SDT_CONDVAR(GameSettings, pf.yapf.rail_longer_platform_per_tile_penalty, SLE_UINT, 33, SL_MAX_VERSION, 0, 0, 0 * YAPF_TILE_LENGTH, 0, 20000, 0, STR_NULL, NULL), SDT_CONDVAR(GameSettings, pf.yapf.rail_shorter_platform_penalty, SLE_UINT, 33, SL_MAX_VERSION, 0, 0, 40 * YAPF_TILE_LENGTH, 0, 20000, 0, STR_NULL, NULL), diff --git a/src/settings_type.h b/src/settings_type.h index adef059..dcdb44d 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -231,6 +231,8 @@ struct YAPFSettings { uint32 rail_pbs_station_penalty; ///< penalty for crossing a reserved station tile uint32 rail_pbs_signal_back_penalty; ///< penalty for passing a pbs signal from the backside uint32 rail_doubleslip_penalty; ///< penalty for passing a double slip switch + uint32 rail_speed_lower_factor; ///< penalty factor for rail speed lower than vehicle speed + uint32 rail_speed_higher_factor; ///< penalty factor for rail speed higher than vehicle speed uint32 rail_longer_platform_penalty; ///< penalty for longer station platform than train uint32 rail_longer_platform_per_tile_penalty; ///< penalty for longer station platform than train (per tile) diff --git a/src/yapf/follow_track.hpp b/src/yapf/follow_track.hpp index e990424..3b47806 100644 --- a/src/yapf/follow_track.hpp +++ b/src/yapf/follow_track.hpp @@ -412,7 +412,6 @@ public: /** Helper for pathfinders - get min/max speed on the m_old_tile/m_old_td */ int GetSpeedLimit(int *pmin_speed = NULL) const { - int min_speed = 0; int max_speed = INT_MAX; // no limit // for now we handle only on-bridge speed limit @@ -422,8 +421,9 @@ public: if (max_speed > spd) max_speed = spd; } - // if min speed was requested, return it - if (pmin_speed) *pmin_speed = min_speed; + /* If min speed was requested, return it. + * The minium speed is currently just the maximum speed as well. */ + if (pmin_speed) *pmin_speed = max_speed; return max_speed; } }; diff --git a/src/yapf/yapf_costrail.hpp b/src/yapf/yapf_costrail.hpp index e7e301d..6e999c9 100644 --- a/src/yapf/yapf_costrail.hpp +++ b/src/yapf/yapf_costrail.hpp @@ -413,9 +413,9 @@ no_entry_cost: // jump here at the beginning if the node has no parent (it is th int min_speed = 0; int max_speed = tf->GetSpeedLimit(&min_speed); if (max_speed < v->max_speed) - extra_cost += YAPF_TILE_LENGTH * (v->max_speed - max_speed) * (4 + tf->m_tiles_skipped) / v->max_speed; + extra_cost += Yapf().PfGetSettings().rail_speed_lower_factor * (v->max_speed - max_speed) * (4 + tf->m_tiles_skipped) / v->max_speed; if (min_speed > v->max_speed) - extra_cost += YAPF_TILE_LENGTH * (min_speed - v->max_speed); + extra_cost += Yapf().PfGetSettings().rail_speed_higher_factor * (min_speed - v->max_speed); } /* Finish if we already exceeded the maximum path cost (i.e. when -- 1.6.0.4