* Let a water tile floods its diagonal adjoining tiles * called from tunnelbridge_cmd, and by TileLoop_Industry() and TileLoop_Track() * * @param tile the water/shore tile that floods */
| 1267 | * @param tile the water/shore tile that floods |
| 1268 | */ |
| 1269 | void TileLoop_Water(TileIndex tile) |
| 1270 | { |
| 1271 | if (IsTileType(tile, MP_WATER)) { |
| 1272 | AmbientSoundEffect(tile); |
| 1273 | if (IsNonFloodingWaterTile(tile)) return; |
| 1274 | } |
| 1275 | |
| 1276 | switch (GetFloodingBehaviour(tile)) { |
| 1277 | case FLOOD_ACTIVE: { |
| 1278 | bool continue_flooding = false; |
| 1279 | for (Direction dir = DIR_BEGIN; dir < DIR_END; dir++) { |
| 1280 | TileIndex dest = AddTileIndexDiffCWrap(tile, TileIndexDiffCByDir(dir)); |
| 1281 | /* Contrary to drying up, flooding does not consider MP_VOID tiles. */ |
| 1282 | if (!IsValidTile(dest)) continue; |
| 1283 | /* do not try to flood water tiles - increases performance a lot */ |
| 1284 | if (IsTileType(dest, MP_WATER)) continue; |
| 1285 | |
| 1286 | /* Buoys and docks cannot be flooded, and when removed turn into flooding water. */ |
| 1287 | if (IsTileType(dest, MP_STATION) && (IsBuoy(dest) || IsDock(dest))) continue; |
| 1288 | |
| 1289 | /* This neighbour tile might be floodable later if the tile is cleared, so allow flooding to continue. */ |
| 1290 | continue_flooding = true; |
| 1291 | |
| 1292 | /* TREE_GROUND_SHORE is the sign of a previous flood. */ |
| 1293 | if (IsTileType(dest, MP_TREES) && GetTreeGround(dest) == TREE_GROUND_SHORE) continue; |
| 1294 | |
| 1295 | auto [slope_dest, z_dest] = GetFoundationSlope(dest); |
| 1296 | if (z_dest > 0) continue; |
| 1297 | |
| 1298 | if (!_flood_from_dirs[slope_dest & ~SLOPE_HALFTILE_MASK & ~SLOPE_STEEP].Test(ReverseDir(dir))) continue; |
| 1299 | |
| 1300 | DoFloodTile(dest); |
| 1301 | } |
| 1302 | if (!continue_flooding && IsTileType(tile, MP_WATER)) SetNonFloodingWaterTile(tile, true); |
| 1303 | break; |
| 1304 | } |
| 1305 | |
| 1306 | case FLOOD_DRYUP: { |
| 1307 | Slope slope_here = std::get<0>(GetFoundationSlope(tile)) & ~SLOPE_HALFTILE_MASK & ~SLOPE_STEEP; |
| 1308 | for (Direction dir : _flood_from_dirs[slope_here]) { |
| 1309 | TileIndex dest = AddTileIndexDiffCWrap(tile, TileIndexDiffCByDir(dir)); |
| 1310 | /* Contrary to flooding, drying up does consider MP_VOID tiles. */ |
| 1311 | if (dest == INVALID_TILE) continue; |
| 1312 | |
| 1313 | FloodingBehaviour dest_behaviour = GetFloodingBehaviour(dest); |
| 1314 | if ((dest_behaviour == FLOOD_ACTIVE) || (dest_behaviour == FLOOD_PASSIVE)) return; |
| 1315 | } |
| 1316 | DoDryUp(tile); |
| 1317 | break; |
| 1318 | } |
| 1319 | |
| 1320 | default: return; |
| 1321 | } |
| 1322 | } |
| 1323 | |
| 1324 | void ConvertGroundTilesIntoWaterTiles() |
| 1325 | { |
no test coverage detected