diff --git a/src/debug_settings.h b/src/debug_settings.h index d3b1ca32f1..47d38453ec 100644 --- a/src/debug_settings.h +++ b/src/debug_settings.h @@ -21,6 +21,8 @@ enum ChickenBitFlags { DCBF_DESYNC_CHECK_NO_GENERAL = 4, DCBF_DESYNC_CHECK_PERIODIC_SIGNALS = 5, DCBF_CMD_NO_TEST_ALL = 6, + DCBF_WATER_REGION_CLEAR = 7, + DCBF_WATER_REGION_INIT_ALL = 8, }; inline bool HasChickenBit(ChickenBitFlags flag) diff --git a/src/pathfinder/water_regions.cpp b/src/pathfinder/water_regions.cpp index b38e6c7b7d..a7cfbfb3dd 100644 --- a/src/pathfinder/water_regions.cpp +++ b/src/pathfinder/water_regions.cpp @@ -484,6 +484,28 @@ uint GetWaterRegionTileDebugColourIndex(TileIndex tile) } } +void DebugInvalidateAllWaterRegions() +{ + const uint32_t size_x = GetWaterRegionMapSizeX(); + const uint32_t size_y = GetWaterRegionMapSizeY(); + for (uint32_t y = 0; y < size_y; y++) { + for (uint32_t x = 0; x < size_x; x++) { + GetWaterRegionRef(x, y).Invalidate(); + } + } +} + +void DebugInitAllWaterRegions() +{ + const uint32_t size_x = GetWaterRegionMapSizeX(); + const uint32_t size_y = GetWaterRegionMapSizeY(); + for (uint32_t y = 0; y < size_y; y++) { + for (uint32_t x = 0; x < size_x; x++) { + GetWaterRegionRef(x, y).UpdateIfNotInitialized(); + } + } +} + void WaterRegionCheckCaches(std::function log) { char cclog_buffer[1024]; diff --git a/src/pathfinder/water_regions.h b/src/pathfinder/water_regions.h index d7fdbfa6dc..d06f7d92bc 100644 --- a/src/pathfinder/water_regions.h +++ b/src/pathfinder/water_regions.h @@ -65,6 +65,8 @@ WaterRegionDesc GetWaterRegionInfo(TileIndex tile); WaterRegionPatchDesc GetWaterRegionPatchInfo(TileIndex tile); void InvalidateWaterRegion(TileIndex tile); +void DebugInvalidateAllWaterRegions(); +void DebugInitAllWaterRegions(); using TVisitWaterRegionPatchCallBack = std::function; void VisitWaterRegionPatchNeighbors(const WaterRegionPatchDesc &water_region_patch, TVisitWaterRegionPatchCallBack &callback); diff --git a/src/vehicle.cpp b/src/vehicle.cpp index f4472db895..918d4ea4f7 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -61,6 +61,7 @@ #include "scope_info.h" #include "debug_settings.h" #include "network/network_sync.h" +#include "pathfinder/water_regions.h" #include "3rdparty/cpp-btree/btree_set.h" #include "3rdparty/cpp-btree/btree_map.h" #include "3rdparty/robin_hood/robin_hood.h" @@ -1563,6 +1564,13 @@ void CallVehicleTicks() if (!_tick_caches_valid || HasChickenBit(DCBF_VEH_TICK_CACHE)) RebuildVehicleTickCaches(); + if (HasChickenBit(DCBF_WATER_REGION_CLEAR)) { + DebugInvalidateAllWaterRegions(); + } + if (HasChickenBit(DCBF_WATER_REGION_INIT_ALL)) { + DebugInitAllWaterRegions(); + } + Vehicle *v = nullptr; SCOPE_INFO_FMT([&v], "CallVehicleTicks: %s", scope_dumper().VehicleInfo(v)); {