summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSamuXarick <43006711+SamuXarick@users.noreply.github.com>2019-02-23 12:16:12 +0000
committerNiels Martin Hansen <nielsm@indvikleren.dk>2019-02-23 13:16:12 +0100
commit4adb91202d7c0118b52daeab2c4e6b040b30e4a9 (patch)
tree464ac86f5ae02a13a43a3563c87ddcc8e2b25ca5 /src
parentfde5bd0ccfc56b71f85fb65562dc1eac1c446aee (diff)
downloadopenttd-4adb91202d7c0118b52daeab2c4e6b040b30e4a9.tar.xz
Fix: Remove desert around lakes upon generation
Diffstat (limited to 'src')
-rw-r--r--src/landscape.cpp8
-rw-r--r--src/water.h1
-rw-r--r--src/water_cmd.cpp2
3 files changed, 9 insertions, 2 deletions
diff --git a/src/landscape.cpp b/src/landscape.cpp
index b173709f3..b36f5c884 100644
--- a/src/landscape.cpp
+++ b/src/landscape.cpp
@@ -1063,6 +1063,9 @@ static bool MakeLake(TileIndex tile, void *user_data)
TileIndex t2 = tile + TileOffsByDiagDir(d);
if (IsWaterTile(t2)) {
MakeRiver(tile, Random());
+ /* Remove desert directly around the river tile. */
+ TileIndex t = tile;
+ CircularTileSearch(&t, RIVER_OFFSET_DESERT_DISTANCE, RiverModifyDesertZone, NULL);
return false;
}
}
@@ -1134,7 +1137,7 @@ static void River_FoundEndNode(AyStar *aystar, OpenListNode *current)
if (!IsWaterTile(tile)) {
MakeRiver(tile, Random());
/* Remove desert directly around the river tile. */
- CircularTileSearch(&tile, 5, RiverModifyDesertZone, NULL);
+ CircularTileSearch(&tile, RIVER_OFFSET_DESERT_DISTANCE, RiverModifyDesertZone, NULL);
}
}
}
@@ -1245,6 +1248,9 @@ static bool FlowRiver(TileIndex spring, TileIndex begin)
DistanceManhattan(spring, lakeCenter) > _settings_game.game_creation.min_river_length) {
end = lakeCenter;
MakeRiver(lakeCenter, Random());
+ /* Remove desert directly around the river tile. */
+ CircularTileSearch(&lakeCenter, RIVER_OFFSET_DESERT_DISTANCE, RiverModifyDesertZone, NULL);
+ lakeCenter = end;
uint range = RandomRange(8) + 3;
CircularTileSearch(&lakeCenter, range, MakeLake, &height);
/* Call the search a second time so artefacts from going circular in one direction get (mostly) hidden. */
diff --git a/src/water.h b/src/water.h
index cb7237fc7..1b804720f 100644
--- a/src/water.h
+++ b/src/water.h
@@ -40,6 +40,7 @@ void DrawShoreTile(Slope tileh);
void MakeWaterKeepingClass(TileIndex tile, Owner o);
bool RiverModifyDesertZone(TileIndex tile, void *data);
+static const uint RIVER_OFFSET_DESERT_DISTANCE = 5; ///< Circular tile search radius to create non-desert around a river tile.
bool IsWateredTile(TileIndex tile, Direction from);
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index 31dafe57f..03b321e68 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -428,7 +428,7 @@ CommandCost CmdBuildCanal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
MakeRiver(tile, Random());
if (_game_mode == GM_EDITOR) {
TileIndex tile2 = tile;
- CircularTileSearch(&tile2, 5, RiverModifyDesertZone, NULL);
+ CircularTileSearch(&tile2, RIVER_OFFSET_DESERT_DISTANCE, RiverModifyDesertZone, NULL);
}
break;