1
0
Fork 0

Codefix: Rename variables to adhere codestyle

pull/13253/head
SamuXarick 2025-01-03 11:52:57 +00:00 committed by rubidium42
parent b60101853c
commit 6222cedcc1
1 changed files with 32 additions and 32 deletions

View File

@ -992,8 +992,8 @@ static void CreateDesertOrRainForest(uint desert_tropic_line)
*/ */
static bool FindSpring(TileIndex tile, void *) static bool FindSpring(TileIndex tile, void *)
{ {
int referenceHeight; int reference_height;
if (!IsTileFlat(tile, &referenceHeight) || IsWaterTile(tile)) return false; if (!IsTileFlat(tile, &reference_height) || IsWaterTile(tile)) return false;
/* In the tropics rivers start in the rainforest. */ /* In the tropics rivers start in the rainforest. */
if (_settings_game.game_creation.landscape == LT_TROPIC && GetTropicZone(tile) != TROPICZONE_RAINFOREST) return false; if (_settings_game.game_creation.landscape == LT_TROPIC && GetTropicZone(tile) != TROPICZONE_RAINFOREST) return false;
@ -1003,7 +1003,7 @@ static bool FindSpring(TileIndex tile, void *)
for (int dx = -1; dx <= 1; dx++) { for (int dx = -1; dx <= 1; dx++) {
for (int dy = -1; dy <= 1; dy++) { for (int dy = -1; dy <= 1; dy++) {
TileIndex t = TileAddWrap(tile, dx, dy); TileIndex t = TileAddWrap(tile, dx, dy);
if (t != INVALID_TILE && GetTileMaxZ(t) > referenceHeight) num++; if (t != INVALID_TILE && GetTileMaxZ(t) > reference_height) num++;
} }
} }
@ -1013,7 +1013,7 @@ static bool FindSpring(TileIndex tile, void *)
for (int dx = -16; dx <= 16; dx++) { for (int dx = -16; dx <= 16; dx++) {
for (int dy = -16; dy <= 16; dy++) { for (int dy = -16; dy <= 16; dy++) {
TileIndex t = TileAddWrap(tile, dx, dy); TileIndex t = TileAddWrap(tile, dx, dy);
if (t != INVALID_TILE && GetTileMaxZ(t) > referenceHeight + 2) return false; if (t != INVALID_TILE && GetTileMaxZ(t) > reference_height + 2) return false;
} }
} }
@ -1028,13 +1028,13 @@ static bool FindSpring(TileIndex tile, void *)
*/ */
static bool MakeLake(TileIndex tile, void *user_data) static bool MakeLake(TileIndex tile, void *user_data)
{ {
uint height = *(uint*)user_data; uint height_lake = *(uint*)user_data;
if (!IsValidTile(tile) || TileHeight(tile) != height || !IsTileFlat(tile)) return false; if (!IsValidTile(tile) || TileHeight(tile) != height_lake || !IsTileFlat(tile)) return false;
if (_settings_game.game_creation.landscape == LT_TROPIC && GetTropicZone(tile) == TROPICZONE_DESERT) return false; if (_settings_game.game_creation.landscape == LT_TROPIC && GetTropicZone(tile) == TROPICZONE_DESERT) return false;
for (DiagDirection d = DIAGDIR_BEGIN; d < DIAGDIR_END; d++) { for (DiagDirection d = DIAGDIR_BEGIN; d < DIAGDIR_END; d++) {
TileIndex t2 = tile + TileOffsByDiagDir(d); TileIndex t = tile + TileOffsByDiagDir(d);
if (IsWaterTile(t2)) { if (IsWaterTile(t)) {
MakeRiverAndModifyDesertZoneAround(tile); MakeRiverAndModifyDesertZoneAround(tile);
return false; return false;
} }
@ -1200,14 +1200,14 @@ static bool FlowsDown(TileIndex begin, TileIndex end)
{ {
assert(DistanceManhattan(begin, end) == 1); assert(DistanceManhattan(begin, end) == 1);
auto [slopeBegin, heightBegin] = GetTileSlopeZ(begin); auto [slope_begin, height_begin] = GetTileSlopeZ(begin);
auto [slopeEnd, heightEnd] = GetTileSlopeZ(end); auto [slope_end, height_end] = GetTileSlopeZ(end);
return heightEnd <= heightBegin && return height_end <= height_begin &&
/* Slope either is inclined or flat; rivers don't support other slopes. */ /* Slope either is inclined or flat; rivers don't support other slopes. */
(slopeEnd == SLOPE_FLAT || IsInclinedSlope(slopeEnd)) && (slope_end == SLOPE_FLAT || IsInclinedSlope(slope_end)) &&
/* Slope continues, then it must be lower... or either end must be flat. */ /* Slope continues, then it must be lower... or either end must be flat. */
((slopeEnd == slopeBegin && heightEnd < heightBegin) || slopeEnd == SLOPE_FLAT || slopeBegin == SLOPE_FLAT); ((slope_end == slope_begin && height_end < height_begin) || slope_end == SLOPE_FLAT || slope_begin == SLOPE_FLAT);
} }
/** Parameters for river generation to pass as AyStar user data. */ /** Parameters for river generation to pass as AyStar user data. */
@ -1324,7 +1324,7 @@ static std::tuple<bool, bool> FlowRiver(TileIndex spring, TileIndex begin, uint
# define SET_MARK(x) marks.insert(x) # define SET_MARK(x) marks.insert(x)
# define IS_MARKED(x) (marks.find(x) != marks.end()) # define IS_MARKED(x) (marks.find(x) != marks.end())
uint height = TileHeight(begin); uint height_begin = TileHeight(begin);
if (IsWaterTile(begin)) { if (IsWaterTile(begin)) {
return { DistanceManhattan(spring, begin) > min_river_length, GetTileZ(begin) == 0 }; return { DistanceManhattan(spring, begin) > min_river_length, GetTileZ(begin) == 0 };
@ -1344,18 +1344,18 @@ static std::tuple<bool, bool> FlowRiver(TileIndex spring, TileIndex begin, uint
end = queue.front(); end = queue.front();
queue.pop_front(); queue.pop_front();
uint height2 = TileHeight(end); uint height_end = TileHeight(end);
if (IsTileFlat(end) && (height2 < height || (height2 == height && IsWaterTile(end)))) { if (IsTileFlat(end) && (height_end < height_begin || (height_end == height_begin && IsWaterTile(end)))) {
found = true; found = true;
break; break;
} }
for (DiagDirection d = DIAGDIR_BEGIN; d < DIAGDIR_END; d++) { for (DiagDirection d = DIAGDIR_BEGIN; d < DIAGDIR_END; d++) {
TileIndex t2 = end + TileOffsByDiagDir(d); TileIndex t = end + TileOffsByDiagDir(d);
if (IsValidTile(t2) && !IS_MARKED(t2) && FlowsDown(end, t2)) { if (IsValidTile(t) && !IS_MARKED(t) && FlowsDown(end, t)) {
SET_MARK(t2); SET_MARK(t);
count++; count++;
queue.push_back(t2); queue.push_back(t);
} }
} }
} while (!queue.empty()); } while (!queue.empty());
@ -1368,26 +1368,26 @@ static std::tuple<bool, bool> FlowRiver(TileIndex spring, TileIndex begin, uint
/* Maybe we can make a lake. Find the Nth of the considered tiles. */ /* Maybe we can make a lake. Find the Nth of the considered tiles. */
std::set<TileIndex>::const_iterator cit = marks.cbegin(); std::set<TileIndex>::const_iterator cit = marks.cbegin();
std::advance(cit, RandomRange(count - 1)); std::advance(cit, RandomRange(count - 1));
TileIndex lakeCenter = *cit; TileIndex lake_centre = *cit;
if (IsValidTile(lakeCenter) && if (IsValidTile(lake_centre) &&
/* A river, or lake, can only be built on flat slopes. */ /* A river, or lake, can only be built on flat slopes. */
IsTileFlat(lakeCenter) && IsTileFlat(lake_centre) &&
/* We want the lake to be built at the height of the river. */ /* We want the lake to be built at the height of the river. */
TileHeight(begin) == TileHeight(lakeCenter) && TileHeight(begin) == TileHeight(lake_centre) &&
/* We don't want the lake at the entry of the valley. */ /* We don't want the lake at the entry of the valley. */
lakeCenter != begin && lake_centre != begin &&
/* We don't want lakes in the desert. */ /* We don't want lakes in the desert. */
(_settings_game.game_creation.landscape != LT_TROPIC || GetTropicZone(lakeCenter) != TROPICZONE_DESERT) && (_settings_game.game_creation.landscape != LT_TROPIC || GetTropicZone(lake_centre) != TROPICZONE_DESERT) &&
/* We only want a lake if the river is long enough. */ /* We only want a lake if the river is long enough. */
DistanceManhattan(spring, lakeCenter) > min_river_length) { DistanceManhattan(spring, lake_centre) > min_river_length) {
end = lakeCenter; end = lake_centre;
MakeRiverAndModifyDesertZoneAround(lakeCenter); MakeRiverAndModifyDesertZoneAround(lake_centre);
uint range = RandomRange(8) + 3; uint range = RandomRange(8) + 3;
CircularTileSearch(&lakeCenter, range, MakeLake, &height); CircularTileSearch(&lake_centre, range, MakeLake, &height_begin);
/* Call the search a second time so artefacts from going circular in one direction get (mostly) hidden. */ /* Call the search a second time so artefacts from going circular in one direction get (mostly) hidden. */
lakeCenter = end; lake_centre = end;
CircularTileSearch(&lakeCenter, range, MakeLake, &height); CircularTileSearch(&lake_centre, range, MakeLake, &height_begin);
found = true; found = true;
} }
} }