mirror of https://github.com/OpenTTD/OpenTTD
Codefix: Remove 'cur_pos' and move variable declarations closer to their usage
Removed unnecessary `cur_pos` variable and increment in the for loops. Moved the `current_river_length` and `radius` variable declarations closer to their usage.pull/13276/head
parent
6d9f30c343
commit
62e2d1fdb5
|
@ -1256,8 +1256,7 @@ static void River_FoundEndNode(AyStar *aystar, PathNode *current)
|
|||
River_UserData *data = (River_UserData *)aystar->user_data;
|
||||
|
||||
/* First, build the river without worrying about its width. */
|
||||
uint cur_pos = 0;
|
||||
for (PathNode *path = current->parent; path != nullptr; path = path->parent, cur_pos++) {
|
||||
for (PathNode *path = current->parent; path != nullptr; path = path->parent) {
|
||||
TileIndex tile = path->GetTile();
|
||||
if (!IsWaterTile(tile)) {
|
||||
MakeRiverAndModifyDesertZoneAround(tile);
|
||||
|
@ -1269,16 +1268,13 @@ static void River_FoundEndNode(AyStar *aystar, PathNode *current)
|
|||
*/
|
||||
if (_settings_game.game_creation.land_generator != LG_ORIGINAL && data->main_river) {
|
||||
const uint long_river_length = _settings_game.game_creation.min_river_length * 4;
|
||||
uint current_river_length;
|
||||
uint radius;
|
||||
|
||||
cur_pos = 0;
|
||||
for (PathNode *path = current->parent; path != nullptr; path = path->parent, cur_pos++) {
|
||||
for (PathNode *path = current->parent; path != nullptr; path = path->parent) {
|
||||
TileIndex tile = path->GetTile();
|
||||
|
||||
/* Check if we should widen river depending on how far we are away from the source. */
|
||||
current_river_length = DistanceManhattan(data->spring, tile);
|
||||
radius = std::min(3u, (current_river_length / (long_river_length / 3u)) + 1u);
|
||||
uint current_river_length = DistanceManhattan(data->spring, tile);
|
||||
uint radius = std::min(3u, (current_river_length / (long_river_length / 3u)) + 1u);
|
||||
|
||||
if (radius > 1) CircularTileSearch(&tile, radius, RiverMakeWider, (void *)&path->key.tile);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue