Debug: Add chicken bits for water region invalidation/init

This commit is contained in:
Jonathan G Rennison 2024-01-10 17:41:09 +00:00
parent b45b8e77f3
commit de91c56ed5
4 changed files with 34 additions and 0 deletions

View File

@ -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)

View File

@ -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<void(const char *)> log)
{
char cclog_buffer[1024];

View File

@ -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(const WaterRegionPatchDesc &)>;
void VisitWaterRegionPatchNeighbors(const WaterRegionPatchDesc &water_region_patch, TVisitWaterRegionPatchCallBack &callback);

View File

@ -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));
{