about summary refs log tree commit diff stats
path: root/Source/PuzzleSerializer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/PuzzleSerializer.cpp')
-rw-r--r--Source/PuzzleSerializer.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/Source/PuzzleSerializer.cpp b/Source/PuzzleSerializer.cpp index 3732db8..e316216 100644 --- a/Source/PuzzleSerializer.cpp +++ b/Source/PuzzleSerializer.cpp
@@ -179,6 +179,7 @@ void PuzzleSerializer::ReadExtras(Puzzle& p) {
179 179
180void PuzzleSerializer::ReadDecorations(Puzzle& p, int id) { 180void PuzzleSerializer::ReadDecorations(Puzzle& p, int id) {
181 int numDecorations = _memory->ReadEntityData<int>(id, NUM_DECORATIONS, 1)[0]; 181 int numDecorations = _memory->ReadEntityData<int>(id, NUM_DECORATIONS, 1)[0];
182 if (numDecorations == 0) return;
182 std::vector<int> decorations = _memory->ReadArray<int>(id, DECORATIONS, numDecorations); 183 std::vector<int> decorations = _memory->ReadArray<int>(id, DECORATIONS, numDecorations);
183 if (numDecorations > 0) p.hasDecorations = true; 184 if (numDecorations > 0) p.hasDecorations = true;
184 185
@@ -203,6 +204,7 @@ void PuzzleSerializer::ReadDecorations(Puzzle& p, int id) {
203 204
204void PuzzleSerializer::ReadSequence(Puzzle& p, int id) { 205void PuzzleSerializer::ReadSequence(Puzzle& p, int id) {
205 int sequenceLength = _memory->ReadEntityData<int>(id, SEQUENCE_LEN, 1)[0]; 206 int sequenceLength = _memory->ReadEntityData<int>(id, SEQUENCE_LEN, 1)[0];
207 if (sequenceLength == 0) return;
206 std::vector<int> sequence = _memory->ReadArray<int>(id, SEQUENCE, sequenceLength); 208 std::vector<int> sequence = _memory->ReadArray<int>(id, SEQUENCE, sequenceLength);
207 209
208 for (int location : sequence) { 210 for (int location : sequence) {
@@ -545,6 +547,8 @@ std::tuple<int, int> PuzzleSerializer::loc_to_xy(const Puzzle& p, int location)
545 547
546 int x = 2 * (location % width2); 548 int x = 2 * (location % width2);
547 int y = 2 * (height2 - location / width2); 549 int y = 2 * (height2 - location / width2);
550 assert(x >= 0 && x < p.width);
551 assert(y >= 0 && y < p.height);
548 return {x, y}; 552 return {x, y};
549} 553}
550 554