1
0
Fork 0

Codechange: Speed up ground density transition during river generation

This in turn avoids running the tile loop.
pull/13284/head
SamuXarick 2025-01-05 21:05:34 +00:00
parent bf02cb014b
commit b331d3f787
4 changed files with 22 additions and 9 deletions

View File

@ -202,7 +202,7 @@ static inline bool NeighbourIsNormal(TileIndex tile)
return false; return false;
} }
static void TileLoopClearDesert(TileIndex tile) void TileLoopClearDesert(TileIndex tile)
{ {
/* Current desert level - 0 if it is not desert */ /* Current desert level - 0 if it is not desert */
uint current = 0; uint current = 0;

View File

@ -15,4 +15,6 @@
void DrawHillyLandTile(const TileInfo *ti); void DrawHillyLandTile(const TileInfo *ti);
void DrawClearLandTile(const TileInfo *ti, uint8_t set); void DrawClearLandTile(const TileInfo *ti, uint8_t set);
void TileLoopClearDesert(TileIndex tile);
#endif /* CLEAR_FUNC_H */ #endif /* CLEAR_FUNC_H */

View File

@ -1400,7 +1400,7 @@ static void CreateRivers()
uint wells = Map::ScaleBySize(4 << _settings_game.game_creation.amount_of_rivers); uint wells = Map::ScaleBySize(4 << _settings_game.game_creation.amount_of_rivers);
const uint num_short_rivers = wells - std::max(1u, wells / 10); const uint num_short_rivers = wells - std::max(1u, wells / 10);
SetGeneratingWorldProgress(GWP_RIVER, wells + TILE_UPDATE_FREQUENCY / 64); // Include the tile loop calls below. SetGeneratingWorldProgress(GWP_RIVER, wells);
/* Try to create long rivers. */ /* Try to create long rivers. */
for (; wells > num_short_rivers; wells--) { for (; wells > num_short_rivers; wells--) {
@ -1424,12 +1424,6 @@ static void CreateRivers()
/* Widening rivers may have left some tiles requiring to be watered. */ /* Widening rivers may have left some tiles requiring to be watered. */
ConvertGroundTilesIntoWaterTiles(); ConvertGroundTilesIntoWaterTiles();
/* Run tile loop to update the ground density. */
for (uint i = 0; i != TILE_UPDATE_FREQUENCY; i++) {
if (i % 64 == 0) IncreaseGeneratingWorldProgress(GWP_RIVER);
RunTileLoop();
}
} }
/** /**

View File

@ -40,6 +40,7 @@
#include "water_cmd.h" #include "water_cmd.h"
#include "landscape_cmd.h" #include "landscape_cmd.h"
#include "pathfinder/water_regions.h" #include "pathfinder/water_regions.h"
#include "clear_func.h"
#include "table/strings.h" #include "table/strings.h"
@ -443,7 +444,23 @@ CommandCost CmdBuildLock(DoCommandFlag flags, TileIndex tile)
/** Callback to create non-desert around a river tile. */ /** Callback to create non-desert around a river tile. */
static bool RiverModifyDesertZone(TileIndex tile, void *) static bool RiverModifyDesertZone(TileIndex tile, void *)
{ {
if (GetTropicZone(tile) == TROPICZONE_DESERT) SetTropicZone(tile, TROPICZONE_NORMAL); if (GetTropicZone(tile) == TROPICZONE_DESERT) {
SetTropicZone(tile, TROPICZONE_NORMAL);
/* Speed up the transition from desert to grass. */
if (IsTileType(tile, MP_CLEAR)) TileLoopClearDesert(tile);
for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) {
const TileIndex t = tile + TileOffsByDiagDir(dir);
if (!IsValidTile(t)) continue;
if (!IsTileType(t, MP_CLEAR)) continue;
/* Speed up the transition of adjacent desert tile density. */
TileLoopClearDesert(t);
}
}
return false; return false;
} }