mirror of https://github.com/OpenTTD/OpenTTD
Compare commits
8 Commits
00e5f7b768
...
322aaeb284
Author | SHA1 | Date |
---|---|---|
|
322aaeb284 | |
|
9ce2aca949 | |
|
55098a2f2e | |
|
7ff0c67f77 | |
|
b2de1ff66f | |
|
fc924161ab | |
|
cd5d13a692 | |
|
61a299bc99 |
|
@ -103,14 +103,14 @@ void SpriteFontCache::ClearFontCache()
|
||||||
|
|
||||||
const Sprite *SpriteFontCache::GetGlyph(GlyphID key)
|
const Sprite *SpriteFontCache::GetGlyph(GlyphID key)
|
||||||
{
|
{
|
||||||
SpriteID sprite = this->GetUnicodeGlyph(static_cast<char32_t>(key & ~SPRITE_GLYPH));
|
SpriteID sprite = static_cast<SpriteID>(key & ~SPRITE_GLYPH);
|
||||||
if (sprite == 0) sprite = this->GetUnicodeGlyph('?');
|
if (sprite == 0) sprite = this->GetUnicodeGlyph('?');
|
||||||
return GetSprite(sprite, SpriteType::Font);
|
return GetSprite(sprite, SpriteType::Font);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint SpriteFontCache::GetGlyphWidth(GlyphID key)
|
uint SpriteFontCache::GetGlyphWidth(GlyphID key)
|
||||||
{
|
{
|
||||||
SpriteID sprite = this->GetUnicodeGlyph(static_cast<char32_t>(key & ~SPRITE_GLYPH));
|
SpriteID sprite = static_cast<SpriteID>(key & ~SPRITE_GLYPH);
|
||||||
if (sprite == 0) sprite = this->GetUnicodeGlyph('?');
|
if (sprite == 0) sprite = this->GetUnicodeGlyph('?');
|
||||||
return SpriteExists(sprite) ? GetSprite(sprite, SpriteType::Font)->width + ScaleFontTrad(this->fs != FS_NORMAL ? 1 : 0) : 0;
|
return SpriteExists(sprite) ? GetSprite(sprite, SpriteType::Font)->width + ScaleFontTrad(this->fs != FS_NORMAL ? 1 : 0) : 0;
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ GlyphID SpriteFontCache::MapCharToGlyph(char32_t key, [[maybe_unused]] bool allo
|
||||||
assert(IsPrintable(key));
|
assert(IsPrintable(key));
|
||||||
SpriteID sprite = this->GetUnicodeGlyph(key);
|
SpriteID sprite = this->GetUnicodeGlyph(key);
|
||||||
if (sprite == 0) return 0;
|
if (sprite == 0) return 0;
|
||||||
return SPRITE_GLYPH | key;
|
return SPRITE_GLYPH | sprite;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpriteFontCache::GetDrawGlyphShadow()
|
bool SpriteFontCache::GetDrawGlyphShadow()
|
||||||
|
|
|
@ -49,6 +49,8 @@ static const uint CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY = 4; ///< Value for custom
|
||||||
static const uint CUSTOM_SEA_LEVEL_MIN_PERCENTAGE = 1; ///< Minimum percentage a user can specify for custom sea level.
|
static const uint CUSTOM_SEA_LEVEL_MIN_PERCENTAGE = 1; ///< Minimum percentage a user can specify for custom sea level.
|
||||||
static const uint CUSTOM_SEA_LEVEL_MAX_PERCENTAGE = 90; ///< Maximum percentage a user can specify for custom sea level.
|
static const uint CUSTOM_SEA_LEVEL_MAX_PERCENTAGE = 90; ///< Maximum percentage a user can specify for custom sea level.
|
||||||
|
|
||||||
|
static const uint CUSTOM_SNOW_LEVEL_NUMBER = 5; ///< Value for custom snow level in game creation settings
|
||||||
|
|
||||||
static constexpr uint MAP_HEIGHT_LIMIT_ORIGINAL = 15; ///< Original map height limit.
|
static constexpr uint MAP_HEIGHT_LIMIT_ORIGINAL = 15; ///< Original map height limit.
|
||||||
|
|
||||||
static const uint MAP_HEIGHT_LIMIT_AUTO_MINIMUM = 30; ///< When map height limit is auto, make this the lowest possible map height limit.
|
static const uint MAP_HEIGHT_LIMIT_AUTO_MINIMUM = 30; ///< When map height limit is auto, make this the lowest possible map height limit.
|
||||||
|
|
|
@ -124,7 +124,7 @@ static constexpr NWidgetPart _nested_generate_landscape_widgets[] = {
|
||||||
/* Labels on the left side (global column 3). */
|
/* Labels on the left side (global column 3). */
|
||||||
NWidget(NWID_VERTICAL, NWidContainerFlag::EqualSize), SetPIP(0, WidgetDimensions::unscaled.vsep_sparse, 0),
|
NWidget(NWID_VERTICAL, NWidContainerFlag::EqualSize), SetPIP(0, WidgetDimensions::unscaled.vsep_sparse, 0),
|
||||||
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_GL_CLIMATE_SEL_LABEL),
|
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_GL_CLIMATE_SEL_LABEL),
|
||||||
NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_SNOW_COVERAGE, STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT), SetFill(1, 1),
|
NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_SNOW_LINE_LEVEL, STR_CONFIG_SETTING_SNOW_LINE_LEVEL_HELPTEXT), SetFill(1, 1),
|
||||||
NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_DESERT_COVERAGE, STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT), SetFill(1, 1),
|
NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_DESERT_COVERAGE, STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT), SetFill(1, 1),
|
||||||
NWidget(NWID_SPACER), SetFill(1, 1),
|
NWidget(NWID_SPACER), SetFill(1, 1),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
|
@ -139,11 +139,9 @@ static constexpr NWidgetPart _nested_generate_landscape_widgets[] = {
|
||||||
NWidget(NWID_VERTICAL, NWidContainerFlag::EqualSize), SetPIP(0, WidgetDimensions::unscaled.vsep_sparse, 0),
|
NWidget(NWID_VERTICAL, NWidContainerFlag::EqualSize), SetPIP(0, WidgetDimensions::unscaled.vsep_sparse, 0),
|
||||||
/* Climate selector. */
|
/* Climate selector. */
|
||||||
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_GL_CLIMATE_SEL_SELECTOR),
|
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_GL_CLIMATE_SEL_SELECTOR),
|
||||||
/* Snow coverage. */
|
/* Snow line level. */
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_DOWN), SetSpriteTip(SPR_ARROW_DOWN, STR_MAPGEN_SNOW_COVERAGE_DOWN_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
|
NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_SNOW_LINE_LEVEL_PULLDOWN), SetToolTip(STR_CONFIG_SETTING_SNOW_LINE_LEVEL_HELPTEXT), SetFill(1, 1),
|
||||||
NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_TEXT), SetToolTip(STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT), SetFill(1, 1),
|
|
||||||
NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_UP), SetSpriteTip(SPR_ARROW_UP, STR_MAPGEN_SNOW_COVERAGE_UP_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
|
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
/* Desert coverage. */
|
/* Desert coverage. */
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
|
@ -259,7 +257,7 @@ static constexpr NWidgetPart _nested_heightmap_load_widgets[] = {
|
||||||
/* Right half labels (global column 3) */
|
/* Right half labels (global column 3) */
|
||||||
NWidget(NWID_VERTICAL, NWidContainerFlag::EqualSize), SetPIP(0, WidgetDimensions::unscaled.vsep_sparse, 0),
|
NWidget(NWID_VERTICAL, NWidContainerFlag::EqualSize), SetPIP(0, WidgetDimensions::unscaled.vsep_sparse, 0),
|
||||||
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_GL_CLIMATE_SEL_LABEL),
|
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_GL_CLIMATE_SEL_LABEL),
|
||||||
NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_SNOW_COVERAGE, STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT), SetFill(1, 1),
|
NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_SNOW_LINE_LEVEL, STR_CONFIG_SETTING_SNOW_LINE_LEVEL_HELPTEXT), SetFill(1, 1),
|
||||||
NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_DESERT_COVERAGE, STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT), SetFill(1, 1),
|
NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_MAPGEN_DESERT_COVERAGE, STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT), SetFill(1, 1),
|
||||||
NWidget(NWID_SPACER), SetFill(1, 1),
|
NWidget(NWID_SPACER), SetFill(1, 1),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
|
@ -273,11 +271,9 @@ static constexpr NWidgetPart _nested_heightmap_load_widgets[] = {
|
||||||
NWidget(NWID_VERTICAL, NWidContainerFlag::EqualSize), SetPIP(0, WidgetDimensions::unscaled.vsep_sparse, 0),
|
NWidget(NWID_VERTICAL, NWidContainerFlag::EqualSize), SetPIP(0, WidgetDimensions::unscaled.vsep_sparse, 0),
|
||||||
/* Climate selector. */
|
/* Climate selector. */
|
||||||
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_GL_CLIMATE_SEL_SELECTOR),
|
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_GL_CLIMATE_SEL_SELECTOR),
|
||||||
/* Snow coverage. */
|
/* Snow line level. */
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_DOWN), SetSpriteTip(SPR_ARROW_DOWN, STR_MAPGEN_SNOW_COVERAGE_DOWN_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
|
NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_SNOW_LINE_LEVEL_PULLDOWN), SetToolTip(STR_CONFIG_SETTING_SNOW_LINE_LEVEL_HELPTEXT), SetFill(1, 1),
|
||||||
NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_TEXT), SetToolTip(STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT), SetFill(1, 1),
|
|
||||||
NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_UP), SetSpriteTip(SPR_ARROW_UP, STR_MAPGEN_SNOW_COVERAGE_UP_TOOLTIP), SetFill(0, 1), SetAspect(WidgetDimensions::ASPECT_UP_DOWN_BUTTON),
|
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
/* Desert coverage. */
|
/* Desert coverage. */
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
|
@ -384,6 +380,7 @@ static const StringID _rotation[] = {STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_CO
|
||||||
static const StringID _num_towns[] = {STR_NUM_VERY_LOW, STR_NUM_LOW, STR_NUM_NORMAL, STR_NUM_HIGH, STR_NUM_CUSTOM};
|
static const StringID _num_towns[] = {STR_NUM_VERY_LOW, STR_NUM_LOW, STR_NUM_NORMAL, STR_NUM_HIGH, STR_NUM_CUSTOM};
|
||||||
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};
|
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};
|
||||||
static const StringID _variety[] = {STR_VARIETY_NONE, STR_VARIETY_VERY_LOW, STR_VARIETY_LOW, STR_VARIETY_MEDIUM, STR_VARIETY_HIGH, STR_VARIETY_VERY_HIGH};
|
static const StringID _variety[] = {STR_VARIETY_NONE, STR_VARIETY_VERY_LOW, STR_VARIETY_LOW, STR_VARIETY_MEDIUM, STR_VARIETY_HIGH, STR_VARIETY_VERY_HIGH};
|
||||||
|
static const StringID _snow_levels[] = {STR_SNOW_LINE_LEVEL_VERY_LOW, STR_SNOW_LINE_LEVEL_LOW, STR_SNOW_LINE_LEVEL_MEDIUM, STR_SNOW_LINE_LEVEL_HIGH, STR_SNOW_LINE_LEVEL_VERY_HIGH, STR_SNOW_LINE_LEVEL_CUSTOM};
|
||||||
|
|
||||||
static_assert(std::size(_num_inds) == ID_END);
|
static_assert(std::size(_num_inds) == ID_END);
|
||||||
|
|
||||||
|
@ -426,7 +423,12 @@ struct GenerateLandscapeWindow : public Window {
|
||||||
case WID_GL_MAPSIZE_X_PULLDOWN: return GetString(STR_JUST_INT, 1LL << _settings_newgame.game_creation.map_x);
|
case WID_GL_MAPSIZE_X_PULLDOWN: return GetString(STR_JUST_INT, 1LL << _settings_newgame.game_creation.map_x);
|
||||||
case WID_GL_MAPSIZE_Y_PULLDOWN: return GetString(STR_JUST_INT, 1LL << _settings_newgame.game_creation.map_y);
|
case WID_GL_MAPSIZE_Y_PULLDOWN: return GetString(STR_JUST_INT, 1LL << _settings_newgame.game_creation.map_y);
|
||||||
case WID_GL_HEIGHTMAP_HEIGHT_TEXT: return GetString(STR_JUST_INT, _settings_newgame.game_creation.heightmap_height);
|
case WID_GL_HEIGHTMAP_HEIGHT_TEXT: return GetString(STR_JUST_INT, _settings_newgame.game_creation.heightmap_height);
|
||||||
case WID_GL_SNOW_COVERAGE_TEXT: return GetString(STR_MAPGEN_SNOW_COVERAGE_TEXT, _settings_newgame.game_creation.snow_coverage);
|
case WID_GL_SNOW_LINE_LEVEL_PULLDOWN:
|
||||||
|
if (_settings_newgame.game_creation.snow_line_level == CUSTOM_SNOW_LEVEL_NUMBER) {
|
||||||
|
return GetString(STR_SNOW_LINE_LEVEL_CUSTOM_NUMBER, _settings_newgame.game_creation.snow_line_height);
|
||||||
|
}
|
||||||
|
return GetString(_snow_levels[_settings_newgame.game_creation.snow_line_level]);
|
||||||
|
|
||||||
case WID_GL_DESERT_COVERAGE_TEXT: return GetString(STR_MAPGEN_DESERT_COVERAGE_TEXT, _settings_newgame.game_creation.desert_coverage);
|
case WID_GL_DESERT_COVERAGE_TEXT: return GetString(STR_MAPGEN_DESERT_COVERAGE_TEXT, _settings_newgame.game_creation.desert_coverage);
|
||||||
|
|
||||||
case WID_GL_TOWN_PULLDOWN:
|
case WID_GL_TOWN_PULLDOWN:
|
||||||
|
@ -523,7 +525,7 @@ struct GenerateLandscapeWindow : public Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Disable snowline if not arctic */
|
/* Disable snowline if not arctic */
|
||||||
this->SetWidgetDisabledState(WID_GL_SNOW_COVERAGE_TEXT, _settings_newgame.game_creation.landscape != LandscapeType::Arctic);
|
this->SetWidgetDisabledState(WID_GL_SNOW_LINE_LEVEL_PULLDOWN, _settings_newgame.game_creation.landscape != LandscapeType::Arctic);
|
||||||
/* Disable desert if not tropic */
|
/* Disable desert if not tropic */
|
||||||
this->SetWidgetDisabledState(WID_GL_DESERT_COVERAGE_TEXT, _settings_newgame.game_creation.landscape != LandscapeType::Tropic);
|
this->SetWidgetDisabledState(WID_GL_DESERT_COVERAGE_TEXT, _settings_newgame.game_creation.landscape != LandscapeType::Tropic);
|
||||||
|
|
||||||
|
@ -545,8 +547,6 @@ struct GenerateLandscapeWindow : public Window {
|
||||||
}
|
}
|
||||||
this->SetWidgetDisabledState(WID_GL_START_DATE_DOWN, _settings_newgame.game_creation.starting_year <= CalendarTime::MIN_YEAR);
|
this->SetWidgetDisabledState(WID_GL_START_DATE_DOWN, _settings_newgame.game_creation.starting_year <= CalendarTime::MIN_YEAR);
|
||||||
this->SetWidgetDisabledState(WID_GL_START_DATE_UP, _settings_newgame.game_creation.starting_year >= CalendarTime::MAX_YEAR);
|
this->SetWidgetDisabledState(WID_GL_START_DATE_UP, _settings_newgame.game_creation.starting_year >= CalendarTime::MAX_YEAR);
|
||||||
this->SetWidgetDisabledState(WID_GL_SNOW_COVERAGE_DOWN, _settings_newgame.game_creation.snow_coverage <= 0 || _settings_newgame.game_creation.landscape != LandscapeType::Arctic);
|
|
||||||
this->SetWidgetDisabledState(WID_GL_SNOW_COVERAGE_UP, _settings_newgame.game_creation.snow_coverage >= 100 || _settings_newgame.game_creation.landscape != LandscapeType::Arctic);
|
|
||||||
this->SetWidgetDisabledState(WID_GL_DESERT_COVERAGE_DOWN, _settings_newgame.game_creation.desert_coverage <= 0 || _settings_newgame.game_creation.landscape != LandscapeType::Tropic);
|
this->SetWidgetDisabledState(WID_GL_DESERT_COVERAGE_DOWN, _settings_newgame.game_creation.desert_coverage <= 0 || _settings_newgame.game_creation.landscape != LandscapeType::Tropic);
|
||||||
this->SetWidgetDisabledState(WID_GL_DESERT_COVERAGE_UP, _settings_newgame.game_creation.desert_coverage >= 100 || _settings_newgame.game_creation.landscape != LandscapeType::Tropic);
|
this->SetWidgetDisabledState(WID_GL_DESERT_COVERAGE_UP, _settings_newgame.game_creation.desert_coverage >= 100 || _settings_newgame.game_creation.landscape != LandscapeType::Tropic);
|
||||||
|
|
||||||
|
@ -586,8 +586,8 @@ struct GenerateLandscapeWindow : public Window {
|
||||||
d = GetStringBoundingBox(GetString(STR_JUST_INT, GetParamMaxValue(MAX_MAP_SIZE)));
|
d = GetStringBoundingBox(GetString(STR_JUST_INT, GetParamMaxValue(MAX_MAP_SIZE)));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_GL_SNOW_COVERAGE_TEXT:
|
case WID_GL_SNOW_LINE_LEVEL_PULLDOWN:
|
||||||
d = GetStringBoundingBox(GetString(STR_MAPGEN_SNOW_COVERAGE_TEXT, GetParamMaxValue(MAX_TILE_HEIGHT)));
|
d = GetStringBoundingBox(GetString(STR_JUST_INT, GetParamMaxValue(MAX_SNOWLINE_HEIGHT)));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_GL_DESERT_COVERAGE_TEXT:
|
case WID_GL_DESERT_COVERAGE_TEXT:
|
||||||
|
@ -738,21 +738,8 @@ struct GenerateLandscapeWindow : public Window {
|
||||||
ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.starting_year), STR_MAPGEN_START_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QueryStringFlag::EnableDefault);
|
ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.starting_year), STR_MAPGEN_START_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QueryStringFlag::EnableDefault);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_GL_SNOW_COVERAGE_DOWN:
|
case WID_GL_SNOW_LINE_LEVEL_PULLDOWN: // Snow line level
|
||||||
case WID_GL_SNOW_COVERAGE_UP: // Snow coverage buttons
|
ShowDropDownMenu(this, _snow_levels, _settings_newgame.game_creation.snow_line_level, WID_GL_SNOW_LINE_LEVEL_PULLDOWN, 0, 0);
|
||||||
/* Don't allow too fast scrolling */
|
|
||||||
if (!this->flags.Test(WindowFlag::Timeout) || this->timeout_timer <= 1) {
|
|
||||||
this->HandleButtonClick(widget);
|
|
||||||
|
|
||||||
_settings_newgame.game_creation.snow_coverage = Clamp(_settings_newgame.game_creation.snow_coverage + (widget - WID_GL_SNOW_COVERAGE_TEXT) * 10, 0, 100);
|
|
||||||
this->InvalidateData();
|
|
||||||
}
|
|
||||||
_left_button_clicked = false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WID_GL_SNOW_COVERAGE_TEXT: // Snow coverage text
|
|
||||||
this->widget_id = WID_GL_SNOW_COVERAGE_TEXT;
|
|
||||||
ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.snow_coverage), STR_MAPGEN_SNOW_COVERAGE_QUERY_CAPT, 4, this, CS_NUMERAL, QueryStringFlag::EnableDefault);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_GL_DESERT_COVERAGE_DOWN:
|
case WID_GL_DESERT_COVERAGE_DOWN:
|
||||||
|
@ -846,9 +833,9 @@ struct GenerateLandscapeWindow : public Window {
|
||||||
void OnTimeout() override
|
void OnTimeout() override
|
||||||
{
|
{
|
||||||
if (mode == GLWM_HEIGHTMAP) {
|
if (mode == GLWM_HEIGHTMAP) {
|
||||||
this->RaiseWidgetsWhenLowered(WID_GL_HEIGHTMAP_HEIGHT_DOWN, WID_GL_HEIGHTMAP_HEIGHT_UP, WID_GL_START_DATE_DOWN, WID_GL_START_DATE_UP, WID_GL_SNOW_COVERAGE_UP, WID_GL_SNOW_COVERAGE_DOWN, WID_GL_DESERT_COVERAGE_UP, WID_GL_DESERT_COVERAGE_DOWN);
|
this->RaiseWidgetsWhenLowered(WID_GL_HEIGHTMAP_HEIGHT_DOWN, WID_GL_HEIGHTMAP_HEIGHT_UP, WID_GL_START_DATE_DOWN, WID_GL_START_DATE_UP, WID_GL_DESERT_COVERAGE_UP, WID_GL_DESERT_COVERAGE_DOWN);
|
||||||
} else {
|
} else {
|
||||||
this->RaiseWidgetsWhenLowered(WID_GL_START_DATE_DOWN, WID_GL_START_DATE_UP, WID_GL_SNOW_COVERAGE_UP, WID_GL_SNOW_COVERAGE_DOWN, WID_GL_DESERT_COVERAGE_UP, WID_GL_DESERT_COVERAGE_DOWN);
|
this->RaiseWidgetsWhenLowered(WID_GL_START_DATE_DOWN, WID_GL_START_DATE_UP, WID_GL_DESERT_COVERAGE_UP, WID_GL_DESERT_COVERAGE_DOWN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -863,6 +850,14 @@ struct GenerateLandscapeWindow : public Window {
|
||||||
|
|
||||||
case WID_GL_HEIGHTMAP_ROTATION_PULLDOWN: _settings_newgame.game_creation.heightmap_rotation = index; break;
|
case WID_GL_HEIGHTMAP_ROTATION_PULLDOWN: _settings_newgame.game_creation.heightmap_rotation = index; break;
|
||||||
|
|
||||||
|
case WID_GL_SNOW_LINE_LEVEL_PULLDOWN: // Snow line level
|
||||||
|
if ((uint)index == CUSTOM_SNOW_LEVEL_NUMBER) {
|
||||||
|
this->widget_id = widget;
|
||||||
|
ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.snow_line_height), STR_MAPGEN_SNOW_LINE_LEVEL_QUERY_CAPT, 4, this, CS_NUMERAL, {});
|
||||||
|
}
|
||||||
|
_settings_newgame.game_creation.snow_line_level = index;
|
||||||
|
break;
|
||||||
|
|
||||||
case WID_GL_TOWN_PULLDOWN:
|
case WID_GL_TOWN_PULLDOWN:
|
||||||
if ((uint)index == CUSTOM_TOWN_NUMBER_DIFFICULTY) {
|
if ((uint)index == CUSTOM_TOWN_NUMBER_DIFFICULTY) {
|
||||||
this->widget_id = widget;
|
this->widget_id = widget;
|
||||||
|
@ -922,7 +917,7 @@ struct GenerateLandscapeWindow : public Window {
|
||||||
switch (this->widget_id) {
|
switch (this->widget_id) {
|
||||||
case WID_GL_HEIGHTMAP_HEIGHT_TEXT: value = MAP_HEIGHT_LIMIT_AUTO_MINIMUM; break;
|
case WID_GL_HEIGHTMAP_HEIGHT_TEXT: value = MAP_HEIGHT_LIMIT_AUTO_MINIMUM; break;
|
||||||
case WID_GL_START_DATE_TEXT: value = CalendarTime::DEF_START_YEAR.base(); break;
|
case WID_GL_START_DATE_TEXT: value = CalendarTime::DEF_START_YEAR.base(); break;
|
||||||
case WID_GL_SNOW_COVERAGE_TEXT: value = DEF_SNOW_COVERAGE; break;
|
case WID_GL_SNOW_LINE_LEVEL_PULLDOWN: value = DEF_SNOWLINE_HEIGHT; break;
|
||||||
case WID_GL_DESERT_COVERAGE_TEXT: value = DEF_DESERT_COVERAGE; break;
|
case WID_GL_DESERT_COVERAGE_TEXT: value = DEF_DESERT_COVERAGE; break;
|
||||||
case WID_GL_TOWN_PULLDOWN: value = 1; break;
|
case WID_GL_TOWN_PULLDOWN: value = 1; break;
|
||||||
case WID_GL_INDUSTRY_PULLDOWN: value = 1; break;
|
case WID_GL_INDUSTRY_PULLDOWN: value = 1; break;
|
||||||
|
@ -943,9 +938,8 @@ struct GenerateLandscapeWindow : public Window {
|
||||||
_settings_newgame.game_creation.starting_year = Clamp(TimerGameCalendar::Year(value), CalendarTime::MIN_YEAR, CalendarTime::MAX_YEAR);
|
_settings_newgame.game_creation.starting_year = Clamp(TimerGameCalendar::Year(value), CalendarTime::MIN_YEAR, CalendarTime::MAX_YEAR);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_GL_SNOW_COVERAGE_TEXT:
|
case WID_GL_SNOW_LINE_LEVEL_PULLDOWN:
|
||||||
this->SetWidgetDirty(WID_GL_SNOW_COVERAGE_TEXT);
|
_settings_newgame.game_creation.snow_line_height = Clamp(value, MIN_SNOWLINE_HEIGHT, MAX_SNOWLINE_HEIGHT);
|
||||||
_settings_newgame.game_creation.snow_coverage = Clamp(value, 0, 100);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_GL_DESERT_COVERAGE_TEXT:
|
case WID_GL_DESERT_COVERAGE_TEXT:
|
||||||
|
|
|
@ -1510,13 +1510,45 @@ static uint CalculateCoverageLine(uint coverage, uint edge_multiplier)
|
||||||
return best_h;
|
return best_h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get current maximum height of the map.
|
||||||
|
* @return The maximum height of the map.
|
||||||
|
*/
|
||||||
|
static uint GetMapMaxHeight()
|
||||||
|
{
|
||||||
|
uint max_height = 0;
|
||||||
|
|
||||||
|
for (const auto tile : Map::Iterate()) {
|
||||||
|
uint h = TileHeight(tile);
|
||||||
|
if (h > max_height) {
|
||||||
|
max_height = h;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return max_height;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate the line from which snow begins.
|
* Calculate the line from which snow begins.
|
||||||
*/
|
*/
|
||||||
static void CalculateSnowLine()
|
static void CalculateSnowLine()
|
||||||
{
|
{
|
||||||
/* We do not have snow sprites on coastal tiles, so never allow "1" as height. */
|
/* If snow_line_level is custom, then snow_line_height is already set
|
||||||
_settings_game.game_creation.snow_line_height = std::max(CalculateCoverageLine(_settings_game.game_creation.snow_coverage, 0), 2u);
|
* otherwise we have to calculate it
|
||||||
|
*/
|
||||||
|
if (_settings_game.game_creation.snow_line_level != CUSTOM_SNOW_LEVEL_NUMBER) {
|
||||||
|
uint min_snow_line_height = 4; // Not too low to make room for farms
|
||||||
|
uint max_snow_line_height = GetMapMaxHeight() - 2; // Not too high to make room for forests
|
||||||
|
|
||||||
|
uint max_height_diff = min_snow_line_height < max_snow_line_height
|
||||||
|
? max_snow_line_height - min_snow_line_height
|
||||||
|
: 0;
|
||||||
|
|
||||||
|
/* snow_line_level goes up to 4 so we divide by 5 to get a maximum ratio of 80% */
|
||||||
|
uint height_diff = RoundDivSU(max_height_diff * _settings_game.game_creation.snow_line_level, 5);
|
||||||
|
|
||||||
|
_settings_game.game_creation.snow_line_height = min_snow_line_height + height_diff;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1217,6 +1217,15 @@ STR_TERRAIN_TYPE_ALPINIST :Alpinist
|
||||||
STR_TERRAIN_TYPE_CUSTOM :Custom height
|
STR_TERRAIN_TYPE_CUSTOM :Custom height
|
||||||
STR_TERRAIN_TYPE_CUSTOM_VALUE :Custom height ({NUM})
|
STR_TERRAIN_TYPE_CUSTOM_VALUE :Custom height ({NUM})
|
||||||
|
|
||||||
|
###length 7
|
||||||
|
STR_SNOW_LINE_LEVEL_VERY_LOW :Very Low
|
||||||
|
STR_SNOW_LINE_LEVEL_LOW :Low
|
||||||
|
STR_SNOW_LINE_LEVEL_MEDIUM :Medium
|
||||||
|
STR_SNOW_LINE_LEVEL_HIGH :High
|
||||||
|
STR_SNOW_LINE_LEVEL_VERY_HIGH :Very high
|
||||||
|
STR_SNOW_LINE_LEVEL_CUSTOM :Custom
|
||||||
|
STR_SNOW_LINE_LEVEL_CUSTOM_NUMBER :Custom ({NUM})
|
||||||
|
|
||||||
###length 4
|
###length 4
|
||||||
STR_CITY_APPROVAL_LENIENT :Lenient
|
STR_CITY_APPROVAL_LENIENT :Lenient
|
||||||
STR_CITY_APPROVAL_TOLERANT :Tolerant
|
STR_CITY_APPROVAL_TOLERANT :Tolerant
|
||||||
|
@ -1593,9 +1602,8 @@ STR_CONFIG_SETTING_OIL_REF_EDGE_DISTANCE_HELPTEXT :Limit for how f
|
||||||
STR_CONFIG_SETTING_SNOWLINE_HEIGHT :Snow line height: {STRING2}
|
STR_CONFIG_SETTING_SNOWLINE_HEIGHT :Snow line height: {STRING2}
|
||||||
STR_CONFIG_SETTING_SNOWLINE_HEIGHT_HELPTEXT :Choose at what height snow starts in sub-arctic landscape. Snow also affects industry generation and town growth requirements. Can only be modified via Scenario Editor or is otherwise calculated via "snow coverage"
|
STR_CONFIG_SETTING_SNOWLINE_HEIGHT_HELPTEXT :Choose at what height snow starts in sub-arctic landscape. Snow also affects industry generation and town growth requirements. Can only be modified via Scenario Editor or is otherwise calculated via "snow coverage"
|
||||||
|
|
||||||
STR_CONFIG_SETTING_SNOW_COVERAGE :Snow coverage: {STRING2}
|
STR_CONFIG_SETTING_SNOW_LINE_LEVEL :Snow line level: {STRING2}
|
||||||
STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT :Choose the approximate amount of snow on the sub-arctic landscape. Snow also affects industry generation and town growth requirements. Only used during map generation. Sea level and coast tiles never have snow
|
STR_CONFIG_SETTING_SNOW_LINE_LEVEL_HELPTEXT :Choose the approximate height above which all tiles will be covered by snow in sub-arctic landscape. Snow also affects industry generation and town growth requirements.
|
||||||
STR_CONFIG_SETTING_SNOW_COVERAGE_VALUE :{NUM}%
|
|
||||||
|
|
||||||
STR_CONFIG_SETTING_DESERT_COVERAGE :Desert coverage: {STRING2}
|
STR_CONFIG_SETTING_DESERT_COVERAGE :Desert coverage: {STRING2}
|
||||||
STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT :Choose the approximate amount of desert on the tropical landscape. Desert also affects industry generation and town growth requirements. Only used during map generation
|
STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT :Choose the approximate amount of desert on the tropical landscape. Desert also affects industry generation and town growth requirements. Only used during map generation
|
||||||
|
@ -3352,10 +3360,7 @@ STR_MAPGEN_HEIGHTMAP_HEIGHT :{BLACK}Highest
|
||||||
STR_MAPGEN_HEIGHTMAP_HEIGHT_TOOLTIP :{BLACK}Choose the highest peak that the game will attempt to create, measured in elevation above sea level
|
STR_MAPGEN_HEIGHTMAP_HEIGHT_TOOLTIP :{BLACK}Choose the highest peak that the game will attempt to create, measured in elevation above sea level
|
||||||
STR_MAPGEN_HEIGHTMAP_HEIGHT_UP_TOOLTIP :{BLACK}Increase the maximum height of highest peak on the map by one
|
STR_MAPGEN_HEIGHTMAP_HEIGHT_UP_TOOLTIP :{BLACK}Increase the maximum height of highest peak on the map by one
|
||||||
STR_MAPGEN_HEIGHTMAP_HEIGHT_DOWN_TOOLTIP :{BLACK}Decrease the maximum height of highest peak on the map by one
|
STR_MAPGEN_HEIGHTMAP_HEIGHT_DOWN_TOOLTIP :{BLACK}Decrease the maximum height of highest peak on the map by one
|
||||||
STR_MAPGEN_SNOW_COVERAGE :{BLACK}Snow coverage:
|
STR_MAPGEN_SNOW_LINE_LEVEL :{BLACK}Snow line level:
|
||||||
STR_MAPGEN_SNOW_COVERAGE_UP_TOOLTIP :{BLACK}Increase snow coverage by ten percent
|
|
||||||
STR_MAPGEN_SNOW_COVERAGE_DOWN_TOOLTIP :{BLACK}Decrease snow coverage by ten percent
|
|
||||||
STR_MAPGEN_SNOW_COVERAGE_TEXT :{BLACK}{NUM}%
|
|
||||||
STR_MAPGEN_DESERT_COVERAGE :{BLACK}Desert coverage:
|
STR_MAPGEN_DESERT_COVERAGE :{BLACK}Desert coverage:
|
||||||
STR_MAPGEN_DESERT_COVERAGE_UP_TOOLTIP :{BLACK}Increase desert coverage by ten percent
|
STR_MAPGEN_DESERT_COVERAGE_UP_TOOLTIP :{BLACK}Increase desert coverage by ten percent
|
||||||
STR_MAPGEN_DESERT_COVERAGE_DOWN_TOOLTIP :{BLACK}Decrease desert coverage by ten percent
|
STR_MAPGEN_DESERT_COVERAGE_DOWN_TOOLTIP :{BLACK}Decrease desert coverage by ten percent
|
||||||
|
@ -3420,7 +3425,7 @@ STR_MAPGEN_HEIGHTMAP_SIZE :{ORANGE}{NUM} x
|
||||||
|
|
||||||
STR_MAPGEN_TERRAIN_TYPE_QUERY_CAPT :{WHITE}Target peak height
|
STR_MAPGEN_TERRAIN_TYPE_QUERY_CAPT :{WHITE}Target peak height
|
||||||
STR_MAPGEN_HEIGHTMAP_HEIGHT_QUERY_CAPT :{WHITE}Highest peak
|
STR_MAPGEN_HEIGHTMAP_HEIGHT_QUERY_CAPT :{WHITE}Highest peak
|
||||||
STR_MAPGEN_SNOW_COVERAGE_QUERY_CAPT :{WHITE}Snow coverage (in %)
|
STR_MAPGEN_SNOW_LINE_LEVEL_QUERY_CAPT :{WHITE}Snow line height
|
||||||
STR_MAPGEN_DESERT_COVERAGE_QUERY_CAPT :{WHITE}Desert coverage (in %)
|
STR_MAPGEN_DESERT_COVERAGE_QUERY_CAPT :{WHITE}Desert coverage (in %)
|
||||||
STR_MAPGEN_START_DATE_QUERY_CAPT :{WHITE}Change starting year
|
STR_MAPGEN_START_DATE_QUERY_CAPT :{WHITE}Change starting year
|
||||||
|
|
||||||
|
|
|
@ -105,8 +105,8 @@ static ChangeInfoResult RoadStopChangeInfo(uint first, uint last, int prop, Byte
|
||||||
AddStringForMapping(GRFStringID{buf.ReadWord()}, [rs = rs.get()](StringID str) { RoadStopClass::Get(rs->class_index)->name = str; });
|
AddStringForMapping(GRFStringID{buf.ReadWord()}, [rs = rs.get()](StringID str) { RoadStopClass::Get(rs->class_index)->name = str; });
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x0C: // The draw mode
|
case 0x0C: // The draw modes
|
||||||
rs->draw_mode = static_cast<RoadStopDrawMode>(buf.ReadByte());
|
rs->draw_mode = static_cast<RoadStopDrawModes>(buf.ReadByte());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x0D: // Cargo types for random triggers
|
case 0x0D: // Cargo types for random triggers
|
||||||
|
|
|
@ -298,7 +298,7 @@ void DrawRoadStopTile(int x, int y, RoadType roadtype, const RoadStopSpec *spec,
|
||||||
|
|
||||||
RoadStopDrawModes draw_mode;
|
RoadStopDrawModes draw_mode;
|
||||||
if (spec->flags.Test(RoadStopSpecFlag::DrawModeRegister)) {
|
if (spec->flags.Test(RoadStopSpecFlag::DrawModeRegister)) {
|
||||||
draw_mode = static_cast<RoadStopDrawMode>(object.GetRegister(0x100));
|
draw_mode = static_cast<RoadStopDrawModes>(object.GetRegister(0x100));
|
||||||
} else {
|
} else {
|
||||||
draw_mode = spec->draw_mode;
|
draw_mode = spec->draw_mode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
#include "../timer/timer_game_economy.h"
|
#include "../timer/timer_game_economy.h"
|
||||||
#include "../timer/timer_game_tick.h"
|
#include "../timer/timer_game_tick.h"
|
||||||
#include "../picker_func.h"
|
#include "../picker_func.h"
|
||||||
|
#include "../genworld.h"
|
||||||
|
|
||||||
#include "saveload_internal.h"
|
#include "saveload_internal.h"
|
||||||
|
|
||||||
|
@ -3397,6 +3398,11 @@ bool AfterLoadGame()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsSavegameVersionBefore(SLV_SNOW_LINE_LEVEL)) {
|
||||||
|
/* The snow line level replaces the snow coverage but the two do not map very well. */
|
||||||
|
_settings_game.game_creation.snow_line_level = CUSTOM_SNOW_LEVEL_NUMBER;
|
||||||
|
}
|
||||||
|
|
||||||
AfterLoadLabelMaps();
|
AfterLoadLabelMaps();
|
||||||
AfterLoadCompanyStats();
|
AfterLoadCompanyStats();
|
||||||
AfterLoadStoryBook();
|
AfterLoadStoryBook();
|
||||||
|
|
|
@ -143,7 +143,7 @@ const SaveLoadCompat _settings_sl_compat[] = {
|
||||||
SLC_VAR("economy.fund_roads"),
|
SLC_VAR("economy.fund_roads"),
|
||||||
SLC_VAR("economy.give_money"),
|
SLC_VAR("economy.give_money"),
|
||||||
SLC_VAR("game_creation.snow_line_height"),
|
SLC_VAR("game_creation.snow_line_height"),
|
||||||
SLC_VAR("game_creation.snow_coverage"),
|
SLC_NULL(1, SLV_MAPGEN_SETTINGS_REVAMP, SLV_TABLE_CHUNKS),
|
||||||
SLC_VAR("game_creation.desert_coverage"),
|
SLC_VAR("game_creation.desert_coverage"),
|
||||||
SLC_NULL(4, SL_MIN_VERSION, SLV_144),
|
SLC_NULL(4, SL_MIN_VERSION, SLV_144),
|
||||||
SLC_VAR("game_creation.starting_year"),
|
SLC_VAR("game_creation.starting_year"),
|
||||||
|
|
|
@ -405,6 +405,7 @@ enum SaveLoadVersion : uint16_t {
|
||||||
|
|
||||||
SLV_FACE_STYLES, ///< 355 PR#14319 Addition of face styles, replacing gender and ethnicity.
|
SLV_FACE_STYLES, ///< 355 PR#14319 Addition of face styles, replacing gender and ethnicity.
|
||||||
SLV_INDUSTRY_NUM_VALID_HISTORY, ///< 356 PR#14416 Store number of valid history records for industries.
|
SLV_INDUSTRY_NUM_VALID_HISTORY, ///< 356 PR#14416 Store number of valid history records for industries.
|
||||||
|
SLV_SNOW_LINE_LEVEL, ///< 357 PR#14428 Replacement of snow coverage setting with snow line level setting
|
||||||
|
|
||||||
SL_MAX_VERSION, ///< Highest possible saveload version
|
SL_MAX_VERSION, ///< Highest possible saveload version
|
||||||
};
|
};
|
||||||
|
|
|
@ -76,7 +76,7 @@ ScriptController::ScriptController(::CompanyID company) :
|
||||||
|
|
||||||
/* static */ uint ScriptController::GetTick()
|
/* static */ uint ScriptController::GetTick()
|
||||||
{
|
{
|
||||||
return ScriptObject::GetActiveInstance().GetController()->ticks;
|
return ScriptObject::GetActiveInstance().GetController().ticks;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ int ScriptController::GetOpsTillSuspend()
|
/* static */ int ScriptController::GetOpsTillSuspend()
|
||||||
|
@ -96,9 +96,9 @@ ScriptController::ScriptController(::CompanyID company) :
|
||||||
|
|
||||||
/* static */ HSQOBJECT ScriptController::Import(const std::string &library, const std::string &class_name, int version)
|
/* static */ HSQOBJECT ScriptController::Import(const std::string &library, const std::string &class_name, int version)
|
||||||
{
|
{
|
||||||
ScriptController *controller = ScriptObject::GetActiveInstance().GetController();
|
ScriptController &controller = ScriptObject::GetActiveInstance().GetController();
|
||||||
Squirrel *engine = ScriptObject::GetActiveInstance().engine;
|
Squirrel &engine = *ScriptObject::GetActiveInstance().engine;
|
||||||
HSQUIRRELVM vm = engine->GetVM();
|
HSQUIRRELVM vm = engine.GetVM();
|
||||||
|
|
||||||
ScriptInfo *lib = ScriptObject::GetActiveInstance().FindLibrary(library, version);
|
ScriptInfo *lib = ScriptObject::GetActiveInstance().FindLibrary(library, version);
|
||||||
if (lib == nullptr) {
|
if (lib == nullptr) {
|
||||||
|
@ -114,11 +114,11 @@ ScriptController::ScriptController(::CompanyID company) :
|
||||||
|
|
||||||
std::string fake_class;
|
std::string fake_class;
|
||||||
|
|
||||||
LoadedLibraryList::iterator it = controller->loaded_library.find(library_name);
|
LoadedLibraryList::iterator it = controller.loaded_library.find(library_name);
|
||||||
if (it != controller->loaded_library.end()) {
|
if (it != controller.loaded_library.end()) {
|
||||||
fake_class = (*it).second;
|
fake_class = (*it).second;
|
||||||
} else {
|
} else {
|
||||||
int next_number = ++controller->loaded_library_count;
|
int next_number = ++controller.loaded_library_count;
|
||||||
|
|
||||||
/* Create a new fake internal name */
|
/* Create a new fake internal name */
|
||||||
fake_class = fmt::format("_internalNA{}", next_number);
|
fake_class = fmt::format("_internalNA{}", next_number);
|
||||||
|
@ -128,14 +128,14 @@ ScriptController::ScriptController(::CompanyID company) :
|
||||||
sq_pushstring(vm, fake_class);
|
sq_pushstring(vm, fake_class);
|
||||||
sq_newclass(vm, SQFalse);
|
sq_newclass(vm, SQFalse);
|
||||||
/* Load the library */
|
/* Load the library */
|
||||||
if (!engine->LoadScript(vm, lib->GetMainScript(), false)) {
|
if (!engine.LoadScript(vm, lib->GetMainScript(), false)) {
|
||||||
throw sq_throwerror(vm, fmt::format("there was a compile error when importing '{}' version {}", library, version));
|
throw sq_throwerror(vm, fmt::format("there was a compile error when importing '{}' version {}", library, version));
|
||||||
}
|
}
|
||||||
/* Create the fake class */
|
/* Create the fake class */
|
||||||
sq_newslot(vm, -3, SQFalse);
|
sq_newslot(vm, -3, SQFalse);
|
||||||
sq_pop(vm, 1);
|
sq_pop(vm, 1);
|
||||||
|
|
||||||
controller->loaded_library[library_name] = fake_class;
|
controller.loaded_library[library_name] = fake_class;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find the real class inside the fake class (like 'sets.Vector') */
|
/* Find the real class inside the fake class (like 'sets.Vector') */
|
||||||
|
|
|
@ -45,7 +45,7 @@ void SimpleCountedObject::Release()
|
||||||
* Get the storage associated with the current ScriptInstance.
|
* Get the storage associated with the current ScriptInstance.
|
||||||
* @return The storage.
|
* @return The storage.
|
||||||
*/
|
*/
|
||||||
static ScriptStorage *GetStorage()
|
static ScriptStorage &GetStorage()
|
||||||
{
|
{
|
||||||
return ScriptObject::GetActiveInstance().GetStorage();
|
return ScriptObject::GetActiveInstance().GetStorage();
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ ScriptObject::ActiveInstance::~ActiveInstance()
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptObject::DisableDoCommandScope::DisableDoCommandScope()
|
ScriptObject::DisableDoCommandScope::DisableDoCommandScope()
|
||||||
: AutoRestoreBackup(GetStorage()->allow_do_command, false)
|
: AutoRestoreBackup(GetStorage().allow_do_command, false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/* static */ ScriptInstance &ScriptObject::GetActiveInstance()
|
/* static */ ScriptInstance &ScriptObject::GetActiveInstance()
|
||||||
|
@ -78,181 +78,181 @@ ScriptObject::DisableDoCommandScope::DisableDoCommandScope()
|
||||||
/* static */ void ScriptObject::SetDoCommandDelay(uint ticks)
|
/* static */ void ScriptObject::SetDoCommandDelay(uint ticks)
|
||||||
{
|
{
|
||||||
assert(ticks > 0);
|
assert(ticks > 0);
|
||||||
GetStorage()->delay = ticks;
|
GetStorage().delay = ticks;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ uint ScriptObject::GetDoCommandDelay()
|
/* static */ uint ScriptObject::GetDoCommandDelay()
|
||||||
{
|
{
|
||||||
return GetStorage()->delay;
|
return GetStorage().delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void ScriptObject::SetDoCommandMode(ScriptModeProc *proc, ScriptObject *instance)
|
/* static */ void ScriptObject::SetDoCommandMode(ScriptModeProc *proc, ScriptObject *instance)
|
||||||
{
|
{
|
||||||
GetStorage()->mode = proc;
|
GetStorage().mode = proc;
|
||||||
GetStorage()->mode_instance = instance;
|
GetStorage().mode_instance = instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ ScriptModeProc *ScriptObject::GetDoCommandMode()
|
/* static */ ScriptModeProc *ScriptObject::GetDoCommandMode()
|
||||||
{
|
{
|
||||||
return GetStorage()->mode;
|
return GetStorage().mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ ScriptObject *ScriptObject::GetDoCommandModeInstance()
|
/* static */ ScriptObject *ScriptObject::GetDoCommandModeInstance()
|
||||||
{
|
{
|
||||||
return GetStorage()->mode_instance;
|
return GetStorage().mode_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void ScriptObject::SetDoCommandAsyncMode(ScriptAsyncModeProc *proc, ScriptObject *instance)
|
/* static */ void ScriptObject::SetDoCommandAsyncMode(ScriptAsyncModeProc *proc, ScriptObject *instance)
|
||||||
{
|
{
|
||||||
GetStorage()->async_mode = proc;
|
GetStorage().async_mode = proc;
|
||||||
GetStorage()->async_mode_instance = instance;
|
GetStorage().async_mode_instance = instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ ScriptAsyncModeProc *ScriptObject::GetDoCommandAsyncMode()
|
/* static */ ScriptAsyncModeProc *ScriptObject::GetDoCommandAsyncMode()
|
||||||
{
|
{
|
||||||
return GetStorage()->async_mode;
|
return GetStorage().async_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ ScriptObject *ScriptObject::GetDoCommandAsyncModeInstance()
|
/* static */ ScriptObject *ScriptObject::GetDoCommandAsyncModeInstance()
|
||||||
{
|
{
|
||||||
return GetStorage()->async_mode_instance;
|
return GetStorage().async_mode_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void ScriptObject::SetLastCommand(const CommandDataBuffer &data, Commands cmd)
|
/* static */ void ScriptObject::SetLastCommand(const CommandDataBuffer &data, Commands cmd)
|
||||||
{
|
{
|
||||||
ScriptStorage *s = GetStorage();
|
ScriptStorage &s = GetStorage();
|
||||||
Debug(script, 6, "SetLastCommand company={:02d} cmd={} data={}", s->root_company, cmd, FormatArrayAsHex(data));
|
Debug(script, 6, "SetLastCommand company={:02d} cmd={} data={}", s.root_company, cmd, FormatArrayAsHex(data));
|
||||||
s->last_data = data;
|
s.last_data = data;
|
||||||
s->last_cmd = cmd;
|
s.last_cmd = cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ bool ScriptObject::CheckLastCommand(const CommandDataBuffer &data, Commands cmd)
|
/* static */ bool ScriptObject::CheckLastCommand(const CommandDataBuffer &data, Commands cmd)
|
||||||
{
|
{
|
||||||
ScriptStorage *s = GetStorage();
|
ScriptStorage &s = GetStorage();
|
||||||
Debug(script, 6, "CheckLastCommand company={:02d} cmd={} data={}", s->root_company, cmd, FormatArrayAsHex(data));
|
Debug(script, 6, "CheckLastCommand company={:02d} cmd={} data={}", s.root_company, cmd, FormatArrayAsHex(data));
|
||||||
if (s->last_cmd != cmd) return false;
|
if (s.last_cmd != cmd) return false;
|
||||||
if (s->last_data != data) return false;
|
if (s.last_data != data) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void ScriptObject::SetDoCommandCosts(Money value)
|
/* static */ void ScriptObject::SetDoCommandCosts(Money value)
|
||||||
{
|
{
|
||||||
GetStorage()->costs = CommandCost(INVALID_EXPENSES, value); // Expense type is never read.
|
GetStorage().costs = CommandCost(INVALID_EXPENSES, value); // Expense type is never read.
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void ScriptObject::IncreaseDoCommandCosts(Money value)
|
/* static */ void ScriptObject::IncreaseDoCommandCosts(Money value)
|
||||||
{
|
{
|
||||||
GetStorage()->costs.AddCost(value);
|
GetStorage().costs.AddCost(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ Money ScriptObject::GetDoCommandCosts()
|
/* static */ Money ScriptObject::GetDoCommandCosts()
|
||||||
{
|
{
|
||||||
return GetStorage()->costs.GetCost();
|
return GetStorage().costs.GetCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void ScriptObject::SetLastError(ScriptErrorType last_error)
|
/* static */ void ScriptObject::SetLastError(ScriptErrorType last_error)
|
||||||
{
|
{
|
||||||
GetStorage()->last_error = last_error;
|
GetStorage().last_error = last_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ ScriptErrorType ScriptObject::GetLastError()
|
/* static */ ScriptErrorType ScriptObject::GetLastError()
|
||||||
{
|
{
|
||||||
return GetStorage()->last_error;
|
return GetStorage().last_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void ScriptObject::SetLastCost(Money last_cost)
|
/* static */ void ScriptObject::SetLastCost(Money last_cost)
|
||||||
{
|
{
|
||||||
GetStorage()->last_cost = last_cost;
|
GetStorage().last_cost = last_cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ Money ScriptObject::GetLastCost()
|
/* static */ Money ScriptObject::GetLastCost()
|
||||||
{
|
{
|
||||||
return GetStorage()->last_cost;
|
return GetStorage().last_cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void ScriptObject::SetRoadType(RoadType road_type)
|
/* static */ void ScriptObject::SetRoadType(RoadType road_type)
|
||||||
{
|
{
|
||||||
GetStorage()->road_type = road_type;
|
GetStorage().road_type = road_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ RoadType ScriptObject::GetRoadType()
|
/* static */ RoadType ScriptObject::GetRoadType()
|
||||||
{
|
{
|
||||||
return GetStorage()->road_type;
|
return GetStorage().road_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void ScriptObject::SetRailType(RailType rail_type)
|
/* static */ void ScriptObject::SetRailType(RailType rail_type)
|
||||||
{
|
{
|
||||||
GetStorage()->rail_type = rail_type;
|
GetStorage().rail_type = rail_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ RailType ScriptObject::GetRailType()
|
/* static */ RailType ScriptObject::GetRailType()
|
||||||
{
|
{
|
||||||
return GetStorage()->rail_type;
|
return GetStorage().rail_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void ScriptObject::SetLastCommandRes(bool res)
|
/* static */ void ScriptObject::SetLastCommandRes(bool res)
|
||||||
{
|
{
|
||||||
GetStorage()->last_command_res = res;
|
GetStorage().last_command_res = res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ bool ScriptObject::GetLastCommandRes()
|
/* static */ bool ScriptObject::GetLastCommandRes()
|
||||||
{
|
{
|
||||||
return GetStorage()->last_command_res;
|
return GetStorage().last_command_res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void ScriptObject::SetLastCommandResData(CommandDataBuffer data)
|
/* static */ void ScriptObject::SetLastCommandResData(CommandDataBuffer data)
|
||||||
{
|
{
|
||||||
GetStorage()->last_cmd_ret = std::move(data);
|
GetStorage().last_cmd_ret = std::move(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ const CommandDataBuffer &ScriptObject::GetLastCommandResData()
|
/* static */ const CommandDataBuffer &ScriptObject::GetLastCommandResData()
|
||||||
{
|
{
|
||||||
return GetStorage()->last_cmd_ret;
|
return GetStorage().last_cmd_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void ScriptObject::SetCompany(::CompanyID company)
|
/* static */ void ScriptObject::SetCompany(::CompanyID company)
|
||||||
{
|
{
|
||||||
if (GetStorage()->root_company == INVALID_OWNER) GetStorage()->root_company = company;
|
if (GetStorage().root_company == INVALID_OWNER) GetStorage().root_company = company;
|
||||||
GetStorage()->company = company;
|
GetStorage().company = company;
|
||||||
|
|
||||||
_current_company = company;
|
_current_company = company;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ ::CompanyID ScriptObject::GetCompany()
|
/* static */ ::CompanyID ScriptObject::GetCompany()
|
||||||
{
|
{
|
||||||
return GetStorage()->company;
|
return GetStorage().company;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ ::CompanyID ScriptObject::GetRootCompany()
|
/* static */ ::CompanyID ScriptObject::GetRootCompany()
|
||||||
{
|
{
|
||||||
return GetStorage()->root_company;
|
return GetStorage().root_company;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ bool ScriptObject::CanSuspend()
|
/* static */ bool ScriptObject::CanSuspend()
|
||||||
{
|
{
|
||||||
Squirrel *squirrel = ScriptObject::GetActiveInstance().engine;
|
Squirrel *squirrel = ScriptObject::GetActiveInstance().engine;
|
||||||
return GetStorage()->allow_do_command && squirrel->CanSuspend();
|
return GetStorage().allow_do_command && squirrel->CanSuspend();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ ScriptEventQueue &ScriptObject::GetEventQueue()
|
/* static */ ScriptEventQueue &ScriptObject::GetEventQueue()
|
||||||
{
|
{
|
||||||
return GetStorage()->event_queue;
|
return GetStorage().event_queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ ScriptLogTypes::LogData &ScriptObject::GetLogData()
|
/* static */ ScriptLogTypes::LogData &ScriptObject::GetLogData()
|
||||||
{
|
{
|
||||||
return GetStorage()->log_data;
|
return GetStorage().log_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void ScriptObject::SetCallbackVariable(int index, int value)
|
/* static */ void ScriptObject::SetCallbackVariable(int index, int value)
|
||||||
{
|
{
|
||||||
if (static_cast<size_t>(index) >= GetStorage()->callback_value.size()) GetStorage()->callback_value.resize(index + 1);
|
if (static_cast<size_t>(index) >= GetStorage().callback_value.size()) GetStorage().callback_value.resize(index + 1);
|
||||||
GetStorage()->callback_value[index] = value;
|
GetStorage().callback_value[index] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ int ScriptObject::GetCallbackVariable(int index)
|
/* static */ int ScriptObject::GetCallbackVariable(int index)
|
||||||
{
|
{
|
||||||
return GetStorage()->callback_value[index];
|
return GetStorage().callback_value[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ CommandCallbackData *ScriptObject::GetDoCommandCallback()
|
/* static */ CommandCallbackData *ScriptObject::GetDoCommandCallback()
|
||||||
|
@ -310,8 +310,8 @@ ScriptObject::DisableDoCommandScope::DisableDoCommandScope()
|
||||||
IncreaseDoCommandCosts(res.GetCost());
|
IncreaseDoCommandCosts(res.GetCost());
|
||||||
if (!_generating_world) {
|
if (!_generating_world) {
|
||||||
/* Charge a nominal fee for asynchronously executed commands */
|
/* Charge a nominal fee for asynchronously executed commands */
|
||||||
Squirrel *engine = ScriptObject::GetActiveInstance().engine;
|
Squirrel &engine = *ScriptObject::GetActiveInstance().engine;
|
||||||
Squirrel::DecreaseOps(engine->GetVM(), 100);
|
Squirrel::DecreaseOps(engine.GetVM(), 100);
|
||||||
}
|
}
|
||||||
if (callback != nullptr) {
|
if (callback != nullptr) {
|
||||||
/* Insert return value into to stack and throw a control code that
|
/* Insert return value into to stack and throw a control code that
|
||||||
|
|
|
@ -100,7 +100,7 @@ void ScriptInstance::Initialize(const std::string &main_script, const std::strin
|
||||||
|
|
||||||
void ScriptInstance::RegisterAPI()
|
void ScriptInstance::RegisterAPI()
|
||||||
{
|
{
|
||||||
squirrel_register_std(this->engine);
|
squirrel_register_std(*this->engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScriptInstance::LoadCompatibilityScript(std::string_view api_version, Subdirectory dir)
|
bool ScriptInstance::LoadCompatibilityScript(std::string_view api_version, Subdirectory dir)
|
||||||
|
@ -318,9 +318,10 @@ void ScriptInstance::CollectGarbage()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ScriptStorage *ScriptInstance::GetStorage()
|
ScriptStorage &ScriptInstance::GetStorage()
|
||||||
{
|
{
|
||||||
return this->storage;
|
assert(this->storage != nullptr);
|
||||||
|
return *this->storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptLogTypes::LogData &ScriptInstance::GetLogData()
|
ScriptLogTypes::LogData &ScriptInstance::GetLogData()
|
||||||
|
|
|
@ -91,7 +91,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Get the storage of this script.
|
* Get the storage of this script.
|
||||||
*/
|
*/
|
||||||
class ScriptStorage *GetStorage();
|
class ScriptStorage &GetStorage();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the log pointer of this script.
|
* Get the log pointer of this script.
|
||||||
|
@ -146,7 +146,11 @@ public:
|
||||||
/**
|
/**
|
||||||
* Get the controller attached to the instance.
|
* Get the controller attached to the instance.
|
||||||
*/
|
*/
|
||||||
class ScriptController *GetController() { return controller; }
|
class ScriptController &GetController()
|
||||||
|
{
|
||||||
|
assert(this->controller != nullptr);
|
||||||
|
return *this->controller;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the "this script died" value
|
* Return the "this script died" value
|
||||||
|
|
|
@ -536,7 +536,7 @@ void Squirrel::Initialize()
|
||||||
sq_setforeignptr(this->vm, this);
|
sq_setforeignptr(this->vm, this);
|
||||||
|
|
||||||
sq_pushroottable(this->vm);
|
sq_pushroottable(this->vm);
|
||||||
squirrel_register_global_std(this);
|
squirrel_register_global_std(*this);
|
||||||
|
|
||||||
/* Set consts table as delegate of root table, so consts/enums defined via require() are accessible */
|
/* Set consts table as delegate of root table, so consts/enums defined via require() are accessible */
|
||||||
sq_pushconsttable(this->vm);
|
sq_pushconsttable(this->vm);
|
||||||
|
|
|
@ -82,20 +82,20 @@ SQInteger SquirrelStd::notifyallexceptions(HSQUIRRELVM vm)
|
||||||
return SQ_ERROR;
|
return SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void squirrel_register_global_std(Squirrel *engine)
|
void squirrel_register_global_std(Squirrel &engine)
|
||||||
{
|
{
|
||||||
/* We don't use squirrel_helper here, as we want to register to the global
|
/* We don't use squirrel_helper here, as we want to register to the global
|
||||||
* scope and not to a class. */
|
* scope and not to a class. */
|
||||||
engine->AddMethod("require", &SquirrelStd::require, ".s");
|
engine.AddMethod("require", &SquirrelStd::require, ".s");
|
||||||
engine->AddMethod("notifyallexceptions", &SquirrelStd::notifyallexceptions, ".b");
|
engine.AddMethod("notifyallexceptions", &SquirrelStd::notifyallexceptions, ".b");
|
||||||
}
|
}
|
||||||
|
|
||||||
void squirrel_register_std(Squirrel *engine)
|
void squirrel_register_std(Squirrel &engine)
|
||||||
{
|
{
|
||||||
/* We don't use squirrel_helper here, as we want to register to the global
|
/* We don't use squirrel_helper here, as we want to register to the global
|
||||||
* scope and not to a class. */
|
* scope and not to a class. */
|
||||||
engine->AddMethod("min", &SquirrelStd::min, ".ii");
|
engine.AddMethod("min", &SquirrelStd::min, ".ii");
|
||||||
engine->AddMethod("max", &SquirrelStd::max, ".ii");
|
engine.AddMethod("max", &SquirrelStd::max, ".ii");
|
||||||
|
|
||||||
sqstd_register_mathlib(engine->GetVM());
|
sqstd_register_mathlib(engine.GetVM());
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,12 +52,12 @@ public:
|
||||||
/**
|
/**
|
||||||
* Register all standard functions we want to give to a script.
|
* Register all standard functions we want to give to a script.
|
||||||
*/
|
*/
|
||||||
void squirrel_register_std(Squirrel *engine);
|
void squirrel_register_std(Squirrel &engine);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register all standard functions that are available on first startup.
|
* Register all standard functions that are available on first startup.
|
||||||
* @note this set is very limited, and is only meant to load other scripts and things like that.
|
* @note this set is very limited, and is only meant to load other scripts and things like that.
|
||||||
*/
|
*/
|
||||||
void squirrel_register_global_std(Squirrel *engine);
|
void squirrel_register_global_std(Squirrel &engine);
|
||||||
|
|
||||||
#endif /* SQUIRREL_STD_HPP */
|
#endif /* SQUIRREL_STD_HPP */
|
||||||
|
|
|
@ -842,7 +842,7 @@ SettingsContainer &GetSettingsTree()
|
||||||
genworld->Add(new SettingEntry("difficulty.terrain_type"));
|
genworld->Add(new SettingEntry("difficulty.terrain_type"));
|
||||||
genworld->Add(new SettingEntry("game_creation.tgen_smoothness"));
|
genworld->Add(new SettingEntry("game_creation.tgen_smoothness"));
|
||||||
genworld->Add(new SettingEntry("game_creation.variety"));
|
genworld->Add(new SettingEntry("game_creation.variety"));
|
||||||
genworld->Add(new SettingEntry("game_creation.snow_coverage"));
|
genworld->Add(new SettingEntry("game_creation.snow_line_level"));
|
||||||
genworld->Add(new SettingEntry("game_creation.snow_line_height"));
|
genworld->Add(new SettingEntry("game_creation.snow_line_height"));
|
||||||
genworld->Add(new SettingEntry("game_creation.desert_coverage"));
|
genworld->Add(new SettingEntry("game_creation.desert_coverage"));
|
||||||
genworld->Add(new SettingEntry("game_creation.amount_of_rivers"));
|
genworld->Add(new SettingEntry("game_creation.amount_of_rivers"));
|
||||||
|
|
|
@ -363,8 +363,8 @@ struct GameCreationSettings {
|
||||||
uint8_t map_y; ///< Y size of map
|
uint8_t map_y; ///< Y size of map
|
||||||
uint8_t land_generator; ///< the landscape generator
|
uint8_t land_generator; ///< the landscape generator
|
||||||
uint8_t oil_refinery_limit; ///< distance oil refineries allowed from map edge
|
uint8_t oil_refinery_limit; ///< distance oil refineries allowed from map edge
|
||||||
uint8_t snow_line_height; ///< the configured snow line height (deduced from "snow_coverage")
|
uint8_t snow_line_height; ///< the configured snow line height (deduced from "snow_line_level" unless it is set on "custom")
|
||||||
uint8_t snow_coverage; ///< the amount of snow coverage on the map
|
uint8_t snow_line_level; ///< the approximate snow line level on the map
|
||||||
uint8_t desert_coverage; ///< the amount of desert coverage on the map
|
uint8_t desert_coverage; ///< the amount of desert coverage on the map
|
||||||
uint8_t heightmap_height; ///< highest mountain for heightmap (towards what it scales)
|
uint8_t heightmap_height; ///< highest mountain for heightmap (towards what it scales)
|
||||||
uint8_t tgen_smoothness; ///< how rough is the terrain from 0-3
|
uint8_t tgen_smoothness; ///< how rough is the terrain from 0-3
|
||||||
|
|
|
@ -3331,7 +3331,7 @@ draw_default_foundation:
|
||||||
auto result = GetRoadStopLayout(ti, stopspec, st, type, view, regs100);
|
auto result = GetRoadStopLayout(ti, stopspec, st, type, view, regs100);
|
||||||
if (result.has_value()) {
|
if (result.has_value()) {
|
||||||
if (stopspec->flags.Test(RoadStopSpecFlag::DrawModeRegister)) {
|
if (stopspec->flags.Test(RoadStopSpecFlag::DrawModeRegister)) {
|
||||||
stop_draw_mode = static_cast<RoadStopDrawMode>(regs100[0]);
|
stop_draw_mode = static_cast<RoadStopDrawModes>(regs100[0]);
|
||||||
}
|
}
|
||||||
if (type == StationType::RoadWaypoint && stop_draw_mode.Test(RoadStopDrawMode::WaypGround)) {
|
if (type == StationType::RoadWaypoint && stop_draw_mode.Test(RoadStopDrawMode::WaypGround)) {
|
||||||
draw_ground = true;
|
draw_ground = true;
|
||||||
|
|
|
@ -97,17 +97,17 @@ strval = STR_JUST_COMMA
|
||||||
cat = SC_BASIC
|
cat = SC_BASIC
|
||||||
|
|
||||||
[SDT_VAR]
|
[SDT_VAR]
|
||||||
var = game_creation.snow_coverage
|
var = game_creation.snow_line_level
|
||||||
type = SLE_UINT8
|
type = SLE_UINT8
|
||||||
from = SLV_MAPGEN_SETTINGS_REVAMP
|
from = SLV_SNOW_LINE_LEVEL
|
||||||
flags = SettingFlag::NewgameOnly
|
flags = SettingFlag::GuiDropdown, SettingFlag::NewgameOnly
|
||||||
def = DEF_SNOW_COVERAGE
|
def = 1
|
||||||
min = 0
|
min = 0
|
||||||
max = 100
|
max = 5
|
||||||
interval = 10
|
interval = 1
|
||||||
str = STR_CONFIG_SETTING_SNOW_COVERAGE
|
str = STR_CONFIG_SETTING_SNOW_LINE_LEVEL
|
||||||
strhelp = STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT
|
strhelp = STR_CONFIG_SETTING_SNOW_LINE_LEVEL_HELPTEXT
|
||||||
strval = STR_CONFIG_SETTING_SNOW_COVERAGE_VALUE
|
strval = STR_SNOW_LINE_LEVEL_VERY_LOW
|
||||||
cat = SC_BASIC
|
cat = SC_BASIC
|
||||||
|
|
||||||
[SDT_VAR]
|
[SDT_VAR]
|
||||||
|
|
|
@ -33,7 +33,6 @@ static const uint MIN_SNOWLINE_HEIGHT = 2; ///< Minimum snow
|
||||||
static const uint DEF_SNOWLINE_HEIGHT = 10; ///< Default snowline height
|
static const uint DEF_SNOWLINE_HEIGHT = 10; ///< Default snowline height
|
||||||
static const uint MAX_SNOWLINE_HEIGHT = (MAX_TILE_HEIGHT - 2); ///< Maximum allowed snowline height
|
static const uint MAX_SNOWLINE_HEIGHT = (MAX_TILE_HEIGHT - 2); ///< Maximum allowed snowline height
|
||||||
|
|
||||||
static const uint DEF_SNOW_COVERAGE = 40; ///< Default snow coverage.
|
|
||||||
static const uint DEF_DESERT_COVERAGE = 50; ///< Default desert coverage.
|
static const uint DEF_DESERT_COVERAGE = 50; ///< Default desert coverage.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -427,6 +427,7 @@ struct TimetableWindow : Window {
|
||||||
void DrawTimetablePanel(const Rect &r) const
|
void DrawTimetablePanel(const Rect &r) const
|
||||||
{
|
{
|
||||||
const Vehicle *v = this->vehicle;
|
const Vehicle *v = this->vehicle;
|
||||||
|
if (v->GetNumOrders() == 0) return;
|
||||||
Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
|
Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
|
||||||
int i = this->vscroll->GetPosition();
|
int i = this->vscroll->GetPosition();
|
||||||
VehicleOrderID order_id = (i + 1) / 2;
|
VehicleOrderID order_id = (i + 1) / 2;
|
||||||
|
|
|
@ -34,9 +34,7 @@ enum GenerateLandscapeWidgets : WidgetID {
|
||||||
WID_GL_START_DATE_TEXT, ///< Start year.
|
WID_GL_START_DATE_TEXT, ///< Start year.
|
||||||
WID_GL_START_DATE_UP, ///< Increase start year.
|
WID_GL_START_DATE_UP, ///< Increase start year.
|
||||||
|
|
||||||
WID_GL_SNOW_COVERAGE_DOWN, ///< Decrease snow coverage.
|
WID_GL_SNOW_LINE_LEVEL_PULLDOWN, ///< Snow line level.
|
||||||
WID_GL_SNOW_COVERAGE_TEXT, ///< Snow coverage.
|
|
||||||
WID_GL_SNOW_COVERAGE_UP, ///< Increase snow coverage.
|
|
||||||
|
|
||||||
WID_GL_DESERT_COVERAGE_DOWN, ///< Decrease desert coverage.
|
WID_GL_DESERT_COVERAGE_DOWN, ///< Decrease desert coverage.
|
||||||
WID_GL_DESERT_COVERAGE_TEXT, ///< Desert coverage.
|
WID_GL_DESERT_COVERAGE_TEXT, ///< Desert coverage.
|
||||||
|
|
Loading…
Reference in New Issue