Mercurial > hg > openttd
changeset 12176:3e420ecefa97 draft bridge_penalty
-Feature(ette) [YAPF]: Add a configurable penalty for bridge speeds.
author | Michael Lutz <michi@icosahedron.de> |
---|---|
date | Tue, 30 Dec 2008 14:27:16 +0100 |
parents | a8461c552ea5 |
children | |
files | src/saveload/saveload.cpp src/settings_type.h src/table/settings.h src/yapf/follow_track.hpp src/yapf/yapf_costrail.hpp |
diffstat | 5 files changed, 10 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -40,7 +40,7 @@ #include "saveload_internal.h" -extern const uint16 SAVEGAME_VERSION = 120; +extern const uint16 SAVEGAME_VERSION = 121; SavegameType _savegame_type; ///< type of savegame we are loading
--- a/src/settings_type.h +++ b/src/settings_type.h @@ -243,6 +243,8 @@ 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)
--- a/src/table/settings.h +++ b/src/table/settings.h @@ -483,6 +483,8 @@ 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,121, 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,121, 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),
--- a/src/yapf/follow_track.hpp +++ b/src/yapf/follow_track.hpp @@ -414,7 +414,6 @@ /** 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 */ @@ -424,8 +423,9 @@ 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; } };
--- a/src/yapf/yapf_costrail.hpp +++ b/src/yapf/yapf_costrail.hpp @@ -423,10 +423,10 @@ 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); } }