@@ -29,12 +29,13 @@
#include "error.h"
#include "newgrf_townname.h"
#include "townname_type.h"
#include "video/video_driver.hpp"
#include "ai/ai_gui.hpp"
#include "game/game_gui.hpp"
#include "industry.h"
#include "widgets/genworld_widget.h"
#include "safeguards.h"
@@ -393,13 +394,13 @@ static DropDownList BuildTownNameDropDow
static const StringID _elevations[] = {STR_TERRAIN_TYPE_VERY_FLAT, STR_TERRAIN_TYPE_FLAT, STR_TERRAIN_TYPE_HILLY, STR_TERRAIN_TYPE_MOUNTAINOUS, STR_TERRAIN_TYPE_ALPINIST, STR_TERRAIN_TYPE_CUSTOM, INVALID_STRING_ID};
static const StringID _sea_lakes[] = {STR_SEA_LEVEL_VERY_LOW, STR_SEA_LEVEL_LOW, STR_SEA_LEVEL_MEDIUM, STR_SEA_LEVEL_HIGH, STR_SEA_LEVEL_CUSTOM, INVALID_STRING_ID};
static const StringID _rivers[] = {STR_RIVERS_NONE, STR_RIVERS_FEW, STR_RIVERS_MODERATE, STR_RIVERS_LOT, INVALID_STRING_ID};
static const StringID _smoothness[] = {STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_VERY_SMOOTH, STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_SMOOTH, STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_ROUGH, STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_VERY_ROUGH, 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 _num_towns[] = {STR_NUM_VERY_LOW, STR_NUM_LOW, STR_NUM_NORMAL, STR_NUM_HIGH, STR_NUM_CUSTOM, INVALID_STRING_ID};
static const StringID _num_inds[] = {STR_FUNDING_ONLY, STR_MINIMAL, STR_NUM_VERY_LOW, STR_NUM_LOW, STR_NUM_NORMAL, STR_NUM_HIGH, INVALID_STRING_ID};
static const StringID _num_inds[] = {STR_FUNDING_ONLY, STR_MINIMAL, STR_NUM_VERY_LOW, STR_NUM_LOW, STR_NUM_NORMAL, STR_NUM_HIGH, STR_NUM_CUSTOM, INVALID_STRING_ID};
static const StringID _variety[] = {STR_VARIETY_NONE, STR_VARIETY_VERY_LOW, STR_VARIETY_LOW, STR_VARIETY_MEDIUM, STR_VARIETY_HIGH, STR_VARIETY_VERY_HIGH, INVALID_STRING_ID};
static_assert(lengthof(_num_inds) == ID_END + 1);
struct GenerateLandscapeWindow : public Window {
uint widget_id;
@@ -460,13 +461,23 @@ struct GenerateLandscapeWindow : public
STR_MAPGEN_TOWN_NAME_ORIGINAL_ENGLISH + gen :
GetGRFTownNameName(gen - BUILTIN_TOWNNAME_GENERATOR_COUNT);
SetDParam(0, name);
break;
}
case WID_GL_INDUSTRY_PULLDOWN: SetDParam(0, _game_mode == GM_EDITOR ? STR_CONFIG_SETTING_OFF : _num_inds[_settings_newgame.difficulty.industry_density]); break;
case WID_GL_INDUSTRY_PULLDOWN:
if (_game_mode == GM_EDITOR) {
SetDParam(0, STR_CONFIG_SETTING_OFF);
} else if (_settings_newgame.difficulty.industry_density == ID_CUSTOM) {
SetDParam(0, STR_NUM_CUSTOM_NUMBER);
SetDParam(1, _settings_newgame.game_creation.custom_industry_number);
} else {
SetDParam(0, _num_inds[_settings_newgame.difficulty.industry_density]);
case WID_GL_TERRAIN_PULLDOWN:
if (_settings_newgame.difficulty.terrain_type == CUSTOM_TERRAIN_TYPE_NUMBER_DIFFICULTY) {
SetDParam(0, STR_TERRAIN_TYPE_CUSTOM_VALUE);
SetDParam(1, _settings_newgame.game_creation.custom_terrain_type);
SetDParam(0, _elevations[_settings_newgame.difficulty.terrain_type]); break;
@@ -617,13 +628,17 @@ struct GenerateLandscapeWindow : public
case WID_GL_TOWN_PULLDOWN:
strs = _num_towns;
SetDParamMaxValue(0, CUSTOM_TOWN_MAX_NUMBER);
*size = maxdim(*size, GetStringBoundingBox(STR_NUM_CUSTOM_NUMBER));
case WID_GL_INDUSTRY_PULLDOWN: strs = _num_inds; break;
strs = _num_inds;
SetDParamMaxValue(0, IndustryPool::MAX_SIZE);
strs = _elevations;
SetDParamMaxValue(0, MAX_MAP_HEIGHT_LIMIT);
*size = maxdim(*size, GetStringBoundingBox(STR_TERRAIN_TYPE_CUSTOM_VALUE));
@@ -905,13 +920,21 @@ struct GenerateLandscapeWindow : public
if (_game_mode == GM_MENU || Town::GetNumItems() == 0) {
_settings_newgame.game_creation.town_name = index;
SetWindowDirty(WC_GAME_OPTIONS, WN_GAME_OPTIONS_GAME_OPTIONS);
case WID_GL_INDUSTRY_PULLDOWN: _settings_newgame.difficulty.industry_density = index; break;
if ((uint)index == ID_CUSTOM) {
this->widget_id = widget;
SetDParam(0, _settings_newgame.game_creation.custom_industry_number);
ShowQueryString(STR_JUST_INT, STR_MAPGEN_NUMBER_OF_INDUSTRIES, 5, this, CS_NUMERAL, QSF_NONE);
_settings_newgame.difficulty.industry_density = index;
case WID_GL_TERRAIN_PULLDOWN: {
if ((uint)index == CUSTOM_TERRAIN_TYPE_NUMBER_DIFFICULTY) {
SetDParam(0, _settings_newgame.game_creation.custom_terrain_type);
ShowQueryString(STR_JUST_INT, STR_MAPGEN_TERRAIN_TYPE_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_NONE);
@@ -945,12 +968,13 @@ struct GenerateLandscapeWindow : public
switch (this->widget_id) {
case WID_GL_HEIGHTMAP_HEIGHT_TEXT: value = MAP_HEIGHT_LIMIT_AUTO_MINIMUM; break;
case WID_GL_START_DATE_TEXT: value = DEF_START_YEAR; break;
case WID_GL_SNOW_COVERAGE_TEXT: value = DEF_SNOW_COVERAGE; break;
case WID_GL_DESERT_COVERAGE_TEXT: value = DEF_DESERT_COVERAGE; break;
case WID_GL_TOWN_PULLDOWN: value = 1; break;
case WID_GL_INDUSTRY_PULLDOWN: value = 1; break;
case WID_GL_TERRAIN_PULLDOWN: value = MIN_MAP_HEIGHT_LIMIT; break;
case WID_GL_WATER_PULLDOWN: value = CUSTOM_SEA_LEVEL_MIN_PERCENTAGE; break;
default: NOT_REACHED();
@@ -976,12 +1000,16 @@ struct GenerateLandscapeWindow : public
_settings_newgame.game_creation.custom_town_number = Clamp(value, 1, CUSTOM_TOWN_MAX_NUMBER);
_settings_newgame.game_creation.custom_industry_number = Clamp(value, 1, IndustryPool::MAX_SIZE);
_settings_newgame.game_creation.custom_terrain_type = Clamp(value, MIN_CUSTOM_TERRAIN_TYPE, GetMapHeightLimit());
case WID_GL_WATER_PULLDOWN:
_settings_newgame.game_creation.custom_sea_level = Clamp(value, CUSTOM_SEA_LEVEL_MIN_PERCENTAGE, CUSTOM_SEA_LEVEL_MAX_PERCENTAGE);
@@ -2233,16 +2233,20 @@ static uint GetNumberOfIndustries()
0, // none
0, // minimal
10, // very low
25, // low
55, // normal
80, // high
0, // custom
};
assert(lengthof(numof_industry_table) == ID_END);
uint difficulty = (_game_mode != GM_EDITOR) ? _settings_game.difficulty.industry_density : (uint)ID_VERY_LOW;
if (difficulty == ID_CUSTOM) return std::min<uint>(IndustryPool::MAX_SIZE, _settings_game.game_creation.custom_industry_number);
return std::min<uint>(IndustryPool::MAX_SIZE, ScaleByMapSize(numof_industry_table[difficulty]));
/**
* Try to place the industry in the game.
* Since there is no feedback why placement fails, there is no other option
@@ -55,12 +55,14 @@ enum IndustryDensity {
ID_MINIMAL, ///< Start with just the industries that must be present.
ID_VERY_LOW, ///< Very few industries at game start.
ID_LOW, ///< Few industries at game start.
ID_NORMAL, ///< Normal amount of industries at game start.
ID_HIGH, ///< Many industries at game start.
ID_CUSTOM, ///< Custom number of industries.
ID_END, ///< Number of industry density settings.
/** Possible values for "userelayservice" setting. */
enum UseRelayService {
URS_NEVER = 0,
@@ -323,12 +325,13 @@ struct GameCreationSettings {
byte heightmap_rotation; ///< rotation director for the heightmap
byte se_flat_world_height; ///< land height a flat world gets in SE
byte town_name; ///< the town name generator used for town names
byte landscape; ///< the landscape we're currently in
byte water_borders; ///< bitset of the borders that are water
uint16 custom_town_number; ///< manually entered number of towns
uint16 custom_industry_number; ///< manually entered number of industries
byte variety; ///< variety level applied to TGP
byte custom_terrain_type; ///< manually entered height for TGP to aim for
byte custom_sea_level; ///< manually entered percentage of water in the map
byte min_river_length; ///< the minimum river length
byte river_route_random; ///< the amount of randomicity for the route finding
byte amount_of_rivers; ///< the amount of rivers
@@ -80,13 +80,13 @@ cat = SC_BASIC
[SDT_VAR]
var = difficulty.industry_density
type = SLE_UINT8
from = SLV_97
flags = SF_GUI_DROPDOWN
def = ID_END - 1
def = ID_NORMAL
min = 0
max = ID_END - 1
interval = 1
str = STR_CONFIG_SETTING_INDUSTRY_DENSITY
strhelp = STR_CONFIG_SETTING_INDUSTRY_DENSITY_HELPTEXT
strval = STR_FUNDING_ONLY
@@ -269,12 +269,19 @@ from = SLV_115
def = 1
min = 1
max = 5000
cat = SC_BASIC
var = game_creation.custom_industry_number
type = SLE_UINT16
max = 64000
var = game_creation.custom_terrain_type
from = SLV_MAPGEN_SETTINGS_REVAMP
flags = SF_NEWGAME_ONLY
def = MAP_HEIGHT_LIMIT_AUTO_MINIMUM
min = MIN_CUSTOM_TERRAIN_TYPE
Status change: