diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index 7d1fa31ecb..03cd3b3c73 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -2197,7 +2197,8 @@ static bool AircraftEventHandler(Aircraft *v, int loop) ProcessOrders(v); if (v->current_order.IsType(OT_GOTO_STATION) && v->current_order.GetDestination() == station_id && - v->targetairport == station_id && IsAirportTile(v->tile) && GetStationIndex(v->tile) == station_id) { + v->targetairport == station_id && IsAirportTile(v->tile) && GetStationIndex(v->tile) == station_id && + Company::Get(v->owner)->settings.remain_if_next_order_same_station) { AircraftEntersTerminal(v); return true; } diff --git a/src/lang/extra/english.txt b/src/lang/extra/english.txt index 40cc5f8736..eec1701c4c 100644 --- a/src/lang/extra/english.txt +++ b/src/lang/extra/english.txt @@ -707,6 +707,9 @@ STR_CONFIG_SETTING_ADVANCE_ORDER_ON_CLONE_HELPTEXT :After cloning a STR_CONFIG_SETTING_COPY_CLONE_ADD_TO_GROUP :Add vehicle to group on copy-clone: {STRING2} STR_CONFIG_SETTING_COPY_CLONE_ADD_TO_GROUP_HELPTEXT :Set whether cloned vehicles which do not share orders are added to the copied vehicle's group. +STR_CONFIG_SETTING_REMAIN_IF_NEXT_ORDER_SAME_STATION :Remain in station if next order is for same station: {STRING2} +STR_CONFIG_SETTING_REMAIN_IF_NEXT_ORDER_SAME_STATION_HELPTEXT :If a vehicle's next order is for the same station it would be about to leave, start loading/unloading again instead of leaving. + STR_CONFIG_SETTING_SCENARIO_MULTIPLE_BUILDINGS :Allow multiple churches/stadiums: {STRING2} STR_CONFIG_SETTING_SCENARIO_MULTIPLE_BUILDINGS_HELPTEXT :Allow manually adding churches and stadiums when there is already one present in the town. diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index acf07a2136..40d1df9a80 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -1580,7 +1580,7 @@ inline byte IncreaseOvertakingCounter(RoadVehicle *v) static bool CheckRestartLoadingAtRoadStop(RoadVehicle *v) { - if (v->GetNumOrders() < 1) return false; + if (v->GetNumOrders() < 1 || !Company::Get(v->owner)->settings.remain_if_next_order_same_station) return false; StationID station_id = v->current_order.GetDestination(); VehicleOrderID next_order_idx = AdvanceOrderIndexDeferred(v, v->cur_implicit_order_index); diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index c213b76d8c..e70d5e3ce9 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -4139,6 +4139,13 @@ bool AfterLoadGame() } } + if (SlXvIsFeatureMissing(XSLFI_REMAIN_NEXT_ORDER_STATION)) { + for (Company *c : Company::Iterate()) { + /* Approximately the same time as when this was feature was added and unconditionally enabled */ + c->settings.remain_if_next_order_same_station = SlXvIsFeaturePresent(XSLFI_TRACE_RESTRICT_TUNBRIDGE); + } + } + InitializeRoadGUI(); /* This needs to be done after conversion. */ diff --git a/src/saveload/extended_ver_sl.cpp b/src/saveload/extended_ver_sl.cpp index 8896db5ee0..425fea2d7d 100644 --- a/src/saveload/extended_ver_sl.cpp +++ b/src/saveload/extended_ver_sl.cpp @@ -186,6 +186,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = { { XSLFI_NEWGRF_ENTITY_EXTRA, XSCF_NULL, 1, 1, "newgrf_entity_extra", nullptr, nullptr, nullptr }, { XSLFI_TNNC_CHUNK, XSCF_IGNORABLE_ALL, 0, 1, "tnnc_chunk", nullptr, nullptr, "TNNC" }, { XSLFI_MULTI_CARGO_SHIPS, XSCF_NULL, 1, 1, "multi_cargo_ships", nullptr, nullptr, nullptr }, + { XSLFI_REMAIN_NEXT_ORDER_STATION, XSCF_IGNORABLE_UNKNOWN, 1, 1, "remain_next_order_station", nullptr, nullptr, nullptr }, { XSLFI_SCRIPT_INT64, XSCF_NULL, 1, 1, "script_int64", nullptr, nullptr, nullptr }, { XSLFI_U64_TICK_COUNTER, XSCF_NULL, 1, 1, "u64_tick_counter", nullptr, nullptr, nullptr }, { XSLFI_LINKGRAPH_TRAVEL_TIME, XSCF_NULL, 1, 1, "linkgraph_travel_time", nullptr, nullptr, nullptr }, diff --git a/src/saveload/extended_ver_sl.h b/src/saveload/extended_ver_sl.h index 8e8f7d3ff5..955034154d 100644 --- a/src/saveload/extended_ver_sl.h +++ b/src/saveload/extended_ver_sl.h @@ -137,6 +137,7 @@ enum SlXvFeatureIndex { XSLFI_NEWGRF_ENTITY_EXTRA, ///< NewGRF entity mappings are 16 bit XSLFI_TNNC_CHUNK, ///< TNNC chunk XSLFI_MULTI_CARGO_SHIPS, ///< Multi-cargo ships + XSLFI_REMAIN_NEXT_ORDER_STATION, ///< Remain in station if next order is for same station XSLFI_SCRIPT_INT64, ///< See: SLV_SCRIPT_INT64 XSLFI_U64_TICK_COUNTER, ///< See: SLV_U64_TICK_COUNTER diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 5e93bdcd60..4a90b716cd 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -2043,6 +2043,7 @@ static SettingsContainer &GetSettingsTree() company->Add(new SettingEntry("company.infra_others_buy_in_depot[3]")); company->Add(new SettingEntry("company.advance_order_on_clone")); company->Add(new SettingEntry("company.copy_clone_add_to_group")); + company->Add(new SettingEntry("company.remain_if_next_order_same_station")); } SettingsPage *accounting = main->Add(new SettingsPage(STR_CONFIG_SETTING_ACCOUNTING)); diff --git a/src/settings_type.h b/src/settings_type.h index f8c2e150e8..e382361c72 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -768,6 +768,7 @@ struct CompanySettings { uint16 timetable_autofill_rounding; ///< round up timetable times to be a multiple of this number of ticks bool advance_order_on_clone; ///< when cloning a vehicle or copying/sharing an order list, advance the current order to a suitable point bool copy_clone_add_to_group; ///< whether to add cloned vehicles to the source vehicle's group, when cloning a vehicle without sharing orders + bool remain_if_next_order_same_station; ///< if the next order is for the same station, start loading/unloading again instead of leaving. byte old_simulated_wormhole_signals; ///< no longer needs a setting: tunnel/bridge signal simulation spacing }; diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index 500d1d9bbf..e82ff32d96 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -925,7 +925,8 @@ static void ShipController(Ship *v) bool may_reverse = ProcessOrders(v); - if (v->current_order.IsType(OT_GOTO_STATION) && v->current_order.GetDestination() == station_id && IsDockingTile(gp.new_tile)) { + if (v->current_order.IsType(OT_GOTO_STATION) && v->current_order.GetDestination() == station_id && + IsDockingTile(gp.new_tile) && Company::Get(v->owner)->settings.remain_if_next_order_same_station) { Station *st = Station::Get(station_id); if (st->facilities & FACIL_DOCK && st->docking_station.Contains(gp.new_tile) && IsShipDestinationTile(gp.new_tile, station_id)) { v->last_station_visited = station_id; diff --git a/src/table/settings/company_settings.ini b/src/table/settings/company_settings.ini index ed7aa64b70..8087d3d08f 100644 --- a/src/table/settings/company_settings.ini +++ b/src/table/settings/company_settings.ini @@ -253,6 +253,15 @@ str = STR_CONFIG_SETTING_COPY_CLONE_ADD_TO_GROUP strhelp = STR_CONFIG_SETTING_COPY_CLONE_ADD_TO_GROUP_HELPTEXT patxname = ""copy_clone_add_to_group"" +[SDT_BOOL] +base = CompanySettings +var = remain_if_next_order_same_station +flags = SF_PER_COMPANY +def = true +str = STR_CONFIG_SETTING_REMAIN_IF_NEXT_ORDER_SAME_STATION +strhelp = STR_CONFIG_SETTING_REMAIN_IF_NEXT_ORDER_SAME_STATION_HELPTEXT +patxname = ""remain_if_next_order_same_station"" + [SDT_VAR] base = CompanySettings var = old_simulated_wormhole_signals diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 130947140a..42d49032cd 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -6551,7 +6551,7 @@ static bool TrainLocoHandler(Train *v, bool mode) bool may_reverse = ProcessOrders(v); - if (IsRailStationTile(v->tile) && GetStationIndex(v->tile) == station_id) { + if (IsRailStationTile(v->tile) && GetStationIndex(v->tile) == station_id && Company::Get(v->owner)->settings.remain_if_next_order_same_station) { if (v->current_order.IsType(OT_GOTO_STATION) && v->current_order.GetDestination() == station_id && !(v->current_order.GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION)) { v->last_station_visited = station_id;