mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Use fmt::format to convert value to binary string representation. (#13016)
Avoids manually iterating bits into an array.pull/13017/head
parent
51ffb2a1a3
commit
7a71df2952
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue