From 4f099a8fff0930a81c085dc8aa6be1b46a3ba491 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 27 Dec 2017 01:45:38 -0500 Subject: XEEN: Fix saving of map stepped on tiles --- engines/xeen/files.cpp | 13 +++++++------ engines/xeen/map.cpp | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/xeen/files.cpp b/engines/xeen/files.cpp index a889cfb95e..375b9df65a 100644 --- a/engines/xeen/files.cpp +++ b/engines/xeen/files.cpp @@ -321,22 +321,23 @@ void File::syncBitFlags(Common::Serializer &s, bool *startP, bool *endP) { byte data = 0; int bitCounter = 0; - for (bool *p = startP; p <= endP; ++p, bitCounter = (bitCounter + 1) % 8) { - if (p == endP || bitCounter == 0) { - if (p != endP || s.isSaving()) + for (bool *p = startP; p < endP; ++p, bitCounter = (bitCounter + 1) % 8) { + if (bitCounter == 0) { + if (s.isLoading() || p != startP) s.syncAsByte(data); - if (p == endP) - break; if (s.isSaving()) data = 0; } if (s.isLoading()) - *p = (data >> bitCounter) != 0; + *p = ((data >> bitCounter) & 1) != 0; else if (*p) data |= 1 << bitCounter; } + + if (s.isSaving()) + s.syncAsByte(data); } /*------------------------------------------------------------------------*/ diff --git a/engines/xeen/map.cpp b/engines/xeen/map.cpp index 27b746e427..611101eac7 100644 --- a/engines/xeen/map.cpp +++ b/engines/xeen/map.cpp @@ -1452,7 +1452,7 @@ void Map::saveMap() { if (!_isOutdoors) { // Iterate through the surrounding mazes for (int mazeIndex = 1; mazeIndex < 9; ++mazeIndex) { - mapId = _mazeData[_mazeDataIndex]._mazeId; + mapId = _mazeData[mazeIndex]._mazeId; if (mapId == 0) continue; -- cgit v1.2.3