summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/genworld_gui.cpp12
-rw-r--r--src/lang/english.txt2
-rw-r--r--src/saveload/saveload.cpp2
-rw-r--r--src/settings.cpp3
-rw-r--r--src/settings_type.h1
-rw-r--r--src/town.h3
-rw-r--r--src/town_cmd.cpp3
7 files changed, 21 insertions, 5 deletions
diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp
index 49b8bc633..fd9346c8f 100644
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -25,6 +25,7 @@
#include "core/random_func.hpp"
#include "landscape_type.h"
#include "querystring_gui.h"
+#include "town.h"
#include "table/strings.h"
#include "table/sprites.h"
@@ -285,7 +286,7 @@ static const StringID _smoothness[] = {STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_
static const StringID _tree_placer[] = {STR_CONFIG_SETTING_TREE_PLACER_NONE, STR_CONFIG_SETTING_TREE_PLACER_ORIGINAL, STR_CONFIG_SETTING_TREE_PLACER_IMPROVED, INVALID_STRING_ID};
static const StringID _rotation[] = {STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_COUNTER_CLOCKWISE, STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_CLOCKWISE, INVALID_STRING_ID};
static const StringID _landscape[] = {STR_CONFIG_SETTING_LAND_GENERATOR_ORIGINAL, STR_CONFIG_SETTING_LAND_GENERATOR_TERRA_GENESIS, INVALID_STRING_ID};
-static const StringID _num_towns[] = {STR_NUM_VERY_LOW, STR_6816_LOW, STR_6817_NORMAL, STR_6818_HIGH, INVALID_STRING_ID};
+static const StringID _num_towns[] = {STR_NUM_VERY_LOW, STR_6816_LOW, STR_6817_NORMAL, STR_6818_HIGH, STR_02BF_CUSTOM, INVALID_STRING_ID};
static const StringID _num_inds[] = {STR_NONE, STR_NUM_VERY_LOW, STR_6816_LOW, STR_6817_NORMAL, STR_6818_HIGH, INVALID_STRING_ID};
struct GenerateLandscapeWindow : public QueryStringBaseWindow {
@@ -571,6 +572,11 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
case GLAND_SMOOTHNESS_PULLDOWN: _settings_newgame.game_creation.tgen_smoothness = index; break;
case GLAND_TOWN_PULLDOWN:
+ if (index == CUSTOM_TOWN_NUMBER_DIFFICULTY) {
+ this->widget_id = widget;
+ SetDParam(0, _settings_newgame.game_creation.custom_town_number);
+ ShowQueryString(STR_CONFIG_SETTING_INT32, STR_NUMBER_OF_TOWNS, 5, 50, this, CS_NUMERAL, QSF_NONE);
+ };
IConsoleSetSetting("difficulty.number_towns", index);
break;
@@ -621,6 +627,10 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
this->InvalidateWidget(GLAND_SNOW_LEVEL_TEXT);
_settings_newgame.game_creation.snow_line_height = Clamp(value, 2, MAX_SNOWLINE_HEIGHT);
break;
+
+ case GLAND_TOWN_PULLDOWN:
+ _settings_newgame.game_creation.custom_town_number = Clamp(value, 1, CUSTOM_TOWN_MAX_NUMBER);
+ break;
}
this->SetDirty();
diff --git a/src/lang/english.txt b/src/lang/english.txt
index f5075d9a9..0519d74fe 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -666,7 +666,6 @@ STR_FULL :Full
STR_02BA :{SILVER}- - {COMPANY} - -
STR_02BB_TOWN_DIRECTORY :Town directory
STR_02BD :{BLACK}{STRING}
-STR_02BF_CUSTOM :Custom
STR_CHECKMARK :{CHECKMARK}
############ range for menu starts
@@ -2129,6 +2128,7 @@ STR_NUM_VERY_LOW :Very low
STR_6816_LOW :Low
STR_6817_NORMAL :Normal
STR_6818_HIGH :High
+STR_02BF_CUSTOM :Custom
STR_6819 :{BLACK}{SMALLLEFTARROW}
STR_681A :{BLACK}{SMALLRIGHTARROW}
STR_681B_VERY_SLOW :Very Slow
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index f30440d5a..f904d45d1 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -40,7 +40,7 @@
#include "saveload_internal.h"
-extern const uint16 SAVEGAME_VERSION = 114;
+extern const uint16 SAVEGAME_VERSION = 115;
SavegameType _savegame_type; ///< type of savegame we are loading
diff --git a/src/settings.cpp b/src/settings.cpp
index 9760ded42..727f9800a 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -1309,7 +1309,7 @@ const SettingDesc _settings[] = {
/* Do not ADD or REMOVE something in this "difficulty.XXX" table or before it. It breaks savegame compatability. */
SDT_CONDVAR(GameSettings, difficulty.max_no_competitors, SLE_UINT8, 97, SL_MAX_VERSION, 0, 0, 2,0,MAX_COMPANIES-1,1,STR_NULL, DifficultyChange),
SDT_CONDNULL( 1, 97, 109),
- SDT_CONDVAR(GameSettings, difficulty.number_towns, SLE_UINT8, 97, SL_MAX_VERSION, 0,NG, 2, 0, 3, 1, STR_NUM_VERY_LOW, DifficultyChange),
+ SDT_CONDVAR(GameSettings, difficulty.number_towns, SLE_UINT8, 97, SL_MAX_VERSION, 0,NG, 2, 0, 4, 1, STR_NUM_VERY_LOW, DifficultyChange),
SDT_CONDVAR(GameSettings, difficulty.number_industries, SLE_UINT8, 97, SL_MAX_VERSION, 0,NG, 4, 0, 4, 1, STR_NONE, DifficultyChange),
SDT_CONDVAR(GameSettings, difficulty.max_loan, SLE_UINT32, 97, SL_MAX_VERSION, 0,NG|CR,300000,100000,500000,50000,STR_NULL, DifficultyChange),
SDT_CONDVAR(GameSettings, difficulty.initial_interest, SLE_UINT8, 97, SL_MAX_VERSION, 0,NG, 2, 2, 4, 1, STR_NULL, DifficultyChange),
@@ -1489,6 +1489,7 @@ const SettingDesc _settings[] = {
SDT_VAR(GameSettings, game_creation.map_y, SLE_UINT8, S, 0, 8, 6, 11, 0, STR_CONFIG_SETTING_MAP_Y, NULL),
SDT_CONDBOOL(GameSettings, construction.freeform_edges, 111, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_SETTING_ENABLE_FREEFORM_EDGES, CheckFreeformEdges),
SDT_CONDVAR(GameSettings, game_creation.water_borders, SLE_UINT8,111, SL_MAX_VERSION, 0, 0, 15, 0, 16, 0, STR_NULL, NULL),
+ SDT_CONDVAR(GameSettings, game_creation.custom_town_number, SLE_UINT16,115, SL_MAX_VERSION, 0, 0, 1, 1, 5000, 0, STR_NULL, NULL),
SDT_CONDOMANY(GameSettings, locale.currency, SLE_UINT8, 97, SL_MAX_VERSION, N, 0, 0, CUSTOM_CURRENCY_ID, "GBP|USD|EUR|YEN|ATS|BEF|CHF|CZK|DEM|DKK|ESP|FIM|FRF|GRD|HUF|ISK|ITL|NLG|NOK|PLN|ROL|RUR|SIT|SEK|YTL|SKK|BRR|custom", STR_NULL, NULL, NULL),
SDT_CONDOMANY(GameSettings, locale.units, SLE_UINT8, 97, SL_MAX_VERSION, N, 0, 1, 2, "imperial|metric|si", STR_NULL, NULL, NULL),
diff --git a/src/settings_type.h b/src/settings_type.h
index 6185aae72..e96a25802 100644
--- a/src/settings_type.h
+++ b/src/settings_type.h
@@ -156,6 +156,7 @@ struct GameCreationSettings {
byte landscape; ///< the landscape we're currently in
byte snow_line; ///< the snowline level in this game
byte water_borders; ///< bitset of the borders that are water
+ uint16 custom_town_number; ///< manually entered number of towns
};
/** Settings related to construction in-game */
diff --git a/src/town.h b/src/town.h
index ac7464e1f..004234cd8 100644
--- a/src/town.h
+++ b/src/town.h
@@ -95,6 +95,9 @@ struct BuildingCounts {
uint8 class_count[HOUSE_CLASS_MAX];
};
+static const int CUSTOM_TOWN_NUMBER_DIFFICULTY = 4; ///< value for custom town number in difficulty settings
+static const int CUSTOM_TOWN_MAX_NUMBER = 5000; ///< this is the maximum number of towns a user can specify in customisation
+
DECLARE_OLD_POOL(Town, Town, 3, 8000)
struct Town : PoolItem<Town, TownID, &_Town_pool> {
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index f656fe76b..a4a47522c 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -1633,7 +1633,8 @@ static const byte _num_initial_towns[4] = {5, 11, 23, 46}; // very low, low, no
bool GenerateTowns(TownLayout layout)
{
uint num = 0;
- uint n = ScaleByMapSize(_num_initial_towns[_settings_game.difficulty.number_towns] + (Random() & 7));
+ uint difficulty = _settings_game.difficulty.number_towns;
+ uint n = difficulty == CUSTOM_TOWN_NUMBER_DIFFICULTY ? _settings_game.game_creation.custom_town_number : ScaleByMapSize(_num_initial_towns[difficulty] + (Random() & 7));
uint num_cities = _settings_game.economy.larger_towns == 0 ? 0 : n / _settings_game.economy.larger_towns;
SetGeneratingWorldProgress(GWP_TOWN, n);