From ef4687895e280d34fdb549554d8653ad5c4de623 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Thu, 11 Dec 2025 11:28:04 +0000 Subject: [PATCH] Add: Setting to control minimum distance between towns. (#14893) Backported from JGRPP. --- src/lang/english.txt | 2 ++ src/settingentry_gui.cpp | 1 + src/settings_type.h | 1 + src/table/settings/economy_settings.ini | 11 +++++++++++ src/town_cmd.cpp | 2 +- 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/lang/english.txt b/src/lang/english.txt index b72538af7f..7cb7e9f2a8 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -2092,6 +2092,8 @@ STR_CONFIG_SETTING_LARGER_TOWNS_VALUE :1 in {COMMA} STR_CONFIG_SETTING_LARGER_TOWNS_DISABLED :None STR_CONFIG_SETTING_CITY_SIZE_MULTIPLIER :Initial city size multiplier: {STRING2} STR_CONFIG_SETTING_CITY_SIZE_MULTIPLIER_HELPTEXT :Average size of cities relative to normal towns at start of the game +STR_CONFIG_SETTING_TOWN_MIN_DISTANCE :Minimum distance between towns: {STRING2} +STR_CONFIG_SETTING_TOWN_MIN_DISTANCE_HELPTEXT :Set the minimum distance in tiles between towns for map generation and random founding STR_CONFIG_SETTING_LINKGRAPH_RECALC_INTERVAL :Update distribution graph every {STRING2} STR_CONFIG_SETTING_LINKGRAPH_RECALC_INTERVAL_HELPTEXT :Time between subsequent recalculations of the link graph. Each recalculation calculates the plans for one component of the graph. That means that a value X for this setting does not mean the whole graph will be updated every X seconds. Only some component will. The shorter you set it the more CPU time will be necessary to calculate it. The longer you set it the longer it will take until the cargo distribution starts on new routes diff --git a/src/settingentry_gui.cpp b/src/settingentry_gui.cpp index a266a10f82..031fb1989f 100644 --- a/src/settingentry_gui.cpp +++ b/src/settingentry_gui.cpp @@ -881,6 +881,7 @@ SettingsContainer &GetSettingsTree() towns->Add(new SettingEntry("economy.town_layout")); towns->Add(new SettingEntry("economy.larger_towns")); towns->Add(new SettingEntry("economy.initial_city_size")); + towns->Add(new SettingEntry("economy.town_min_distance")); towns->Add(new SettingEntry("economy.town_cargogen_mode")); } diff --git a/src/settings_type.h b/src/settings_type.h index 7a07d0d6ea..68b6da1d90 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -565,6 +565,7 @@ struct EconomySettings { uint16_t minutes_per_calendar_year; ///< minutes per calendar year. Special value 0 means that calendar time is frozen. uint16_t town_cargo_scale; ///< scale cargo production of towns by this percentage. uint16_t industry_cargo_scale; ///< scale cargo production of industries by this percentage. + uint16_t town_min_distance; ///< minimum distance between towns. }; struct LinkGraphSettings { diff --git a/src/table/settings/economy_settings.ini b/src/table/settings/economy_settings.ini index de10a04f56..c0c691bb34 100644 --- a/src/table/settings/economy_settings.ini +++ b/src/table/settings/economy_settings.ini @@ -249,6 +249,17 @@ str = STR_CONFIG_SETTING_CITY_SIZE_MULTIPLIER strhelp = STR_CONFIG_SETTING_CITY_SIZE_MULTIPLIER_HELPTEXT strval = STR_JUST_COMMA +[SDT_VAR] +var = economy.town_min_distance +type = SLE_UINT16 +def = 20 +min = 10 +max = 500 +interval = 5 +str = STR_CONFIG_SETTING_TOWN_MIN_DISTANCE +strhelp = STR_CONFIG_SETTING_TOWN_MIN_DISTANCE_HELPTEXT +strval = STR_JUST_INT + [SDT_BOOL] var = economy.mod_road_rebuild from = SLV_77 diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 13d0a8b215..8ca345d540 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -2124,7 +2124,7 @@ static CommandCost TownCanBePlacedHere(TileIndex tile, bool check_surrounding) } /* Check distance to all other towns. */ - if (IsCloseToTown(tile, 20)) { + if (IsCloseToTown(tile, _settings_game.economy.town_min_distance)) { return CommandCost(STR_ERROR_TOO_CLOSE_TO_ANOTHER_TOWN); }