diff --git a/src/lang/english.txt b/src/lang/english.txt index be2595216c..81ffa02793 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -2021,6 +2021,9 @@ STR_CONFIG_OCCUPANCY_SMOOTHNESS_HELPTEXT :0% sets the mea STR_CONFIG_SETTING_ADVANCE_ORDER_ON_CLONE :Advance order after cloning/copying/sharing: {STRING2} STR_CONFIG_SETTING_ADVANCE_ORDER_ON_CLONE_HELPTEXT :After cloning a vehicle or copying/sharing orders from an existing vehicle.{}For trains, road vehicles and ships: if the vehicle is in a depot which is in the order list, skip to the order which follows one of the orders for that depot.{}For aircraft: if the aircraft is in a hangar and the associated airport is in the order list, skip to one of the orders for that airport. +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_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. STR_CONFIG_SETTING_SCENARIO_HOUSE_IGNORE_DATES :Ignore house year restrictions: {STRING2} diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 96c1c3ac48..6166b90dd5 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1790,6 +1790,7 @@ static SettingsContainer &GetSettingsTree() company->Add(new SettingEntry("company.infra_others_buy_in_depot[2]")); 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")); } SettingsPage *accounting = main->Add(new SettingsPage(STR_CONFIG_SETTING_ACCOUNTING)); diff --git a/src/settings_type.h b/src/settings_type.h index 030902c319..fc40867b52 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -660,6 +660,7 @@ struct CompanySettings { bool infra_others_buy_in_depot[4]; ///< other companies can buy/autorenew in this companies depots (where infra sharing enabled) 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 }; /** Debug settings. */ diff --git a/src/table/company_settings.ini b/src/table/company_settings.ini index 30ff023702..51dcf71ab2 100644 --- a/src/table/company_settings.ini +++ b/src/table/company_settings.ini @@ -246,6 +246,15 @@ str = STR_CONFIG_SETTING_ADVANCE_ORDER_ON_CLONE strhelp = STR_CONFIG_SETTING_ADVANCE_ORDER_ON_CLONE_HELPTEXT patxname = ""advance_order_on_clone"" +[SDT_BOOL] +base = CompanySettings +var = copy_clone_add_to_group +guiflags = SGF_PER_COMPANY +def = true +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_END] diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp index 68bf04d3f9..865c2445d1 100644 --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -1462,7 +1462,8 @@ CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint _new_vehicle_id = w_front->index; } - if (flags & DC_EXEC) { + const Company *owner = Company::GetIfValid(_current_company); + if ((flags & DC_EXEC) && ((p2 & 1) || owner == nullptr || owner->settings.copy_clone_add_to_group)) { /* Cloned vehicles belong to the same group */ DoCommand(0, v_front->group_id, w_front->index, flags, CMD_ADD_VEHICLE_GROUP); }