diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/PuzzleSerializer.cpp | 10 | ||||
-rw-r--r-- | Source/PuzzleSerializer.h | 2 |
2 files changed, 5 insertions, 7 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) { |
diff --git a/Source/PuzzleSerializer.h b/Source/PuzzleSerializer.h index 391f5c0..4ccd383 100644 --- a/Source/PuzzleSerializer.h +++ b/Source/PuzzleSerializer.h | |||
@@ -65,6 +65,6 @@ private: | |||
65 | // Locations of non-grid points, i.e. dots, gaps, and endpoints | 65 | // Locations of non-grid points, i.e. dots, gaps, and endpoints |
66 | std::unordered_map<int, int> _extraLocations; | 66 | std::unordered_map<int, int> _extraLocations; |
67 | 67 | ||
68 | float MIN, MAX, INTERVAL, GAP_SIZE; | 68 | float MIN, MAX, INTERVAL; |
69 | int X_OFF, Y_OFF; | 69 | int X_OFF, Y_OFF; |
70 | }; | 70 | }; |