diff options
Diffstat (limited to 'Source/PuzzleSerializer.cpp')
-rw-r--r-- | Source/PuzzleSerializer.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Source/PuzzleSerializer.cpp b/Source/PuzzleSerializer.cpp index c1e93a5..e845578 100644 --- a/Source/PuzzleSerializer.cpp +++ b/Source/PuzzleSerializer.cpp | |||
@@ -1,5 +1,6 @@ | |||
1 | #include "PuzzleSerializer.h" | 1 | #include "PuzzleSerializer.h" |
2 | #include "Memory.h" | 2 | #include "Memory.h" |
3 | #include <cassert> | ||
3 | 4 | ||
4 | #pragma warning (disable:26451) | 5 | #pragma warning (disable:26451) |
5 | #pragma warning (disable:26812) | 6 | #pragma warning (disable:26812) |
@@ -47,6 +48,16 @@ void PuzzleSerializer::WritePuzzle(const Puzzle& p, int id) { | |||
47 | WriteDecorations(p, id); | 48 | WriteDecorations(p, id); |
48 | WriteSequence(p, id); | 49 | WriteSequence(p, id); |
49 | 50 | ||
51 | #ifndef NDEBUG | ||
52 | int maxDots = _memory->ReadEntityData<int>(id, NUM_DOTS, 1)[0]; | ||
53 | assert(_intersectionFlags.size() <= maxDots); | ||
54 | assert(_intersectionLocations.size() <= maxDots*2); | ||
55 | |||
56 | int maxConnections = _memory->ReadEntityData<int>(id, NUM_CONNECTIONS, 1)[0]; | ||
57 | assert(_connectionsA.size() <= maxConnections); | ||
58 | assert(_connectionsB.size() <= maxConnections); | ||
59 | #endif | ||
60 | |||
50 | _memory->WriteEntityData<int>(id, GRID_SIZE_X, {(p.width + 1)/2}); | 61 | _memory->WriteEntityData<int>(id, GRID_SIZE_X, {(p.width + 1)/2}); |
51 | _memory->WriteEntityData<int>(id, GRID_SIZE_Y, {(p.height + 1)/2}); | 62 | _memory->WriteEntityData<int>(id, GRID_SIZE_Y, {(p.height + 1)/2}); |
52 | _memory->WriteEntityData<int>(id, NUM_DOTS, {static_cast<int>(_intersectionFlags.size())}); | 63 | _memory->WriteEntityData<int>(id, NUM_DOTS, {static_cast<int>(_intersectionFlags.size())}); |
@@ -376,6 +387,10 @@ void PuzzleSerializer::WriteDecorations(const Puzzle& p, int id) { | |||
376 | } | 387 | } |
377 | } | 388 | } |
378 | 389 | ||
390 | #ifndef NDEBUG | ||
391 | int maxDecorations = _memory->ReadEntityData<int>(id, NUM_DECORATIONS, 1)[0]; | ||
392 | assert(decorations.size() < maxDecorations); | ||
393 | #endif | ||
379 | _memory->WriteEntityData<int>(id, NUM_DECORATIONS, {static_cast<int>(decorations.size())}); | 394 | _memory->WriteEntityData<int>(id, NUM_DECORATIONS, {static_cast<int>(decorations.size())}); |
380 | _memory->WriteArray<int>(id, DECORATIONS, decorations); | 395 | _memory->WriteArray<int>(id, DECORATIONS, decorations); |
381 | } | 396 | } |