summary refs log tree commit diff stats
path: root/Source/PuzzleSerializer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/PuzzleSerializer.cpp')
-rw-r--r--Source/PuzzleSerializer.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/Source/PuzzleSerializer.cpp b/Source/PuzzleSerializer.cpp index be2d857..7461f7b 100644 --- a/Source/PuzzleSerializer.cpp +++ b/Source/PuzzleSerializer.cpp
@@ -49,12 +49,10 @@ 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);
53 X_OFF = (p.height - p.width) / 2; 52 X_OFF = (p.height - p.width) / 2;
54 Y_OFF = 0; 53 Y_OFF = 0;
55 } else { 54 } else {
56 INTERVAL = (MAX - MIN) / (p.width - (p.width%2)); 55 INTERVAL = (MAX - MIN) / (p.width - (p.width%2));
57 GAP_SIZE = (MAX - MIN) / (2 * p.height);
58 X_OFF = 0; 56 X_OFF = 0;
59 Y_OFF = (p.width - p.height) / 2; 57 Y_OFF = (p.width - p.height) / 2;
60 } 58 }
@@ -413,22 +411,22 @@ void PuzzleSerializer::WriteGaps(const Puzzle& p) {
413 gap1Location = static_cast<int>(_intersectionFlags.size()); 411 gap1Location = static_cast<int>(_intersectionFlags.size());
414 _connectionsA[connectionLocation] = xy_to_loc(p, x, y-1); 412 _connectionsA[connectionLocation] = xy_to_loc(p, x, y-1);
415 _connectionsB[connectionLocation] = gap1Location; 413 _connectionsB[connectionLocation] = gap1Location;
416 AddIntersection(p, x, y, xPos, yPos + GAP_SIZE, Flags::HAS_ONE_CONN | Flags::HAS_VERTI_CONN); 414 AddIntersection(p, x, y, xPos, yPos + INTERVAL / 2, Flags::HAS_ONE_CONN | Flags::HAS_VERTI_CONN);
417 415
418 gap2Location = static_cast<int>(_intersectionFlags.size()); 416 gap2Location = static_cast<int>(_intersectionFlags.size());
419 _connectionsA.push_back(xy_to_loc(p, x, y+1)); 417 _connectionsA.push_back(xy_to_loc(p, x, y+1));
420 _connectionsB.push_back(gap2Location); 418 _connectionsB.push_back(gap2Location);
421 AddIntersection(p, x, y, xPos, yPos - GAP_SIZE, Flags::HAS_ONE_CONN | Flags::HAS_VERTI_CONN); 419 AddIntersection(p, x, y, xPos, yPos - INTERVAL / 2, Flags::HAS_ONE_CONN | Flags::HAS_VERTI_CONN);
422 } else if (y%2 == 0) { // Horizontal gap 420 } else if (y%2 == 0) { // Horizontal gap
423 gap1Location = static_cast<int>(_intersectionFlags.size()); 421 gap1Location = static_cast<int>(_intersectionFlags.size());
424 _connectionsA[connectionLocation] = xy_to_loc(p, x-1, y); 422 _connectionsA[connectionLocation] = xy_to_loc(p, x-1, y);
425 _connectionsB[connectionLocation] = gap1Location; 423 _connectionsB[connectionLocation] = gap1Location;
426 AddIntersection(p, x, y, xPos - GAP_SIZE, yPos, Flags::HAS_ONE_CONN | Flags::HAS_HORIZ_CONN); 424 AddIntersection(p, x, y, xPos - INTERVAL / 2, yPos, Flags::HAS_ONE_CONN | Flags::HAS_HORIZ_CONN);
427 425
428 gap2Location = static_cast<int>(_intersectionFlags.size()); 426 gap2Location = static_cast<int>(_intersectionFlags.size());
429 _connectionsA.push_back(xy_to_loc(p, x+1, y)); 427 _connectionsA.push_back(xy_to_loc(p, x+1, y));
430 _connectionsB.push_back(gap2Location); 428 _connectionsB.push_back(gap2Location);
431 AddIntersection(p, x, y, xPos + GAP_SIZE, yPos, Flags::HAS_ONE_CONN | Flags::HAS_HORIZ_CONN); 429 AddIntersection(p, x, y, xPos + INTERVAL / 2, yPos, Flags::HAS_ONE_CONN | Flags::HAS_HORIZ_CONN);
432 } 430 }
433 if (p.symmetry != Puzzle::Symmetry::NONE) { 431 if (p.symmetry != Puzzle::Symmetry::NONE) {
434 if (p.grid[x][y].gap == Cell::Gap::NONE) { 432 if (p.grid[x][y].gap == Cell::Gap::NONE) {