Cache highest snowline value
This commit is contained in:
@@ -128,6 +128,7 @@ static void _GenerateWorld()
|
|||||||
|
|
||||||
_settings_game.game_creation.snow_line_height = DEF_SNOWLINE_HEIGHT;
|
_settings_game.game_creation.snow_line_height = DEF_SNOWLINE_HEIGHT;
|
||||||
UpdateCachedSnowLine();
|
UpdateCachedSnowLine();
|
||||||
|
UpdateCachedSnowLineBounds();
|
||||||
} else {
|
} else {
|
||||||
GenerateLandscape(_gw.mode);
|
GenerateLandscape(_gw.mode);
|
||||||
GenerateClearTile();
|
GenerateClearTile();
|
||||||
|
@@ -103,6 +103,8 @@ static TileIndex _current_estuary = INVALID_TILE;
|
|||||||
static bool _is_main_river = false;
|
static bool _is_main_river = false;
|
||||||
|
|
||||||
byte _cached_snowline = 0;
|
byte _cached_snowline = 0;
|
||||||
|
byte _cached_highest_snowline = 0;
|
||||||
|
byte _cached_lowest_snowline = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map 2D viewport or smallmap coordinate to 3D world or tile coordinate.
|
* Map 2D viewport or smallmap coordinate to 3D world or tile coordinate.
|
||||||
@@ -657,6 +659,7 @@ void SetSnowLine(byte table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS])
|
|||||||
}
|
}
|
||||||
|
|
||||||
UpdateCachedSnowLine();
|
UpdateCachedSnowLine();
|
||||||
|
UpdateCachedSnowLineBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -677,23 +680,13 @@ void UpdateCachedSnowLine()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the highest possible snow line height, either variable or static.
|
* Cache the lowest and highest possible snow line heights, either variable or static.
|
||||||
* @return the highest snow line height.
|
|
||||||
* @ingroup SnowLineGroup
|
* @ingroup SnowLineGroup
|
||||||
*/
|
*/
|
||||||
byte HighestSnowLine()
|
void UpdateCachedSnowLineBounds()
|
||||||
{
|
{
|
||||||
return _snow_line == nullptr ? _settings_game.game_creation.snow_line_height : _snow_line->highest_value;
|
_cached_highest_snowline = _snow_line == nullptr ? _settings_game.game_creation.snow_line_height : _snow_line->highest_value;
|
||||||
}
|
_cached_lowest_snowline = _snow_line == nullptr ? _settings_game.game_creation.snow_line_height : _snow_line->lowest_value;
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the lowest possible snow line height, either variable or static.
|
|
||||||
* @return the lowest snow line height.
|
|
||||||
* @ingroup SnowLineGroup
|
|
||||||
*/
|
|
||||||
byte LowestSnowLine()
|
|
||||||
{
|
|
||||||
return _snow_line == nullptr ? _settings_game.game_creation.snow_line_height : _snow_line->lowest_value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -705,6 +698,7 @@ void ClearSnowLine()
|
|||||||
free(_snow_line);
|
free(_snow_line);
|
||||||
_snow_line = nullptr;
|
_snow_line = nullptr;
|
||||||
UpdateCachedSnowLine();
|
UpdateCachedSnowLine();
|
||||||
|
UpdateCachedSnowLineBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1540,6 +1534,7 @@ static void CalculateSnowLine()
|
|||||||
_settings_game.game_creation.snow_line_height = std::max(CalculateCoverageLine(_settings_game.game_creation.snow_coverage, 0), 2u);
|
_settings_game.game_creation.snow_line_height = std::max(CalculateCoverageLine(_settings_game.game_creation.snow_coverage, 0), 2u);
|
||||||
}
|
}
|
||||||
UpdateCachedSnowLine();
|
UpdateCachedSnowLine();
|
||||||
|
UpdateCachedSnowLineBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -30,8 +30,7 @@ bool IsSnowLineSet();
|
|||||||
void SetSnowLine(byte table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS]);
|
void SetSnowLine(byte table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS]);
|
||||||
byte GetSnowLineUncached();
|
byte GetSnowLineUncached();
|
||||||
void UpdateCachedSnowLine();
|
void UpdateCachedSnowLine();
|
||||||
byte HighestSnowLine();
|
void UpdateCachedSnowLineBounds();
|
||||||
byte LowestSnowLine();
|
|
||||||
void ClearSnowLine();
|
void ClearSnowLine();
|
||||||
|
|
||||||
inline byte GetSnowLine()
|
inline byte GetSnowLine()
|
||||||
@@ -40,6 +39,18 @@ inline byte GetSnowLine()
|
|||||||
return _cached_snowline;
|
return _cached_snowline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline byte HighestSnowLine()
|
||||||
|
{
|
||||||
|
extern byte _cached_highest_snowline;
|
||||||
|
return _cached_highest_snowline;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline byte LowestSnowLine()
|
||||||
|
{
|
||||||
|
extern byte _cached_lowest_snowline;
|
||||||
|
return _cached_lowest_snowline;
|
||||||
|
}
|
||||||
|
|
||||||
int GetSlopeZInCorner(Slope tileh, Corner corner);
|
int GetSlopeZInCorner(Slope tileh, Corner corner);
|
||||||
Slope GetFoundationSlope(TileIndex tile, int *z = nullptr);
|
Slope GetFoundationSlope(TileIndex tile, int *z = nullptr);
|
||||||
|
|
||||||
|
@@ -111,6 +111,7 @@ void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settin
|
|||||||
SetScaledTickVariables();
|
SetScaledTickVariables();
|
||||||
}
|
}
|
||||||
UpdateCachedSnowLine();
|
UpdateCachedSnowLine();
|
||||||
|
UpdateCachedSnowLineBounds();
|
||||||
|
|
||||||
ClearTraceRestrictMapping();
|
ClearTraceRestrictMapping();
|
||||||
ClearBridgeSimulatedSignalMapping();
|
ClearBridgeSimulatedSignalMapping();
|
||||||
|
@@ -635,6 +635,7 @@ bool AfterLoadGame()
|
|||||||
RebuildTownKdtree();
|
RebuildTownKdtree();
|
||||||
RebuildStationKdtree();
|
RebuildStationKdtree();
|
||||||
UpdateCachedSnowLine();
|
UpdateCachedSnowLine();
|
||||||
|
UpdateCachedSnowLineBounds();
|
||||||
|
|
||||||
_viewport_sign_kdtree_valid = false;
|
_viewport_sign_kdtree_valid = false;
|
||||||
|
|
||||||
@@ -3129,6 +3130,7 @@ bool AfterLoadGame()
|
|||||||
if (IsSavegameVersionBefore(SLV_164) && _settings_game.game_creation.snow_line_height >= MIN_SNOWLINE_HEIGHT * TILE_HEIGHT && SlXvIsFeatureMissing(XSLFI_CHILLPP)) {
|
if (IsSavegameVersionBefore(SLV_164) && _settings_game.game_creation.snow_line_height >= MIN_SNOWLINE_HEIGHT * TILE_HEIGHT && SlXvIsFeatureMissing(XSLFI_CHILLPP)) {
|
||||||
_settings_game.game_creation.snow_line_height /= TILE_HEIGHT;
|
_settings_game.game_creation.snow_line_height /= TILE_HEIGHT;
|
||||||
UpdateCachedSnowLine();
|
UpdateCachedSnowLine();
|
||||||
|
UpdateCachedSnowLineBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsSavegameVersionBefore(SLV_164) && !IsSavegameVersionBefore(SLV_32)) {
|
if (IsSavegameVersionBefore(SLV_164) && !IsSavegameVersionBefore(SLV_32)) {
|
||||||
|
Reference in New Issue
Block a user