From af64b5dc18d39766fcc6c53b44a82d16fb260318 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sat, 11 May 2019 19:58:16 +0100 Subject: [PATCH] Add news/advice setting to warn if no depot order in vehicle schedule --- src/lang/english.txt | 3 +++ src/order_cmd.cpp | 7 +++++++ src/settings_gui.cpp | 1 + src/settings_type.h | 1 + src/table/settings.ini | 7 +++++++ 5 files changed, 19 insertions(+) diff --git a/src/lang/english.txt b/src/lang/english.txt index 7067faa9b8..e6fe5aebf3 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -858,6 +858,7 @@ STR_NEWS_VEHICLE_HAS_TOO_FEW_ORDERS :{WHITE}{VEHICLE STR_NEWS_VEHICLE_HAS_VOID_ORDER :{WHITE}{VEHICLE} has a void order STR_NEWS_VEHICLE_HAS_DUPLICATE_ENTRY :{WHITE}{VEHICLE} has duplicate orders STR_NEWS_VEHICLE_HAS_INVALID_ENTRY :{WHITE}{VEHICLE} has an invalid station in its orders +STR_NEWS_VEHICLE_NO_DEPOT_ORDER :{WHITE}{VEHICLE} does not have a depot order in its schedule STR_NEWS_PLANE_USES_TOO_SHORT_RUNWAY :{WHITE}{VEHICLE} has in its orders an airport whose runway is too short STR_NEWS_VEHICLE_IS_GETTING_OLD :{WHITE}{VEHICLE} is getting old @@ -1311,6 +1312,8 @@ STR_CONFIG_SETTING_ORDER_REVIEW_HELPTEXT :When enabled, t STR_CONFIG_SETTING_ORDER_REVIEW_OFF :No STR_CONFIG_SETTING_ORDER_REVIEW_EXDEPOT :Yes, but exclude stopped vehicles STR_CONFIG_SETTING_ORDER_REVIEW_ON :Of all vehicles +STR_CONFIG_SETTING_WARN_NO_DEPOT_ORDER :Warn if a vehicle does not have a depot order in its schedule: {STRING2} +STR_CONFIG_SETTING_WARN_NO_DEPOT_ORDER_HELPTEXT :When enabled and when reviewing vehicle orders is also enabled, a news message gets sent when a train, road vehicle or ship does not have a depot order in its schedule STR_CONFIG_SETTING_WARN_INCOME_LESS :Warn if a vehicle's income is negative: {STRING2} STR_CONFIG_SETTING_WARN_INCOME_LESS_HELPTEXT :When enabled, a news message gets sent when a vehicle has not made any profit within a calendar year STR_CONFIG_SETTING_NEVER_EXPIRE_VEHICLES :Vehicles never expire: {STRING2} diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index 2aa18693cd..43f53a3c0c 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -827,6 +827,7 @@ static void DeleteOrderWarnings(const Vehicle *v) DeleteVehicleNews(v->index, STR_NEWS_VEHICLE_HAS_VOID_ORDER); DeleteVehicleNews(v->index, STR_NEWS_VEHICLE_HAS_DUPLICATE_ENTRY); DeleteVehicleNews(v->index, STR_NEWS_VEHICLE_HAS_INVALID_ENTRY); + DeleteVehicleNews(v->index, STR_NEWS_VEHICLE_NO_DEPOT_ORDER); DeleteVehicleNews(v->index, STR_NEWS_PLANE_USES_TOO_SHORT_RUNWAY); } @@ -2205,6 +2206,7 @@ void CheckOrders(const Vehicle *v) /* Check the order list */ int n_st = 0; + bool has_depot_order = false; FOR_VEHICLE_ORDERS(v, order) { /* Dummy order? */ @@ -2227,6 +2229,9 @@ void CheckOrders(const Vehicle *v) message = STR_NEWS_PLANE_USES_TOO_SHORT_RUNWAY; } } + if (order->IsType(OT_GOTO_DEPOT)) { + has_depot_order = true; + } } /* Check if the last and the first order are the same */ @@ -2245,6 +2250,8 @@ void CheckOrders(const Vehicle *v) if (v->orders.list != nullptr) v->orders.list->DebugCheckSanity(); #endif + if (message == INVALID_STRING_ID && !has_depot_order && v->type != VEH_AIRCRAFT && _settings_client.gui.no_depot_order_warn) message = STR_NEWS_VEHICLE_NO_DEPOT_ORDER; + /* We don't have a problem */ if (message == INVALID_STRING_ID) return; diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 24fe154c61..effb0f7bd8 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1722,6 +1722,7 @@ static SettingsContainer &GetSettingsTree() advisors->Add(new SettingEntry("news_display.arrival_other")); advisors->Add(new SettingEntry("news_display.advice")); advisors->Add(new SettingEntry("gui.order_review_system")); + 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.show_finances")); diff --git a/src/settings_type.h b/src/settings_type.h index fee6de8853..76a95c6625 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -85,6 +85,7 @@ struct GUISettings { 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 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 bool show_finances; ///< show finances at end of year bool sg_new_nonstop; ///< ttdpatch compatible nonstop handling read from pre v93 savegames diff --git a/src/table/settings.ini b/src/table/settings.ini index d455c38083..bd4effbea2 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -4133,6 +4133,13 @@ strhelp = STR_CONFIG_SETTING_ORDER_REVIEW_HELPTEXT strval = STR_CONFIG_SETTING_ORDER_REVIEW_OFF cat = SC_BASIC +[SDTC_BOOL] +var = gui.no_depot_order_warn +flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC +def = false +str = STR_CONFIG_SETTING_WARN_NO_DEPOT_ORDER +strhelp = STR_CONFIG_SETTING_WARN_NO_DEPOT_ORDER_HELPTEXT + [SDTC_BOOL] var = gui.lost_vehicle_warn flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC