(svn r21962) -Feature-ish: GUI setting to disable reversing at signals

This commit is contained in:
rubidium 2011-02-04 16:40:38 +00:00
parent 773c6765e6
commit 0fe0225751
7 changed files with 19 additions and 5 deletions

View File

@ -1356,6 +1356,7 @@ STR_CONFIG_SETTING_PATHFINDER_FOR_SHIPS :{LTBLUE}Pathfin
STR_CONFIG_SETTING_PATHFINDER_FOR_SHIPS_OPF :Original {BLUE}(Recommended) STR_CONFIG_SETTING_PATHFINDER_FOR_SHIPS_OPF :Original {BLUE}(Recommended)
STR_CONFIG_SETTING_PATHFINDER_FOR_SHIPS_NPF :NPF STR_CONFIG_SETTING_PATHFINDER_FOR_SHIPS_NPF :NPF
STR_CONFIG_SETTING_PATHFINDER_FOR_SHIPS_YAPF :YAPF {RED}(Not recommended) STR_CONFIG_SETTING_PATHFINDER_FOR_SHIPS_YAPF :YAPF {RED}(Not recommended)
STR_CONFIG_SETTING_REVERSE_AT_SIGNALS :{LTBLUE}Automatic reversing at signals: {ORANGE}{STRING1}
STR_CONFIG_SETTING_QUERY_CAPTION :{WHITE}Change setting value STR_CONFIG_SETTING_QUERY_CAPTION :{WHITE}Change setting value

View File

@ -2551,6 +2551,16 @@ bool AfterLoadGame()
} }
} }
if (IsSavegameVersionBefore(159)) {
/* If the savegame is old (before version 100), then the value of 255
* for these settings did not mean "disabled". As such everything
* before then did reverse.
* To simplify stuff we disable all turning around or we do not
* disable anything at all. So, if some reversing was disabled we
* will keep reversing disabled, otherwise it'll be turned on. */
_settings_game.pf.reverse_at_signals = IsSavegameVersionBefore(100) || (_settings_game.pf.wait_oneway_signal != 255 && _settings_game.pf.wait_twoway_signal != 255 && _settings_game.pf.wait_for_pbs_path != 255);
}
/* Road stops is 'only' updating some caches */ /* Road stops is 'only' updating some caches */
AfterLoadRoadStops(); AfterLoadRoadStops();
AfterLoadLabelMaps(); AfterLoadLabelMaps();

View File

@ -223,7 +223,7 @@
* 156 21728 * 156 21728
* 157 21862 * 157 21862
* 158 21933 * 158 21933
* 159 21960 * 159 21962
*/ */
extern const uint16 SAVEGAME_VERSION = 159; ///< Current savegame version of OpenTTD. extern const uint16 SAVEGAME_VERSION = 159; ///< Current savegame version of OpenTTD.

View File

@ -1449,6 +1449,7 @@ static SettingEntry _settings_vehicles_servicing[] = {
static SettingsPage _settings_vehicles_servicing_page = {_settings_vehicles_servicing, lengthof(_settings_vehicles_servicing)}; static SettingsPage _settings_vehicles_servicing_page = {_settings_vehicles_servicing, lengthof(_settings_vehicles_servicing)};
static SettingEntry _settings_vehicles_trains[] = { static SettingEntry _settings_vehicles_trains[] = {
SettingEntry("pf.reverse_at_signals"),
SettingEntry("vehicle.train_acceleration_model"), SettingEntry("vehicle.train_acceleration_model"),
SettingEntry("vehicle.train_slope_steepness"), SettingEntry("vehicle.train_slope_steepness"),
SettingEntry("vehicle.max_train_length"), SettingEntry("vehicle.max_train_length"),

View File

@ -313,6 +313,7 @@ struct PathfinderSettings {
bool roadveh_queue; ///< buggy road vehicle queueing bool roadveh_queue; ///< buggy road vehicle queueing
bool forbid_90_deg; ///< forbid trains to make 90 deg turns bool forbid_90_deg; ///< forbid trains to make 90 deg turns
bool reverse_at_signals; ///< whether to reverse at signals at all
byte wait_oneway_signal; ///< waitingtime in days before a oneway signal byte wait_oneway_signal; ///< waitingtime in days before a oneway signal
byte wait_twoway_signal; ///< waitingtime in days before a twoway signal byte wait_twoway_signal; ///< waitingtime in days before a twoway signal

View File

@ -473,6 +473,7 @@ const SettingDesc _settings[] = {
SDT_VAR(GameSettings, vehicle.extend_vehicle_life, SLE_UINT8, 0, 0, 0, 0, 100, 0, STR_NULL, NULL), SDT_VAR(GameSettings, vehicle.extend_vehicle_life, SLE_UINT8, 0, 0, 0, 0, 100, 0, STR_NULL, NULL),
SDT_VAR(GameSettings, economy.dist_local_authority, SLE_UINT8, 0, 0, 20, 5, 60, 0, STR_NULL, NULL), SDT_VAR(GameSettings, economy.dist_local_authority, SLE_UINT8, 0, 0, 20, 5, 60, 0, STR_NULL, NULL),
SDT_CONDBOOL(GameSettings, pf.reverse_at_signals, 159, SL_MAX_VERSION, 0, 0, false, STR_CONFIG_SETTING_REVERSE_AT_SIGNALS, NULL),
SDT_VAR(GameSettings, pf.wait_oneway_signal, SLE_UINT8, 0, 0, 15, 2, 255, 0, STR_NULL, NULL), SDT_VAR(GameSettings, pf.wait_oneway_signal, SLE_UINT8, 0, 0, 15, 2, 255, 0, STR_NULL, NULL),
SDT_VAR(GameSettings, pf.wait_twoway_signal, SLE_UINT8, 0, 0, 41, 2, 255, 0, STR_NULL, NULL), SDT_VAR(GameSettings, pf.wait_twoway_signal, SLE_UINT8, 0, 0, 41, 2, 255, 0, STR_NULL, NULL),
SDT_CONDVAR(GameSettings, economy.town_noise_population[0], SLE_UINT16, 96, SL_MAX_VERSION, 0, 0, 800, 200, 65535, 0, STR_NULL, NULL), SDT_CONDVAR(GameSettings, economy.town_noise_population[0], SLE_UINT16, 96, SL_MAX_VERSION, 0, 0, 800, 200, 65535, 0, STR_NULL, NULL),

View File

@ -2990,12 +2990,12 @@ static void TrainController(Train *v, Vehicle *nomove)
v->cur_speed = 0; v->cur_speed = 0;
v->subspeed = 0; v->subspeed = 0;
v->progress = 255 - 100; v->progress = 255 - 100;
if (_settings_game.pf.wait_oneway_signal == 255 || ++v->wait_counter < _settings_game.pf.wait_oneway_signal * 20) return; if (!_settings_game.pf.reverse_at_signals || ++v->wait_counter < _settings_game.pf.wait_oneway_signal * 20) return;
} else if (HasSignalOnTrackdir(gp.new_tile, i)) { } else if (HasSignalOnTrackdir(gp.new_tile, i)) {
v->cur_speed = 0; v->cur_speed = 0;
v->subspeed = 0; v->subspeed = 0;
v->progress = 255 - 10; v->progress = 255 - 10;
if (_settings_game.pf.wait_twoway_signal == 255 || ++v->wait_counter < _settings_game.pf.wait_twoway_signal * 73) { if (!_settings_game.pf.reverse_at_signals || ++v->wait_counter < _settings_game.pf.wait_twoway_signal * 73) {
DiagDirection exitdir = TrackdirToExitdir(i); DiagDirection exitdir = TrackdirToExitdir(i);
TileIndex o_tile = TileAddByDiagDir(gp.new_tile, exitdir); TileIndex o_tile = TileAddByDiagDir(gp.new_tile, exitdir);
@ -3010,7 +3010,7 @@ static void TrainController(Train *v, Vehicle *nomove)
* reversing of stuck trains is disabled, don't reverse. * reversing of stuck trains is disabled, don't reverse.
* This does not apply if the reason for reversing is a one-way * This does not apply if the reason for reversing is a one-way
* signal blocking us, because a train would then be stuck forever. */ * signal blocking us, because a train would then be stuck forever. */
if (_settings_game.pf.wait_for_pbs_path == 255 && !HasOnewaySignalBlockingTrackdir(gp.new_tile, i) && if (!_settings_game.pf.reverse_at_signals && !HasOnewaySignalBlockingTrackdir(gp.new_tile, i) &&
UpdateSignalsOnSegment(v->tile, enterdir, v->owner) == SIGSEG_PBS) { UpdateSignalsOnSegment(v->tile, enterdir, v->owner) == SIGSEG_PBS) {
v->wait_counter = 0; v->wait_counter = 0;
return; return;
@ -3578,7 +3578,7 @@ static bool TrainLocoHandler(Train *v, bool mode)
++v->wait_counter; ++v->wait_counter;
/* Should we try reversing this tick if still stuck? */ /* Should we try reversing this tick if still stuck? */
bool turn_around = v->wait_counter % (_settings_game.pf.wait_for_pbs_path * DAY_TICKS) == 0 && _settings_game.pf.wait_for_pbs_path < 255; bool turn_around = v->wait_counter % (_settings_game.pf.wait_for_pbs_path * DAY_TICKS) == 0 && _settings_game.pf.reverse_at_signals;
if (!turn_around && v->wait_counter % _settings_game.pf.path_backoff_interval != 0 && v->force_proceed == TFP_NONE) return true; if (!turn_around && v->wait_counter % _settings_game.pf.path_backoff_interval != 0 && v->force_proceed == TFP_NONE) return true;
if (!TryPathReserve(v)) { if (!TryPathReserve(v)) {