diff options
-rw-r--r-- | engines/xeen/map.cpp | 25 | ||||
-rw-r--r-- | engines/xeen/map.h | 5 |
2 files changed, 24 insertions, 6 deletions
diff --git a/engines/xeen/map.cpp b/engines/xeen/map.cpp index 9d384c7c8f..f2a9395b28 100644 --- a/engines/xeen/map.cpp +++ b/engines/xeen/map.cpp @@ -383,12 +383,24 @@ void MonsterObjectData::synchronize(XeenSerializer &s, MonsterData &monsterData) _wallItems.clear(); } - for (uint i = 0; i < 16; ++i) { - b = (i >= _objectSprites.size()) ? 0xff : _objectSprites[i]._spriteId; - s.syncAsByte(b); - if (s.isLoading() && b != 0xff) - _objectSprites.push_back(SpriteResourceEntry(b)); + byte objSprites[16]; + int maxSprite = 0; + for (int i = 0; i < 16; ++i) { + objSprites[i] = (i >= (int)_objectSprites.size()) ? 0xff : _objectSprites[i]._spriteId; + s.syncAsByte(objSprites[i]); + if (s.isLoading() && objSprites[i] != 0xff) + maxSprite = i; + } + + if (s.isLoading()) { + for (int i = 0; i <= maxSprite; ++i) { + if (objSprites[i] == 0xff) + _objectSprites.push_back(SpriteResourceEntry()); + else + _objectSprites.push_back(SpriteResourceEntry(objSprites[i])); + } } + for (uint i = 0; i < 16; ++i) { b = (i >= _monsterSprites.size()) ? 0xff : _monsterSprites[i]._spriteId; s.syncAsByte(b); @@ -810,7 +822,8 @@ void Map::load(int mapId) { } // Read in the object sprites - _mobData._objectSprites[i]._sprites.load(filename); + if (!_mobData._objectSprites[i].isEmpty()) + _mobData._objectSprites[i]._sprites.load(filename); } // Load sprites for the monsters diff --git a/engines/xeen/map.h b/engines/xeen/map.h index 1c00e549c3..cdd33760d7 100644 --- a/engines/xeen/map.h +++ b/engines/xeen/map.h @@ -319,6 +319,11 @@ public: SpriteResourceEntry() { _spriteId = -1; } SpriteResourceEntry(int spriteId): _spriteId(spriteId) { } + + /** + * Returns true if no sprite id is specified + */ + bool isEmpty() const { return _spriteId == -1; } }; private: XeenEngine *_vm; |