diff options
author | jbzdarkid <jbzdarkid@gmail.com> | 2019-11-09 14:23:42 -0800 |
---|---|---|
committer | jbzdarkid <jbzdarkid@gmail.com> | 2019-11-09 14:23:42 -0800 |
commit | 98db209c9008492baec6bb482b047d386fbdd42b (patch) | |
tree | 9f4a932ed1ff2367a98fe02908fee4c884a2d4ed /Source/Puzzle.cpp | |
parent | 36be1ed32ac9a554f0b11fcc13b5699e717b81f2 (diff) | |
download | witness-tutorializer-98db209c9008492baec6bb482b047d386fbdd42b.tar.gz witness-tutorializer-98db209c9008492baec6bb482b047d386fbdd42b.tar.bz2 witness-tutorializer-98db209c9008492baec6bb482b047d386fbdd42b.zip |
One down, 522 to go.
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 | ||