From 2222a8ce5de5f46b762473001101aa10a0884bc1 Mon Sep 17 00:00:00 2001 From: jbzdarkid Date: Mon, 25 Nov 2019 18:19:04 -0800 Subject: Fix bug, finalize symmetry wall --- Source/PuzzleSerializer.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'Source/PuzzleSerializer.cpp') diff --git a/Source/PuzzleSerializer.cpp b/Source/PuzzleSerializer.cpp index 8165fe8..be2d857 100644 --- a/Source/PuzzleSerializer.cpp +++ b/Source/PuzzleSerializer.cpp @@ -49,10 +49,12 @@ void PuzzleSerializer::WritePuzzle(const Puzzle& p, int id) { if (p.height > p.width) { INTERVAL = (MAX - MIN) / (p.height - (p.height%2)); + GAP_SIZE = (MAX - MIN) / (2 * p.width); X_OFF = (p.height - p.width) / 2; Y_OFF = 0; } else { INTERVAL = (MAX - MIN) / (p.width - (p.width%2)); + GAP_SIZE = (MAX - MIN) / (2 * p.height); X_OFF = 0; Y_OFF = (p.width - p.height) / 2; } @@ -411,22 +413,22 @@ void PuzzleSerializer::WriteGaps(const Puzzle& p) { gap1Location = static_cast(_intersectionFlags.size()); _connectionsA[connectionLocation] = xy_to_loc(p, x, y-1); _connectionsB[connectionLocation] = gap1Location; - AddIntersection(p, x, y, xPos, yPos + INTERVAL / 4, Flags::HAS_ONE_CONN | Flags::HAS_VERTI_CONN); + AddIntersection(p, x, y, xPos, yPos + GAP_SIZE, Flags::HAS_ONE_CONN | Flags::HAS_VERTI_CONN); gap2Location = static_cast(_intersectionFlags.size()); _connectionsA.push_back(xy_to_loc(p, x, y+1)); _connectionsB.push_back(gap2Location); - AddIntersection(p, x, y, xPos, yPos - INTERVAL / 4, Flags::HAS_ONE_CONN | Flags::HAS_VERTI_CONN); + AddIntersection(p, x, y, xPos, yPos - GAP_SIZE, Flags::HAS_ONE_CONN | Flags::HAS_VERTI_CONN); } else if (y%2 == 0) { // Horizontal gap gap1Location = static_cast(_intersectionFlags.size()); _connectionsA[connectionLocation] = xy_to_loc(p, x-1, y); _connectionsB[connectionLocation] = gap1Location; - AddIntersection(p, x, y, xPos - INTERVAL / 4, yPos, Flags::HAS_ONE_CONN | Flags::HAS_HORIZ_CONN); + AddIntersection(p, x, y, xPos - GAP_SIZE, yPos, Flags::HAS_ONE_CONN | Flags::HAS_HORIZ_CONN); gap2Location = static_cast(_intersectionFlags.size()); _connectionsA.push_back(xy_to_loc(p, x+1, y)); _connectionsB.push_back(gap2Location); - AddIntersection(p, x, y, xPos + INTERVAL / 4, yPos, Flags::HAS_ONE_CONN | Flags::HAS_HORIZ_CONN); + AddIntersection(p, x, y, xPos + GAP_SIZE, yPos, Flags::HAS_ONE_CONN | Flags::HAS_HORIZ_CONN); } if (p.symmetry != Puzzle::Symmetry::NONE) { if (p.grid[x][y].gap == Cell::Gap::NONE) { -- cgit 1.4.1