From cc6be16422f1c69dcbb5025809e37c8017906094 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sat, 29 Aug 2020 13:31:52 +0100 Subject: [PATCH] Add news setting for trains waiting due to routing restrictions --- src/lang/english.txt | 2 ++ src/settings_gui.cpp | 1 + src/settings_type.h | 1 + src/table/settings.ini | 7 +++++++ src/train_cmd.cpp | 2 +- 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/lang/english.txt b/src/lang/english.txt index 076b1b459d..0baff9a6dd 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1315,6 +1315,8 @@ STR_CONFIG_SETTING_NEVER_EXPIRE_AIRPORTS_HELPTEXT :Enabling this s STR_CONFIG_SETTING_WARN_LOST_VEHICLE :Warn if vehicle is lost: {STRING2} STR_CONFIG_SETTING_WARN_LOST_VEHICLE_HELPTEXT :Trigger messages about vehicles unable to find a path to their ordered destination +STR_CONFIG_SETTING_WARN_RESTRICTION_WAIT_VEHICLE :Warn if train is stuck due to a routing restriction: {STRING2} +STR_CONFIG_SETTING_WARN_RESTRICTION_WAIT_VEHICLE_HELPTEXT :Trigger messages about trains which are stuck waiting at a PBS signal for a long time because of a routing restriction STR_CONFIG_SETTING_ORDER_REVIEW :Review vehicles' orders: {STRING2} STR_CONFIG_SETTING_ORDER_REVIEW_HELPTEXT :When enabled, the orders of the vehicles are periodically checked, and some obvious issues are reported with a news message when detected STR_CONFIG_SETTING_ORDER_REVIEW_OFF :No diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 56815b34f9..086d5528ad 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1751,6 +1751,7 @@ static SettingsContainer &GetSettingsTree() advisors->Add(new SettingEntry("gui.no_depot_order_warn")); advisors->Add(new SettingEntry("gui.vehicle_income_warn")); advisors->Add(new SettingEntry("gui.lost_vehicle_warn")); + advisors->Add(new SettingEntry("gui.restriction_wait_vehicle_warn")); advisors->Add(new SettingEntry("gui.show_finances")); advisors->Add(new SettingEntry("news_display.economy")); advisors->Add(new SettingEntry("news_display.subsidies")); diff --git a/src/settings_type.h b/src/settings_type.h index c544f6d553..be6b15ea85 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -90,6 +90,7 @@ struct TimeSettings { struct GUISettings : public TimeSettings { bool sg_full_load_any; ///< new full load calculation, any cargo must be full read from pre v93 savegames bool lost_vehicle_warn; ///< if a vehicle can't find its destination, show a warning + bool restriction_wait_vehicle_warn; ///< if a vehicle is waiting for an extended time due to a routing restriction, show a warning uint8 order_review_system; ///< perform order reviews on vehicles bool no_depot_order_warn; ///< if a non-air vehicle doesn't have at least one depot order, show a warning bool vehicle_income_warn; ///< if a vehicle isn't generating income, show a warning diff --git a/src/table/settings.ini b/src/table/settings.ini index d855965f1a..6d1ffbfaa3 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -4604,6 +4604,13 @@ def = true str = STR_CONFIG_SETTING_WARN_LOST_VEHICLE strhelp = STR_CONFIG_SETTING_WARN_LOST_VEHICLE_HELPTEXT +[SDTC_BOOL] +var = gui.restriction_wait_vehicle_warn +flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC +def = false +str = STR_CONFIG_SETTING_WARN_RESTRICTION_WAIT_VEHICLE +strhelp = STR_CONFIG_SETTING_WARN_RESTRICTION_WAIT_VEHICLE_HELPTEXT + [SDTC_BOOL] var = gui.disable_unsuitable_building flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 674c403b31..5ee850fd7d 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -4987,7 +4987,7 @@ static bool TrainLocoHandler(Train *v, bool mode) if (HasBit(v->flags, VRF_TRAIN_STUCK) && v->wait_counter > 2 * _settings_game.pf.wait_for_pbs_path * DAY_TICKS) { /* Show message to player. */ - if (_settings_client.gui.lost_vehicle_warn && v->owner == _local_company) { + if (v->owner == _local_company && (HasBit(v->flags, VRF_WAITING_RESTRICTION) ? _settings_client.gui.restriction_wait_vehicle_warn : _settings_client.gui.lost_vehicle_warn)) { SetDParam(0, v->index); AddVehicleAdviceNewsItem(STR_NEWS_TRAIN_IS_STUCK, v->index); }