diff options
author | Paul Gilbert | 2019-08-24 20:31:56 -0700 |
---|---|---|
committer | Paul Gilbert | 2019-08-24 20:33:22 -0700 |
commit | 4b6578603d1195f04be230870ab003ed0698d936 (patch) | |
tree | 8b7441f0cb94b206364cbcca8e7b9cb79e6fdf6a /engines/xeen | |
parent | a5955999284580ba87225beadcc760a96c7e0645 (diff) | |
download | scummvm-rg350-4b6578603d1195f04be230870ab003ed0698d936.tar.gz scummvm-rg350-4b6578603d1195f04be230870ab003ed0698d936.tar.bz2 scummvm-rg350-4b6578603d1195f04be230870ab003ed0698d936.zip |
XEEN: Fix incorrect Throne sprites in Northern Sphinx
The Northern Sphinx used a list of object sprites that had
an empty entry mid-list. This commit fixes the problem by
allow such entries, but will only apply for new games
Diffstat (limited to 'engines/xeen')
-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; |