1
0
Fork 0

Codechange: Use fmt::format to convert value to binary string representation.

Avoids manually iterating bits into an array.
pull/13016/head
Peter Nelson 2024-10-21 20:50:16 +01:00
parent 3eb7901ad9
commit 72d3db577d
No known key found for this signature in database
GPG Key ID: 8EF8F0A467DF75ED
1 changed files with 4 additions and 6 deletions

View File

@ -197,9 +197,8 @@ public:
const size_t max_element_width = std::to_string(this->data.number_of_patches).size();
std::array<int, 16> traversability_NW{0};
for (auto bitIndex : SetBitIterator(this->data.edge_traversability_bits[DIAGDIR_NW])) *(traversability_NW.rbegin() + bitIndex) = 1;
Debug(map, 9, " {:{}}", fmt::join(traversability_NW, " "), max_element_width);
std::string traversability = fmt::format("{:0{}b}", this->data.edge_traversability_bits[DIAGDIR_NW], WATER_REGION_EDGE_LENGTH);
Debug(map, 9, " {:{}}", fmt::join(traversability, " "), 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) {
@ -213,9 +212,8 @@ public:
}
Debug(map, 9, " +{:->{}}+", "", WATER_REGION_EDGE_LENGTH * (max_element_width + 1) + 1);
std::array<int, 16> traversability_SE{0};
for (auto bitIndex : SetBitIterator(this->data.edge_traversability_bits[DIAGDIR_SE])) *(traversability_SE.rbegin() + bitIndex) = 1;
Debug(map, 9, " {:{}}", fmt::join(traversability_SE, " "), max_element_width);
traversability = fmt::format("{:0{}b}", this->data.edge_traversability_bits[DIAGDIR_SE], WATER_REGION_EDGE_LENGTH);
Debug(map, 9, " {:{}}", fmt::join(traversability, " "), max_element_width);
}
};