diff options
Diffstat (limited to 'Source/PuzzleSerializer.cpp')
| -rw-r--r-- | Source/PuzzleSerializer.cpp | 40 |
1 files changed, 23 insertions, 17 deletions
| diff --git a/Source/PuzzleSerializer.cpp b/Source/PuzzleSerializer.cpp index 29bd648..8faede9 100644 --- a/Source/PuzzleSerializer.cpp +++ b/Source/PuzzleSerializer.cpp | |||
| @@ -493,25 +493,31 @@ void PuzzleSerializer::WriteSymmetry(const Puzzle& p, int id) { | |||
| 493 | for (int x=0; x<p.width; x++) { | 493 | for (int x=0; x<p.width; x++) { |
| 494 | for (int y=0; y<p.height; y++) { | 494 | for (int y=0; y<p.height; y++) { |
| 495 | if (x%2 == y%2) continue; | 495 | if (x%2 == y%2) continue; |
| 496 | if (p.grid[x][y].gap != Cell::Gap::BREAK) continue; | 496 | if (p.grid[x][y].gap == Cell::Gap::BREAK) { |
| 497 | 497 | Pos sym = p.GetSymmetricalPos(x, y); | |
| 498 | Pos sym = p.GetSymmetricalPos(x, y); | 498 | int location = extra_xy_to_loc(p, x, y); |
| 499 | int location = extra_xy_to_loc(p, x, y); | 499 | int symLocation = extra_xy_to_loc(p, sym.x, sym.y); |
| 500 | int symLocation = extra_xy_to_loc(p, sym.x, sym.y); | 500 | // Each gap results in two intersections, @Assume they're written consecutively |
| 501 | // Each gap results in two intersections, @Assume they're written consecutively | 501 | |
| 502 | 502 | if ((x%2 != 0 && p.symmetry & Puzzle::Symmetry::X) || | |
| 503 | if ((x%2 != 0 && p.symmetry & Puzzle::Symmetry::X) || | 503 | (y%2 != 0 && p.symmetry & Puzzle::Symmetry::Y)) { |
| 504 | (y%2 != 0 && p.symmetry & Puzzle::Symmetry::Y)) { | 504 | // Write data inverted, because it's being reflected |
| 505 | // Write data inverted, because it's being reflected | 505 | reflectionData[location] = symLocation-1; |
| 506 | reflectionData[location] = symLocation-1; | 506 | reflectionData[location-1] = symLocation; |
| 507 | reflectionData[location-1] = symLocation; | 507 | reflectionData[symLocation] = location-1; |
| 508 | reflectionData[symLocation] = location-1; | 508 | reflectionData[symLocation-1] = location; |
| 509 | reflectionData[symLocation-1] = location; | 509 | } else { // Write data normally |
| 510 | } else { // Write data normally | 510 | reflectionData[location] = symLocation; |
| 511 | reflectionData[location-1] = symLocation-1; | ||
| 512 | reflectionData[symLocation] = location; | ||
| 513 | reflectionData[symLocation-1] = location-1; | ||
| 514 | } | ||
| 515 | } else if (p.grid[x][y].dot == Cell::Dot::BLACK) { | ||
| 516 | Pos sym = p.GetSymmetricalPos(x, y); | ||
| 517 | int location = extra_xy_to_loc(p, x, y); | ||
| 518 | int symLocation = extra_xy_to_loc(p, sym.x, sym.y); | ||
| 511 | reflectionData[location] = symLocation; | 519 | reflectionData[location] = symLocation; |
| 512 | reflectionData[location-1] = symLocation-1; | ||
| 513 | reflectionData[symLocation] = location; | 520 | reflectionData[symLocation] = location; |
| 514 | reflectionData[symLocation-1] = location-1; | ||
| 515 | } | 521 | } |
| 516 | } | 522 | } |
| 517 | } | 523 | } |
