summary refs log tree commit diff stats
path: root/Source/PuzzleSerializer.cpp
diff options
context:
space:
mode:
authorjbzdarkid <jbzdarkid@gmail.com>2019-12-05 09:43:23 -0800
committerjbzdarkid <jbzdarkid@gmail.com>2019-12-05 09:43:23 -0800
commit9f4ea5694ec32507db1d28000fa52665e0e84323 (patch)
tree4947148cc16394197e220f979e53d3b1e504155d /Source/PuzzleSerializer.cpp
parent1ccd3488a0c946b2ad4c0e525d91dcf96d1ca707 (diff)
downloadwitness-tutorializer-9f4ea5694ec32507db1d28000fa52665e0e84323.tar.gz
witness-tutorializer-9f4ea5694ec32507db1d28000fa52665e0e84323.tar.bz2
witness-tutorializer-9f4ea5694ec32507db1d28000fa52665e0e84323.zip
Just forgot to write this section, I guess
Diffstat (limited to 'Source/PuzzleSerializer.cpp')
-rw-r--r--Source/PuzzleSerializer.cpp40
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 }