mirror of https://github.com/OpenTTD/OpenTTD.git
Codechange: Added debug printing for Water Regions
This commit is contained in:
parent
4b94457bf1
commit
35c89d57f8
|
@ -29,6 +29,7 @@
|
|||
#include "rev.h"
|
||||
#include "timer/timer.h"
|
||||
#include "timer/timer_window.h"
|
||||
#include "pathfinder/water_regions.h"
|
||||
|
||||
#include "widgets/misc_widget.h"
|
||||
|
||||
|
@ -128,6 +129,8 @@ public:
|
|||
Debug(misc, LANDINFOD_LEVEL, "m6 = 0x{:x}", tile.m6());
|
||||
Debug(misc, LANDINFOD_LEVEL, "m7 = 0x{:x}", tile.m7());
|
||||
Debug(misc, LANDINFOD_LEVEL, "m8 = 0x{:x}", tile.m8());
|
||||
|
||||
PrintWaterRegionDebugInfo(tile);
|
||||
#undef LANDINFOD_LEVEL
|
||||
}
|
||||
|
||||
|
|
|
@ -182,6 +182,33 @@ public:
|
|||
{
|
||||
if (!this->initialized) ForceUpdate();
|
||||
}
|
||||
|
||||
void PrintDebugInfo()
|
||||
{
|
||||
Debug(map, 9, "Water region {},{} labels and edge traversability = ...", GetWaterRegionX(tile_area.tile), GetWaterRegionY(tile_area.tile));
|
||||
|
||||
const size_t max_element_width = std::to_string(this->number_of_patches).size();
|
||||
|
||||
std::array<int, 16> traversability_NW{0};
|
||||
for (auto bitIndex : SetBitIterator(edge_traversability_bits[DIAGDIR_NW])) *(traversability_NW.rbegin() + bitIndex) = 1;
|
||||
Debug(map, 9, " {:{}}", fmt::join(traversability_NW, " "), max_element_width);
|
||||
Debug(map, 9, " +{:->{}}+", "", WATER_REGION_EDGE_LENGTH * (max_element_width + 1) + 1);
|
||||
|
||||
for (int y = 0; y < WATER_REGION_EDGE_LENGTH; ++y) {
|
||||
std::string line{};
|
||||
for (int x = 0; x < WATER_REGION_EDGE_LENGTH; ++x) {
|
||||
const auto label = this->tile_patch_labels[x + y * WATER_REGION_EDGE_LENGTH];
|
||||
const std::string label_str = label == INVALID_WATER_REGION_PATCH ? "." : std::to_string(label);
|
||||
line = fmt::format("{:{}}", label_str, max_element_width) + " " + line;
|
||||
}
|
||||
Debug(map, 9, "{} | {}| {}", GB(this->edge_traversability_bits[DIAGDIR_SW], y, 1), line, GB(this->edge_traversability_bits[DIAGDIR_NE], y, 1));
|
||||
}
|
||||
|
||||
Debug(map, 9, " +{:->{}}+", "", WATER_REGION_EDGE_LENGTH * (max_element_width + 1) + 1);
|
||||
std::array<int, 16> traversability_SE{0};
|
||||
for (auto bitIndex : SetBitIterator(edge_traversability_bits[DIAGDIR_SE])) *(traversability_SE.rbegin() + bitIndex) = 1;
|
||||
Debug(map, 9, " {:{}}", fmt::join(traversability_SE, " "), max_element_width);
|
||||
}
|
||||
};
|
||||
|
||||
std::vector<WaterRegion> _water_regions;
|
||||
|
@ -372,3 +399,8 @@ void AllocateWaterRegions()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PrintWaterRegionDebugInfo(TileIndex tile)
|
||||
{
|
||||
GetUpdatedWaterRegion(tile).PrintDebugInfo();
|
||||
}
|
||||
|
|
|
@ -64,4 +64,6 @@ void VisitWaterRegionPatchNeighbors(const WaterRegionPatchDesc &water_region_pat
|
|||
|
||||
void AllocateWaterRegions();
|
||||
|
||||
void PrintWaterRegionDebugInfo(TileIndex tile);
|
||||
|
||||
#endif /* WATER_REGIONS_H */
|
||||
|
|
Loading…
Reference in New Issue