Added debug check macro and some formats

This commit is contained in:
Dmitriy Shishkov 2022-05-31 09:03:38 +03:00
parent 12583220a3
commit ec43ed7c52
No known key found for this signature in database
GPG Key ID: 26720CB2A9608C97
3 changed files with 17 additions and 8 deletions

View File

@ -45,7 +45,9 @@ void Controller::fillSolveableTable() {
auto next_ptr = positions.begin();
while (!positions.empty() || (not_end && !(positions.insert(getRandLowest()), positions.empty()))) {
while (
!positions.empty() ||
(not_end && !(positions.insert(getRandLowest()), positions.empty()))) {
int id = genRandId();
if (id < 34) {
@ -74,6 +76,8 @@ wxPoint Controller::getRandLowest() {
return {x, y};
}
#ifdef WXDEBUG
#include <wx/file.h>
void print_list(const std::set<ThreePoint>& positions) {
@ -85,10 +89,14 @@ void print_list(const std::set<ThreePoint>& positions) {
f.Write("_ size: " + itowxS(positions.size()) + "\n");
}
#endif
void Controller::emplace_rand(int id, std::set<ThreePoint>& positions,
std::set<ThreePoint>::iterator& next_ptr,
bool canBeUp) {
#ifdef WXDEBUG
print_list(positions);
#endif
table[next_ptr->z][next_ptr->x][next_ptr->y] = id;
@ -121,6 +129,7 @@ void Controller::push_available(std::set<ThreePoint>& positions,
const ThreePoint& pos) {
int z = pos.z, x = pos.x, y = pos.y;
// clang-format off
if (x >= 2 && table[z][x-2][y] == FREE) // left
positions.emplace(z, x-2, y);
if (x + 2 < gridSize.x && table[z][x+2][y] == FREE) // right
@ -176,6 +185,7 @@ void Controller::push_available(std::set<ThreePoint>& positions,
positions.emplace(z+1, x+1, y+1);
}
}
// clang-format on
}
void Controller::free_table() {

View File

@ -140,8 +140,7 @@ bool Drawer::resizeBoard(const TLVec& layout, const Dimensions& gridSize) {
tilePixelSize.Set(gridPoint * TILE_WIDTH, gridPoint * TILE_HEIGHT);
}
tablePixelRect.SetPosition(
{(resolution.x - tablePixelRect.width) / 2,
tablePixelRect.SetPosition({(resolution.x - tablePixelRect.width) / 2,
(resolution.y - tablePixelRect.height) / 2});
if (gridPoint != prevGridPoint) {

View File

@ -31,7 +31,7 @@ public:
ThreePoint() : x(0), y(0), z(0){};
bool operator<(const ThreePoint& b) const {
return z*144*144+x*144+y < b.z*144*144+b.x*144+b.y;
return z * 144 * 144 + x * 144 + y < b.z * 144 * 144 + b.x * 144 + b.y;
}
bool operator==(const ThreePoint& b) {