From 98db209c9008492baec6bb482b047d386fbdd42b Mon Sep 17 00:00:00 2001 From: jbzdarkid Date: Sat, 9 Nov 2019 14:23:42 -0800 Subject: One down, 522 to go. --- Source/Puzzle.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'Source/Puzzle.cpp') 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 @@ PuzzleSerializer::PuzzleSerializer(const std::shared_ptr& memory) : _memory(memory) {} Puzzle PuzzleSerializer::ReadPuzzle(int id) { - Puzzle p; - p.width = 2 * _memory->ReadPanelData(id, GRID_SIZE_X, 1)[0] - 1; - p.height = 2 * _memory->ReadPanelData(id, GRID_SIZE_Y, 1)[0] - 1; - 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. - p.grid.resize(p.width); - for (auto& row : p.grid) row.resize(p.height); + int width = 2 * _memory->ReadPanelData(id, GRID_SIZE_X, 1)[0] - 1; + int height = 2 * _memory->ReadPanelData(id, GRID_SIZE_Y, 1)[0] - 1; + if (width < 0 || height < 0) return Puzzle(); // @Error: Grid size should be always positive? Looks like the starting panels break this rule, though. + Puzzle p; + p.NewGrid(width, height); ReadIntersections(p, id); ReadDecorations(p, id); - return p; } -- cgit 1.4.1