Merge branch 'everest_treeline-sx' into jgrpp
This commit is contained in:
@@ -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 <unistd.h>
|
||||
#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;
|
||||
|
@@ -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 :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}
|
||||
|
||||
@@ -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...
|
||||
|
@@ -1640,6 +1640,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}
|
||||
@@ -1763,6 +1768,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
|
||||
STR_CONFIG_SETTING_VIEWPORT_MAP_OPTIONS :{ORANGE}Map mode
|
||||
|
@@ -1774,9 +1774,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));
|
||||
|
@@ -342,6 +342,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.
|
||||
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
|
||||
uint16 maximum_signal_evaluations; ///< maximum number of programmable signals which may be evaluated in one pass
|
||||
byte simulated_wormhole_signals; ///< simulate signals in tunnel
|
||||
|
@@ -2529,6 +2529,28 @@ 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
|
||||
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""
|
||||
|
||||
[SDT_VAR]
|
||||
base = GameSettings
|
||||
var = construction.trees_around_snow_line_range
|
||||
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""
|
||||
|
||||
[SDT_VAR]
|
||||
base = GameSettings
|
||||
var = game_creation.custom_sea_level
|
||||
|
@@ -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
|
||||
*
|
||||
@@ -135,9 +179,30 @@ static TreeType GetRandomTreeType(TileIndex tile, uint seed)
|
||||
case LT_TEMPERATE:
|
||||
return (TreeType)(seed * TREE_COUNT_TEMPERATE / 256 + TREE_TEMPERATE);
|
||||
|
||||
case LT_ARCTIC:
|
||||
case LT_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);
|
||||
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 (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;
|
||||
}
|
||||
}
|
||||
case LT_TROPIC:
|
||||
switch (GetTropicZone(tile)) {
|
||||
case TROPICZONE_NORMAL: return (TreeType)(seed * TREE_COUNT_SUB_TROPICAL / 256 + TREE_SUB_TROPICAL);
|
||||
|
Reference in New Issue
Block a user