diff options
Diffstat (limited to 'Source/Puzzle.cpp')
-rw-r--r-- | Source/Puzzle.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/Source/Puzzle.cpp b/Source/Puzzle.cpp index ee4c2e8..cc552d3 100644 --- a/Source/Puzzle.cpp +++ b/Source/Puzzle.cpp | |||
@@ -7,16 +7,14 @@ | |||
7 | PuzzleSerializer::PuzzleSerializer(const std::shared_ptr<Memory>& memory) : _memory(memory) {} | 7 | PuzzleSerializer::PuzzleSerializer(const std::shared_ptr<Memory>& memory) : _memory(memory) {} |
8 | 8 | ||
9 | Puzzle PuzzleSerializer::ReadPuzzle(int id) { | 9 | Puzzle PuzzleSerializer::ReadPuzzle(int id) { |
10 | Puzzle p; | 10 | int width = 2 * _memory->ReadPanelData<int>(id, GRID_SIZE_X, 1)[0] - 1; |
11 | p.width = 2 * _memory->ReadPanelData<int>(id, GRID_SIZE_X, 1)[0] - 1; | 11 | int height = 2 * _memory->ReadPanelData<int>(id, GRID_SIZE_Y, 1)[0] - 1; |
12 | p.height = 2 * _memory->ReadPanelData<int>(id, GRID_SIZE_Y, 1)[0] - 1; | 12 | if (width < 0 || height < 0) return Puzzle(); // @Error: Grid size should be always positive? Looks like the starting panels break this rule, though. |
13 | if (p.width < 0 || p.height < 0) return p; // @Error: Grid size should be always positive? Looks like the starting panels break this rule, though. | ||
14 | p.grid.resize(p.width); | ||
15 | for (auto& row : p.grid) row.resize(p.height); | ||
16 | 13 | ||
14 | Puzzle p; | ||
15 | p.NewGrid(width, height); | ||
17 | ReadIntersections(p, id); | 16 | ReadIntersections(p, id); |
18 | ReadDecorations(p, id); | 17 | ReadDecorations(p, id); |
19 | |||
20 | return p; | 18 | return p; |
21 | } | 19 | } |
22 | 20 | ||