From 7463c46a54bed2d21ee8e8e2e8cfe9d67f5f45dc Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Fri, 8 Jan 2021 12:02:38 +0100 Subject: [PATCH] Fix: for arctic and tropic, make sure we have at least a few hills (#8513) Without hills, not all industries can be generated, which means that with a default configuration you get errors. This is far from optimal, of course. This now forces that there is at least some hills, even when you are using very-flat. This is a stopgap solution, but a proper solution requires a full rewrite of the terrain generator, which is not a 2 minute (or even 2 week) job. To make sure flat is still flat-ish, reduce the default snow-line-height to 10, making it look a lot better on smaller maps. This is a compromise between being able to have flat maps and still having all industries on arctic. --- src/tgp.cpp | 22 +++++++++++++++++++++- src/tile_type.h | 2 +- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/tgp.cpp b/src/tgp.cpp index f6d902255d..190499cbc1 100644 --- a/src/tgp.cpp +++ b/src/tgp.cpp @@ -234,7 +234,27 @@ static height_t TGPGetMaxHeight() { 12, 19, 25, 31, 67, 75, 87 }, ///< Alpinist }; - int max_height_from_table = max_height[_settings_game.difficulty.terrain_type][std::min(MapLogX(), MapLogY()) - MIN_MAP_SIZE_BITS]; + int map_size_bucket = std::min(MapLogX(), MapLogY()) - MIN_MAP_SIZE_BITS; + int max_height_from_table = max_height[_settings_game.difficulty.terrain_type][map_size_bucket]; + + /* Arctic needs snow to have all industries, so make sure we allow TGP to generate this high. */ + if (_settings_game.game_creation.landscape == LT_ARCTIC) { + max_height_from_table += _settings_newgame.game_creation.snow_line_height; + /* Make flat a bit more flat by removing "very flat" from it, to somewhat compensate for the increase we just did. */ + if (_settings_game.difficulty.terrain_type > 0) { + max_height_from_table -= max_height[_settings_game.difficulty.terrain_type - 1][map_size_bucket]; + } + } + /* Tropic needs tropical forest to have all industries, so make sure we allow TGP to generate this high. + * Tropic forest always starts at 1/4th of the max height. */ + if (_settings_game.game_creation.landscape == LT_TROPIC) { + max_height_from_table += CeilDiv(_settings_game.construction.max_heightlevel, 4); + /* Make flat a bit more flat by removing "very flat" from it, to somewhat compensate for the increase we just did. */ + if (_settings_game.difficulty.terrain_type > 0) { + max_height_from_table -= max_height[_settings_game.difficulty.terrain_type - 1][map_size_bucket]; + } + } + return I2H(std::min(max_height_from_table, _settings_game.construction.max_heightlevel)); } diff --git a/src/tile_type.h b/src/tile_type.h index 132b566f0f..c1e7081f04 100644 --- a/src/tile_type.h +++ b/src/tile_type.h @@ -26,7 +26,7 @@ static const uint DEF_MAX_HEIGHTLEVEL = 30; ///< Default maxi static const uint MAX_MAX_HEIGHTLEVEL = MAX_TILE_HEIGHT; ///< Upper bound of maximum allowed heightlevel (in the construction settings) static const uint MIN_SNOWLINE_HEIGHT = 2; ///< Minimum snowline height -static const uint DEF_SNOWLINE_HEIGHT = 15; ///< 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