diff options
author | jbzdarkid <jbzdarkid@gmail.com> | 2019-11-22 10:04:19 -0800 |
---|---|---|
committer | jbzdarkid <jbzdarkid@gmail.com> | 2019-11-22 10:04:19 -0800 |
commit | 059e44fa16b649938d79597bcf8f41bf4aa136ab (patch) | |
tree | 255c9f256ecae0923e872e62ccaab48221f12743 /Source/PuzzleSerializer.cpp | |
parent | cbdf87bb8aaebca9c969dfec3c1664b9b6355a0d (diff) | |
download | witness-tutorializer-059e44fa16b649938d79597bcf8f41bf4aa136ab.tar.gz witness-tutorializer-059e44fa16b649938d79597bcf8f41bf4aa136ab.tar.bz2 witness-tutorializer-059e44fa16b649938d79597bcf8f41bf4aa136ab.zip |
fix more asymmetrical gap bugs
Diffstat (limited to 'Source/PuzzleSerializer.cpp')
-rw-r--r-- | Source/PuzzleSerializer.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/Source/PuzzleSerializer.cpp b/Source/PuzzleSerializer.cpp index a131376..fb4166b 100644 --- a/Source/PuzzleSerializer.cpp +++ b/Source/PuzzleSerializer.cpp | |||
@@ -485,7 +485,6 @@ void PuzzleSerializer::WriteSymmetry(const Puzzle& p, int id) { | |||
485 | reflectionData[location] = symLocation; | 485 | reflectionData[location] = symLocation; |
486 | reflectionData[symLocation] = location; | 486 | reflectionData[symLocation] = location; |
487 | if (p.grid[x][y].end != Cell::Dir::NONE) { | 487 | if (p.grid[x][y].end != Cell::Dir::NONE) { |
488 | // Rely on symmetry to set the other pair | ||
489 | location = extra_xy_to_loc(p, x, y); | 488 | location = extra_xy_to_loc(p, x, y); |
490 | Pos sym = p.GetSymmetricalPos(x, y); | 489 | Pos sym = p.GetSymmetricalPos(x, y); |
491 | symLocation = extra_xy_to_loc(p, sym.x, sym.y); | 490 | symLocation = extra_xy_to_loc(p, sym.x, sym.y); |
@@ -503,11 +502,20 @@ void PuzzleSerializer::WriteSymmetry(const Puzzle& p, int id) { | |||
503 | int location = extra_xy_to_loc(p, x, y); | 502 | int location = extra_xy_to_loc(p, x, y); |
504 | int symLocation = extra_xy_to_loc(p, sym.x, sym.y); | 503 | int symLocation = extra_xy_to_loc(p, sym.x, sym.y); |
505 | // Each gap results in two intersections, @Assume they're written consecutively | 504 | // Each gap results in two intersections, @Assume they're written consecutively |
506 | // Rely on symmetry to set the other pairs | 505 | |
507 | reflectionData[location] = symLocation; | 506 | if ((x%2 != 0 && p.symmetry & Puzzle::Symmetry::X) || |
508 | reflectionData[location-1] = symLocation-1; | 507 | (y%2 != 0 && p.symmetry & Puzzle::Symmetry::Y)) { |
509 | reflectionData[symLocation] = location; | 508 | // Write data inverted, because it's being reflected |
510 | reflectionData[symLocation-1] = location-1; | 509 | reflectionData[location] = symLocation-1; |
510 | reflectionData[location-1] = symLocation; | ||
511 | reflectionData[symLocation] = location-1; | ||
512 | reflectionData[symLocation-1] = location; | ||
513 | } else { // Write data normally | ||
514 | reflectionData[location] = symLocation; | ||
515 | reflectionData[location-1] = symLocation-1; | ||
516 | reflectionData[symLocation] = location; | ||
517 | reflectionData[symLocation-1] = location-1; | ||
518 | } | ||
511 | } | 519 | } |
512 | } | 520 | } |
513 | 521 | ||