From 284c9dd3422d9adbd71f4fdbf8fd59a89c0b902e Mon Sep 17 00:00:00 2001 From: translators Date: Wed, 19 Aug 2015 17:45:15 +0000 Subject: [PATCH 1/6] (svn r27387) -Update from WebTranslator v3.0: dutch - 2 changes by TheTycoonist --- src/lang/dutch.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lang/dutch.txt b/src/lang/dutch.txt index c051f4fdba..a36aecba4b 100644 --- a/src/lang/dutch.txt +++ b/src/lang/dutch.txt @@ -30,7 +30,7 @@ STR_CARGO_PLURAL_NOTHING : STR_CARGO_PLURAL_PASSENGERS :Passagiers STR_CARGO_PLURAL_COAL :Kolen STR_CARGO_PLURAL_MAIL :Post -STR_CARGO_PLURAL_OIL :Olie +STR_CARGO_PLURAL_OIL :Ruwe olie STR_CARGO_PLURAL_LIVESTOCK :Vee STR_CARGO_PLURAL_GOODS :Goederen STR_CARGO_PLURAL_GRAIN :Graan @@ -4357,7 +4357,7 @@ STR_ERROR_CAN_T_PURCHASE_THIS_LAND :{WHITE}Kan dit STR_ERROR_YOU_ALREADY_OWN_IT :{WHITE}... het is al van jou! # Group related errors -STR_ERROR_GROUP_CAN_T_CREATE :{WHITE}Kan groep niet maken... +STR_ERROR_GROUP_CAN_T_CREATE :{WHITE}Kan groep niet creƫren... STR_ERROR_GROUP_CAN_T_DELETE :{WHITE}Kan deze groep niet verwijderen... STR_ERROR_GROUP_CAN_T_RENAME :{WHITE}Kan deze groep niet hernoemen... STR_ERROR_GROUP_CAN_T_SET_PARENT :{WHITE}Kan huidige groep niet instellen... From 8f36c49ffa20707d804774f40af2bbb5ac797fcd Mon Sep 17 00:00:00 2001 From: translators Date: Thu, 20 Aug 2015 17:45:15 +0000 Subject: [PATCH 2/6] (svn r27388) -Update from WebTranslator v3.0: dutch - 4 changes by TheTycoonist --- src/lang/dutch.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lang/dutch.txt b/src/lang/dutch.txt index a36aecba4b..947f0736c8 100644 --- a/src/lang/dutch.txt +++ b/src/lang/dutch.txt @@ -30,7 +30,7 @@ STR_CARGO_PLURAL_NOTHING : STR_CARGO_PLURAL_PASSENGERS :Passagiers STR_CARGO_PLURAL_COAL :Kolen STR_CARGO_PLURAL_MAIL :Post -STR_CARGO_PLURAL_OIL :Ruwe olie +STR_CARGO_PLURAL_OIL :Aardolie STR_CARGO_PLURAL_LIVESTOCK :Vee STR_CARGO_PLURAL_GOODS :Goederen STR_CARGO_PLURAL_GRAIN :Graan @@ -64,7 +64,7 @@ STR_CARGO_SINGULAR_NOTHING : STR_CARGO_SINGULAR_PASSENGER :Passagier STR_CARGO_SINGULAR_COAL :Kolen STR_CARGO_SINGULAR_MAIL :Post -STR_CARGO_SINGULAR_OIL :Olie +STR_CARGO_SINGULAR_OIL :Aardolie STR_CARGO_SINGULAR_LIVESTOCK :Vee STR_CARGO_SINGULAR_GOODS :Goederen STR_CARGO_SINGULAR_GRAIN :Graan @@ -98,7 +98,7 @@ STR_QUANTITY_NOTHING : STR_QUANTITY_PASSENGERS :{COMMA}{NBSP}passagier{P "" s} STR_QUANTITY_COAL :{WEIGHT_LONG} kolen STR_QUANTITY_MAIL :{COMMA}{NBSP}zak{P "" ken} post -STR_QUANTITY_OIL :{VOLUME_LONG} olie +STR_QUANTITY_OIL :{VOLUME_LONG} Vaten Olie STR_QUANTITY_LIVESTOCK :{COMMA}{NBSP}stuk{P "" s} vee STR_QUANTITY_GOODS :{COMMA}{NBSP}krat{P "" ten} goederen STR_QUANTITY_GRAIN :{WEIGHT_LONG} graan @@ -168,7 +168,7 @@ STR_ABBREV_ALL :{TINY_FONT}ALLE STR_PASSENGERS :{COMMA}{NBSP}passagier{P "" s} STR_BAGS :{COMMA}{NBSP}zak{P "" ken} STR_TONS :{COMMA}{NBSP}ton -STR_LITERS :{COMMA}{NBSP}liter +STR_LITERS :{COMMA}{NBSP}liter{P "" s} STR_ITEMS :{COMMA}{NBSP}stuk{P "" s} STR_CRATES :{COMMA}{NBSP}krat{P "" ten} From 8c389a2a96dd532eb6db8ce11c9b8e73a5239549 Mon Sep 17 00:00:00 2001 From: frosch Date: Thu, 20 Aug 2015 20:47:45 +0000 Subject: [PATCH 3/6] (svn r27389) -Fix: There are two different availability conditions for fdatasync in the manpage. Use them both, since at least on some MinGW versions one is not enough. --- src/ini.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ini.cpp b/src/ini.cpp index ccce192393..905ebfacf8 100644 --- a/src/ini.cpp +++ b/src/ini.cpp @@ -16,7 +16,6 @@ #include "fileio_func.h" #if (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309L) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 500) -# define WITH_FDATASYNC # include #endif @@ -80,7 +79,7 @@ bool IniFile::SaveToDisk(const char *filename) * APIs to do so. We only need to flush the data as the metadata itself * (modification date etc.) is not important to us; only the real data is. */ -#ifdef WITH_FDATASYNC +#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0 int ret = fdatasync(fileno(f)); fclose(f); if (ret != 0) return false; From efe85200f03a810c8b55a1dec185743fb89a0e12 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Fri, 21 Aug 2015 18:16:15 +0100 Subject: [PATCH 4/6] Import Everest treeline patch --- src/settings_type.h | 2 ++ src/table/settings.ini | 18 ++++++++++++++++++ src/tree_cmd.cpp | 29 +++++++++++++++++++++++++---- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/src/settings_type.h b/src/settings_type.h index 41366a7719..45b425f454 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -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? diff --git a/src/table/settings.ini b/src/table/settings.ini index f314f21e92..d43b334af8 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -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 diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp index 4fcda82d81..bb657ba108 100644 --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -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); From 381d11096fc9ab5ad9cba3d1a94ee212a8d47432 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Fri, 21 Aug 2015 21:11:43 +0100 Subject: [PATCH 5/6] Bin no_trees_on_this_level, use exp. decay away from snow line. Probability of placing an arctic tree is now an exponential decay function of height distance from the snow line, instead of the previous 50% blocks. This results in a more gradual thinning out of arctic trees in each direction. The algorithm is: p = exp(-3 * distance / range_setting), using a rather crude approximation of the exponential function. The no_trees_on_this_level setting is not really useful, and its dual behaviour to disallow discrete height levels and turn on the snow line behaviour is unintuitive. Replace it with a simple on/off setting. --- src/settings_type.h | 2 +- src/table/settings.ini | 23 ++++++------ src/tree_cmd.cpp | 84 ++++++++++++++++++++++++++++++++---------- 3 files changed, 76 insertions(+), 33 deletions(-) diff --git a/src/settings_type.h b/src/settings_type.h index 45b425f454..45f8568285 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -311,7 +311,7 @@ struct ConstructionSettings { 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. + bool trees_around_snow_line_enabled; ///< enable mixed and arctic forest around snowline, and no trees above snowline 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? diff --git a/src/table/settings.ini b/src/table/settings.ini index 934ff888ec..78d2f0d1f3 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -2310,23 +2310,22 @@ strhelp = STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_HELPTEXT strval = STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_NONE cat = SC_BASIC +[SDT_BOOL] +base = GameSettings +var = construction.trees_around_snow_line_enabled +def = true +cat = SC_BASIC +patxname = ""everest_treeline.construction.trees_around_snow_line_enabled"" + [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 +def = 8 +min = 1 +max = 20 cat = SC_BASIC +patxname = ""everest_treeline.construction.trees_around_snow_line_range"" [SDT_VAR] base = GameSettings diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp index bb657ba108..9042ad1677 100644 --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -118,6 +118,50 @@ static void PlantTreesOnTile(TileIndex tile, TreeType treetype, uint count, uint MakeTree(tile, treetype, count, growth, ground, density); } +/** + * Previous value of _settings_game.construction.trees_around_snow_line_range + * used to calculate _arctic_tree_occurance + */ +static uint8 _previous_trees_around_snow_line_range = 255; + +/** + * Array of probabilities for artic trees to appear, + * by normalised distance from snow line + */ +static uint8 _arctic_tree_occurance[24]; + +/** Recalculate _arctic_tree_occurance */ +static void RecalculateArcticTreeOccuranceArray() +{ + /* + * Approximate: 256 * exp(-3 * distance / range) + * By using: + * 256 * ((1 + (-3 * distance / range) / 6) ** 6) + * ((256 - (128 * distance / range)) ** 6) >> (5 * 8); + */ + uint8 range = _settings_game.construction.trees_around_snow_line_range; + _previous_trees_around_snow_line_range = range; + _arctic_tree_occurance[0] = 255; + uint i = 1; + for (; i < lengthof(_arctic_tree_occurance); i++) { + if (range == 0) break; + uint x = 256 - ((128 * i) / range); + uint32 output = x; + output *= x; + output *= x; + output *= x; + output >>= 16; + output *= x; + output *= x; + output >>= 24; + if (output == 0) break; + _arctic_tree_occurance[i] = output; + } + for (; i < lengthof(_arctic_tree_occurance); i++) { + _arctic_tree_occurance[i] = 0; + } +} + /** * Get a random TreeType for the given tile based on a given seed * @@ -131,33 +175,33 @@ 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); + 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); + if (!_settings_game.construction.trees_around_snow_line_enabled) { + return (TreeType)(seed * TREE_COUNT_SUB_ARCTIC / 256 + TREE_SUB_ARCTIC); + } + + uint8 range = _settings_game.construction.trees_around_snow_line_range; + if (range != _previous_trees_around_snow_line_range) RecalculateArcticTreeOccuranceArray(); 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; + int height_above_snow_line = z - _settings_game.game_creation.snow_line_height; + uint normalised_distance = (height_above_snow_line < 0) ? -height_above_snow_line : height_above_snow_line + 1; + bool arctic_tree = false; + if (normalised_distance < lengthof(_arctic_tree_occurance)) { + uint adjusted_seed = (seed ^ tile) & 0xFF; + arctic_tree = adjusted_seed < _arctic_tree_occurance[normalised_distance]; } - 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); - } + if (height_above_snow_line < 0) { + /* Below snow level mixed forest. */ + return (arctic_tree) ? (TreeType)(seed * TREE_COUNT_SUB_ARCTIC / 256 + TREE_SUB_ARCTIC) : (TreeType)(seed * TREE_COUNT_TEMPERATE / 256 + TREE_TEMPERATE); + } else { + /* Above is Arctic trees and thinning out. */ + return (arctic_tree) ? (TreeType)(seed * TREE_COUNT_SUB_ARCTIC / 256 + TREE_SUB_ARCTIC) : TREE_INVALID; } - return (TreeType)(seed * TREE_COUNT_TEMPERATE / 256 + TREE_TEMPERATE); } case LT_TROPIC: switch (GetTropicZone(tile)) { From efb1ba33373e703fbd455b39095d1e0a171c285e Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Fri, 21 Aug 2015 21:12:25 +0100 Subject: [PATCH 6/6] Add GUI settings and setting/help texts. Move tree-related functions into their own GUI sub-category. --- src/lang/english.txt | 6 ++++++ src/settings_gui.cpp | 7 ++++++- src/table/settings.ini | 5 +++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/lang/english.txt b/src/lang/english.txt index ad29b3d596..94bac6285c 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1568,6 +1568,11 @@ STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_NONE :None {RED}(brea STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_RAINFOREST :Only in rain forests STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_ALL :Everywhere +STR_CONFIG_SETTING_TREES_AROUND_SNOWLINE :Adjusted arctic tree placement: {STRING2} +STR_CONFIG_SETTING_TREES_AROUND_SNOWLINE_HELPTEXT :Adjust placement of trees around snow line in artic climate. Trees thin out above snowline. Trees are a mix of arctic and temperate just below snowline. Below that trees are temperate. +STR_CONFIG_SETTING_TREES_AROUND_SNOWLINE_RANGE :Arctic tree range: {STRING2} +STR_CONFIG_SETTING_TREES_AROUND_SNOWLINE_RANGE_HELPTEXT :Approximate range of arctic trees around snow line + STR_CONFIG_SETTING_TOOLBAR_POS :Position of main toolbar: {STRING2} STR_CONFIG_SETTING_TOOLBAR_POS_HELPTEXT :Horizontal position of the main toolbar at the top of the screen STR_CONFIG_SETTING_STATUSBAR_POS :Position of status bar: {STRING2} @@ -1685,6 +1690,7 @@ STR_CONFIG_SETTING_ENVIRONMENT_AUTHORITIES :{ORANGE}Authori STR_CONFIG_SETTING_ENVIRONMENT_TOWNS :{ORANGE}Towns STR_CONFIG_SETTING_ENVIRONMENT_INDUSTRIES :{ORANGE}Industries STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST :{ORANGE}Cargo distribution +STR_CONFIG_SETTING_ENVIRONMENT_TREES :{ORANGE}Trees STR_CONFIG_SETTING_AI :{ORANGE}Competitors STR_CONFIG_SETTING_AI_NPC :{ORANGE}Computer players diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 0652d1bd81..27f2a5784d 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1719,9 +1719,14 @@ static SettingsContainer &GetSettingsTree() cdist->Add(new SettingEntry("linkgraph.demand_size")); cdist->Add(new SettingEntry("linkgraph.short_path_saturation")); } + SettingsPage *treedist = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_TREES)); + { + treedist->Add(new SettingEntry("construction.extra_tree_placement")); + treedist->Add(new SettingEntry("construction.trees_around_snow_line_enabled")); + treedist->Add(new SettingEntry("construction.trees_around_snow_line_range")); + } environment->Add(new SettingEntry("station.modified_catchment")); - environment->Add(new SettingEntry("construction.extra_tree_placement")); } SettingsPage *ai = main->Add(new SettingsPage(STR_CONFIG_SETTING_AI)); diff --git a/src/table/settings.ini b/src/table/settings.ini index 78d2f0d1f3..d1c169bf47 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -2314,6 +2314,8 @@ cat = SC_BASIC base = GameSettings var = construction.trees_around_snow_line_enabled def = true +str = STR_CONFIG_SETTING_TREES_AROUND_SNOWLINE +strhelp = STR_CONFIG_SETTING_TREES_AROUND_SNOWLINE_HELPTEXT cat = SC_BASIC patxname = ""everest_treeline.construction.trees_around_snow_line_enabled"" @@ -2324,6 +2326,9 @@ type = SLE_UINT8 def = 8 min = 1 max = 20 +str = STR_CONFIG_SETTING_TREES_AROUND_SNOWLINE_RANGE +strhelp = STR_CONFIG_SETTING_TREES_AROUND_SNOWLINE_RANGE_HELPTEXT +strval = STR_JUST_COMMA cat = SC_BASIC patxname = ""everest_treeline.construction.trees_around_snow_line_range""