summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2011-02-04 16:40:38 +0000
committerrubidium <rubidium@openttd.org>2011-02-04 16:40:38 +0000
commit0fe0225751c801015e8153ef8457c984312f3c72 (patch)
treec3deaa8e684b529a67bc161fb6a7105c59c0cc7d /src
parent773c6765e60e56db4c24c3150de52b18f084637d (diff)
downloadopenttd-0fe0225751c801015e8153ef8457c984312f3c72.tar.xz
(svn r21962) -Feature-ish: GUI setting to disable reversing at signals
Diffstat (limited to 'src')
-rw-r--r--src/lang/english.txt1
-rw-r--r--src/saveload/afterload.cpp10
-rw-r--r--src/saveload/saveload.cpp2
-rw-r--r--src/settings_gui.cpp1
-rw-r--r--src/settings_type.h1
-rw-r--r--src/table/settings.h1
-rw-r--r--src/train_cmd.cpp8
7 files changed, 19 insertions, 5 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index f33056147..bc2905064 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -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_NPF :NPF
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
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index 531db1d1d..a256087d2 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -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 */
AfterLoadRoadStops();
AfterLoadLabelMaps();
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index ec85aedaf..9d22150ad 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -223,7 +223,7 @@
* 156 21728
* 157 21862
* 158 21933
- * 159 21960
+ * 159 21962
*/
extern const uint16 SAVEGAME_VERSION = 159; ///< Current savegame version of OpenTTD.
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index d2367d33a..2d279269b 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -1449,6 +1449,7 @@ static SettingEntry _settings_vehicles_servicing[] = {
static SettingsPage _settings_vehicles_servicing_page = {_settings_vehicles_servicing, lengthof(_settings_vehicles_servicing)};
static SettingEntry _settings_vehicles_trains[] = {
+ SettingEntry("pf.reverse_at_signals"),
SettingEntry("vehicle.train_acceleration_model"),
SettingEntry("vehicle.train_slope_steepness"),
SettingEntry("vehicle.max_train_length"),
diff --git a/src/settings_type.h b/src/settings_type.h
index 6a1ad7fb3..e5738d686 100644
--- a/src/settings_type.h
+++ b/src/settings_type.h
@@ -313,6 +313,7 @@ struct PathfinderSettings {
bool roadveh_queue; ///< buggy road vehicle queueing
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_twoway_signal; ///< waitingtime in days before a twoway signal
diff --git a/src/table/settings.h b/src/table/settings.h
index 5f87f74ae..92129a832 100644
--- a/src/table/settings.h
+++ b/src/table/settings.h
@@ -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, 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_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),
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 139a7faa8..98f6aa5de 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -2990,12 +2990,12 @@ static void TrainController(Train *v, Vehicle *nomove)
v->cur_speed = 0;
v->subspeed = 0;
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)) {
v->cur_speed = 0;
v->subspeed = 0;
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);
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.
* This does not apply if the reason for reversing is a one-way
* 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) {
v->wait_counter = 0;
return;
@@ -3578,7 +3578,7 @@ static bool TrainLocoHandler(Train *v, bool mode)
++v->wait_counter;
/* 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 (!TryPathReserve(v)) {