about summary refs log tree commit diff stats
path: root/Source/Puzzle.cpp
diff options
context:
space:
mode:
authorjbzdarkid <jbzdarkid@gmail.com>2019-11-09 14:23:42 -0800
committerjbzdarkid <jbzdarkid@gmail.com>2019-11-09 14:23:42 -0800
commit98db209c9008492baec6bb482b047d386fbdd42b (patch)
tree9f4a932ed1ff2367a98fe02908fee4c884a2d4ed /Source/Puzzle.cpp
parent36be1ed32ac9a554f0b11fcc13b5699e717b81f2 (diff)
downloadwitness-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.cpp12
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 @@
7PuzzleSerializer::PuzzleSerializer(const std::shared_ptr<Memory>& memory) : _memory(memory) {} 7PuzzleSerializer::PuzzleSerializer(const std::shared_ptr<Memory>& memory) : _memory(memory) {}
8 8
9Puzzle PuzzleSerializer::ReadPuzzle(int id) { 9Puzzle 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