diff options
| author | jbzdarkid <jbzdarkid@gmail.com> | 2019-11-25 18:19:04 -0800 |
|---|---|---|
| committer | jbzdarkid <jbzdarkid@gmail.com> | 2019-11-25 18:19:04 -0800 |
| commit | 2222a8ce5de5f46b762473001101aa10a0884bc1 (patch) | |
| tree | 122190352eff1dbc98657f707d9a34fbeb153ece /Source/PuzzleSerializer.cpp | |
| parent | 50992a6ab44321fe925c2becaa856a31696076ea (diff) | |
| download | witness-tutorializer-2222a8ce5de5f46b762473001101aa10a0884bc1.tar.gz witness-tutorializer-2222a8ce5de5f46b762473001101aa10a0884bc1.tar.bz2 witness-tutorializer-2222a8ce5de5f46b762473001101aa10a0884bc1.zip | |
Fix bug, finalize symmetry wall
Diffstat (limited to 'Source/PuzzleSerializer.cpp')
| -rw-r--r-- | Source/PuzzleSerializer.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
| diff --git a/Source/PuzzleSerializer.cpp b/Source/PuzzleSerializer.cpp index 8165fe8..be2d857 100644 --- a/Source/PuzzleSerializer.cpp +++ b/Source/PuzzleSerializer.cpp | |||
| @@ -49,10 +49,12 @@ void PuzzleSerializer::WritePuzzle(const Puzzle& p, int id) { | |||
| 49 | 49 | ||
| 50 | if (p.height > p.width) { | 50 | if (p.height > p.width) { |
| 51 | INTERVAL = (MAX - MIN) / (p.height - (p.height%2)); | 51 | INTERVAL = (MAX - MIN) / (p.height - (p.height%2)); |
| 52 | GAP_SIZE = (MAX - MIN) / (2 * p.width); | ||
| 52 | X_OFF = (p.height - p.width) / 2; | 53 | X_OFF = (p.height - p.width) / 2; |
| 53 | Y_OFF = 0; | 54 | Y_OFF = 0; |
| 54 | } else { | 55 | } else { |
| 55 | INTERVAL = (MAX - MIN) / (p.width - (p.width%2)); | 56 | INTERVAL = (MAX - MIN) / (p.width - (p.width%2)); |
| 57 | GAP_SIZE = (MAX - MIN) / (2 * p.height); | ||
| 56 | X_OFF = 0; | 58 | X_OFF = 0; |
| 57 | Y_OFF = (p.width - p.height) / 2; | 59 | Y_OFF = (p.width - p.height) / 2; |
| 58 | } | 60 | } |
| @@ -411,22 +413,22 @@ void PuzzleSerializer::WriteGaps(const Puzzle& p) { | |||
| 411 | gap1Location = static_cast<int>(_intersectionFlags.size()); | 413 | gap1Location = static_cast<int>(_intersectionFlags.size()); |
| 412 | _connectionsA[connectionLocation] = xy_to_loc(p, x, y-1); | 414 | _connectionsA[connectionLocation] = xy_to_loc(p, x, y-1); |
| 413 | _connectionsB[connectionLocation] = gap1Location; | 415 | _connectionsB[connectionLocation] = gap1Location; |
| 414 | AddIntersection(p, x, y, xPos, yPos + INTERVAL / 4, Flags::HAS_ONE_CONN | Flags::HAS_VERTI_CONN); | 416 | AddIntersection(p, x, y, xPos, yPos + GAP_SIZE, Flags::HAS_ONE_CONN | Flags::HAS_VERTI_CONN); |
| 415 | 417 | ||
| 416 | gap2Location = static_cast<int>(_intersectionFlags.size()); | 418 | gap2Location = static_cast<int>(_intersectionFlags.size()); |
| 417 | _connectionsA.push_back(xy_to_loc(p, x, y+1)); | 419 | _connectionsA.push_back(xy_to_loc(p, x, y+1)); |
| 418 | _connectionsB.push_back(gap2Location); | 420 | _connectionsB.push_back(gap2Location); |
| 419 | AddIntersection(p, x, y, xPos, yPos - INTERVAL / 4, Flags::HAS_ONE_CONN | Flags::HAS_VERTI_CONN); | 421 | AddIntersection(p, x, y, xPos, yPos - GAP_SIZE, Flags::HAS_ONE_CONN | Flags::HAS_VERTI_CONN); |
| 420 | } else if (y%2 == 0) { // Horizontal gap | 422 | } else if (y%2 == 0) { // Horizontal gap |
| 421 | gap1Location = static_cast<int>(_intersectionFlags.size()); | 423 | gap1Location = static_cast<int>(_intersectionFlags.size()); |
| 422 | _connectionsA[connectionLocation] = xy_to_loc(p, x-1, y); | 424 | _connectionsA[connectionLocation] = xy_to_loc(p, x-1, y); |
| 423 | _connectionsB[connectionLocation] = gap1Location; | 425 | _connectionsB[connectionLocation] = gap1Location; |
| 424 | AddIntersection(p, x, y, xPos - INTERVAL / 4, yPos, Flags::HAS_ONE_CONN | Flags::HAS_HORIZ_CONN); | 426 | AddIntersection(p, x, y, xPos - GAP_SIZE, yPos, Flags::HAS_ONE_CONN | Flags::HAS_HORIZ_CONN); |
| 425 | 427 | ||
| 426 | gap2Location = static_cast<int>(_intersectionFlags.size()); | 428 | gap2Location = static_cast<int>(_intersectionFlags.size()); |
| 427 | _connectionsA.push_back(xy_to_loc(p, x+1, y)); | 429 | _connectionsA.push_back(xy_to_loc(p, x+1, y)); |
| 428 | _connectionsB.push_back(gap2Location); | 430 | _connectionsB.push_back(gap2Location); |
| 429 | AddIntersection(p, x, y, xPos + INTERVAL / 4, yPos, Flags::HAS_ONE_CONN | Flags::HAS_HORIZ_CONN); | 431 | AddIntersection(p, x, y, xPos + GAP_SIZE, yPos, Flags::HAS_ONE_CONN | Flags::HAS_HORIZ_CONN); |
| 430 | } | 432 | } |
| 431 | if (p.symmetry != Puzzle::Symmetry::NONE) { | 433 | if (p.symmetry != Puzzle::Symmetry::NONE) { |
| 432 | if (p.grid[x][y].gap == Cell::Gap::NONE) { | 434 | if (p.grid[x][y].gap == Cell::Gap::NONE) { |
