From 46dc6da270c09f289051eb4b26ce92fd1584e259 Mon Sep 17 00:00:00 2001 From: SamuXarick <43006711+SamuXarick@users.noreply.github.com> Date: Thu, 26 Jan 2023 20:57:25 +0000 Subject: [PATCH] Codechange: Make void tiles flood edge tiles, instead of edge tiles flooding themselves (#8517) --- src/clear_cmd.cpp | 10 ---------- src/void_cmd.cpp | 4 +++- src/water_cmd.cpp | 7 +++++-- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp index 30edb95069..8e87f42f49 100644 --- a/src/clear_cmd.cpp +++ b/src/clear_cmd.cpp @@ -13,7 +13,6 @@ #include "landscape.h" #include "genworld.h" #include "viewport_func.h" -#include "water.h" #include "core/random_func.hpp" #include "newgrf_generic.h" #include "landscape_cmd.h" @@ -248,15 +247,6 @@ static void TileLoopClearDesert(TileIndex tile) static void TileLoop_Clear(TileIndex tile) { - /* If the tile is at any edge flood it to prevent maps without water. */ - if (_settings_game.construction.freeform_edges && DistanceFromEdge(tile) == 1) { - int z; - if (IsTileFlat(tile, &z) && z == 0) { - DoFloodTile(tile); - MarkTileDirtyByTile(tile); - return; - } - } AmbientSoundEffect(tile); switch (_settings_game.game_creation.landscape) { diff --git a/src/void_cmd.cpp b/src/void_cmd.cpp index cf159d69cc..f5716e3f8d 100644 --- a/src/void_cmd.cpp +++ b/src/void_cmd.cpp @@ -12,6 +12,7 @@ #include "command_func.h" #include "viewport_func.h" #include "slope_func.h" +#include "water.h" #include "table/strings.h" #include "table/sprites.h" @@ -53,7 +54,8 @@ static void GetTileDesc_Void(TileIndex tile, TileDesc *td) static void TileLoop_Void(TileIndex tile) { - /* not used */ + /* Floods adjacent edge tile to prevent maps without water. */ + TileLoop_Water(tile); } static void ChangeTileOwner_Void(TileIndex tile, Owner old_owner, Owner new_owner) diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index e34c3c103c..85d9fa6f7b 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -1089,6 +1089,9 @@ FloodingBehaviour GetFloodingBehaviour(TileIndex tile) case MP_TREES: return (GetTreeGround(tile) == TREE_GROUND_SHORE ? FLOOD_DRYUP : FLOOD_NONE); + case MP_VOID: + return FLOOD_ACTIVE; + default: return FLOOD_NONE; } @@ -1240,7 +1243,7 @@ void TileLoop_Water(TileIndex tile) Slope slope_here = GetFoundationSlope(tile) & ~SLOPE_HALFTILE_MASK & ~SLOPE_STEEP; for (uint dir : SetBitIterator(_flood_from_dirs[slope_here])) { TileIndex dest = tile + TileOffsByDir((Direction)dir); - if (!IsValidTile(dest)) continue; + if (dest >= Map::Size()) continue; FloodingBehaviour dest_behaviour = GetFloodingBehaviour(dest); if ((dest_behaviour == FLOOD_ACTIVE) || (dest_behaviour == FLOOD_PASSIVE)) return; @@ -1279,7 +1282,7 @@ void ConvertGroundTilesIntoWaterTiles() for (uint dir : SetBitIterator(_flood_from_dirs[slope & ~SLOPE_STEEP])) { TileIndex dest = TileAddByDir(tile, (Direction)dir); Slope slope_dest = GetTileSlope(dest) & ~SLOPE_STEEP; - if (slope_dest == SLOPE_FLAT || IsSlopeWithOneCornerRaised(slope_dest)) { + if (slope_dest == SLOPE_FLAT || IsSlopeWithOneCornerRaised(slope_dest) || IsTileType(dest, MP_VOID)) { MakeShore(tile); break; } -- 2.11.4.GIT