Import Everest treeline patch

This commit is contained in:
Jonathan G Rennison 2015-08-21 18:16:15 +01:00
parent 8c389a2a96
commit efe85200f0
3 changed files with 45 additions and 4 deletions

View File

@ -310,6 +310,8 @@ struct ConstructionSettings {
uint8 industry_platform; ///< the amount of flat land around an industry
bool freeform_edges; ///< allow terraforming the tiles at the map edges
uint8 extra_tree_placement; ///< (dis)allow building extra trees in-game
uint8 trees_around_snow_line_range; ///< range around snowline for mixed and arctic forest.
uint32 no_trees_on_this_level; ///< option to avoid growth of trees on certain tile level.
uint8 command_pause_level; ///< level/amount of commands that can't be executed while paused
uint32 terraform_per_64k_frames; ///< how many tile heights may, over a long period, be terraformed per 65536 frames?

View File

@ -2308,6 +2308,24 @@ strhelp = STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_HELPTEXT
strval = STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_NONE
cat = SC_BASIC
[SDT_VAR]
base = GameSettings
var = construction.trees_around_snow_line_range
type = SLE_UINT8
def = 0
min = 0
max = 15
cat = SC_BASIC
[SDT_VAR]
base = GameSettings
var = construction.no_trees_on_this_level
type = SLE_UINT32
def = 0
min = 0
max = UINT32_MAX
cat = SC_BASIC
[SDT_VAR]
base = GameSettings
var = game_creation.custom_sea_level

View File

@ -131,13 +131,34 @@ static void PlantTreesOnTile(TileIndex tile, TreeType treetype, uint count, uint
*/
static TreeType GetRandomTreeType(TileIndex tile, uint seed)
{
/* no_trees_on_this_level example: 0xDC96521 is no trees on z levels 13,12,9,6,5,2,1. Set to 0 gives you original gameplay. (See openttd.cfg) */
uint32 no_tree = _settings_game.construction.no_trees_on_this_level;
byte range = _settings_game.construction.trees_around_snow_line_range;
switch (_settings_game.game_creation.landscape) {
case LT_TEMPERATE:
if (no_tree == 0) return (TreeType)(seed * TREE_COUNT_TEMPERATE / 256 + TREE_TEMPERATE);
case LT_ARCTIC: {
if (no_tree == 0) return (TreeType)(seed * TREE_COUNT_SUB_ARCTIC / 256 + TREE_SUB_ARCTIC);
int z = GetTileZ(tile);
if (z > _settings_game.game_creation.snow_line_height + (2 * range)) return TREE_INVALID; // Above tree line.
/* no_trees_on_this_level */
for (; no_tree != 0;) {
if ((int)(no_tree & 0xF) == z) return TREE_INVALID;
no_tree = no_tree >> 4;
}
if (z > (int)_settings_game.game_creation.snow_line_height - range) {
/* Below snow level mixed forest. Above is Arctic trees and thinning out. */
if (z < _settings_game.game_creation.snow_line_height) {
return (seed & 1) ? (TreeType)(seed * TREE_COUNT_SUB_ARCTIC / 256 + TREE_SUB_ARCTIC) : (TreeType)(seed * TREE_COUNT_TEMPERATE / 256 + TREE_TEMPERATE);
} else {
return (seed & 1) ? TREE_INVALID : (TreeType)(seed * TREE_COUNT_SUB_ARCTIC / 256 + TREE_SUB_ARCTIC);
}
}
return (TreeType)(seed * TREE_COUNT_TEMPERATE / 256 + TREE_TEMPERATE);
case LT_ARCTIC:
return (TreeType)(seed * TREE_COUNT_SUB_ARCTIC / 256 + TREE_SUB_ARCTIC);
}
case LT_TROPIC:
switch (GetTropicZone(tile)) {
case TROPICZONE_NORMAL: return (TreeType)(seed * TREE_COUNT_SUB_TROPICAL / 256 + TREE_SUB_TROPICAL);