Codechange: Make void tiles flood edge tiles, instead of edge tiles flooding themselves (#8517)

pull/480/head
SamuXarick 1 year ago committed by GitHub
parent ede1201b6a
commit 46dc6da270
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -13,7 +13,6 @@
#include "landscape.h" #include "landscape.h"
#include "genworld.h" #include "genworld.h"
#include "viewport_func.h" #include "viewport_func.h"
#include "water.h"
#include "core/random_func.hpp" #include "core/random_func.hpp"
#include "newgrf_generic.h" #include "newgrf_generic.h"
#include "landscape_cmd.h" #include "landscape_cmd.h"
@ -248,15 +247,6 @@ static void TileLoopClearDesert(TileIndex tile)
static void TileLoop_Clear(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); AmbientSoundEffect(tile);
switch (_settings_game.game_creation.landscape) { switch (_settings_game.game_creation.landscape) {

@ -12,6 +12,7 @@
#include "command_func.h" #include "command_func.h"
#include "viewport_func.h" #include "viewport_func.h"
#include "slope_func.h" #include "slope_func.h"
#include "water.h"
#include "table/strings.h" #include "table/strings.h"
#include "table/sprites.h" #include "table/sprites.h"
@ -53,7 +54,8 @@ static void GetTileDesc_Void(TileIndex tile, TileDesc *td)
static void TileLoop_Void(TileIndex tile) 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) static void ChangeTileOwner_Void(TileIndex tile, Owner old_owner, Owner new_owner)

@ -1089,6 +1089,9 @@ FloodingBehaviour GetFloodingBehaviour(TileIndex tile)
case MP_TREES: case MP_TREES:
return (GetTreeGround(tile) == TREE_GROUND_SHORE ? FLOOD_DRYUP : FLOOD_NONE); return (GetTreeGround(tile) == TREE_GROUND_SHORE ? FLOOD_DRYUP : FLOOD_NONE);
case MP_VOID:
return FLOOD_ACTIVE;
default: default:
return FLOOD_NONE; return FLOOD_NONE;
} }
@ -1240,7 +1243,7 @@ void TileLoop_Water(TileIndex tile)
Slope slope_here = GetFoundationSlope(tile) & ~SLOPE_HALFTILE_MASK & ~SLOPE_STEEP; Slope slope_here = GetFoundationSlope(tile) & ~SLOPE_HALFTILE_MASK & ~SLOPE_STEEP;
for (uint dir : SetBitIterator(_flood_from_dirs[slope_here])) { for (uint dir : SetBitIterator(_flood_from_dirs[slope_here])) {
TileIndex dest = tile + TileOffsByDir((Direction)dir); TileIndex dest = tile + TileOffsByDir((Direction)dir);
if (!IsValidTile(dest)) continue; if (dest >= Map::Size()) continue;
FloodingBehaviour dest_behaviour = GetFloodingBehaviour(dest); FloodingBehaviour dest_behaviour = GetFloodingBehaviour(dest);
if ((dest_behaviour == FLOOD_ACTIVE) || (dest_behaviour == FLOOD_PASSIVE)) return; 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])) { for (uint dir : SetBitIterator(_flood_from_dirs[slope & ~SLOPE_STEEP])) {
TileIndex dest = TileAddByDir(tile, (Direction)dir); TileIndex dest = TileAddByDir(tile, (Direction)dir);
Slope slope_dest = GetTileSlope(dest) & ~SLOPE_STEEP; 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); MakeShore(tile);
break; break;
} }

Loading…
Cancel
Save