diff options
author | Paul Gilbert | 2014-03-08 15:42:07 -0500 |
---|---|---|
committer | Paul Gilbert | 2014-03-08 15:42:07 -0500 |
commit | 5536b8a933f792f45d08ab5126e826a9a20fa476 (patch) | |
tree | 30ad251d2dd4b09449214bb71590605636838519 | |
parent | c2587af8f29b2b79beae7fda5a9b983614840b17 (diff) | |
download | scummvm-rg350-5536b8a933f792f45d08ab5126e826a9a20fa476.tar.gz scummvm-rg350-5536b8a933f792f45d08ab5126e826a9a20fa476.tar.bz2 scummvm-rg350-5536b8a933f792f45d08ab5126e826a9a20fa476.zip |
MADS: Fixes for sprite list initialisation
-rw-r--r-- | engines/mads/animation.cpp | 1 | ||||
-rw-r--r-- | engines/mads/game.cpp | 4 | ||||
-rw-r--r-- | engines/mads/scene.cpp | 4 | ||||
-rw-r--r-- | engines/mads/sequence.cpp | 8 | ||||
-rw-r--r-- | engines/mads/sprites.cpp | 2 | ||||
-rw-r--r-- | engines/mads/sprites.h | 2 |
6 files changed, 12 insertions, 9 deletions
diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index fad5b27ea7..2117ae2068 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -271,6 +271,7 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, _spriteSets[i] = nullptr; } else { _spriteSets[i] = new SpriteAsset(_vm, _header._spriteSetNames[i], flags); + _spriteListIndexes[i] = _vm->_game->_scene._sprites.add(_spriteSets[i]); } } diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp index 0367aa690f..d206823058 100644 --- a/engines/mads/game.cpp +++ b/engines/mads/game.cpp @@ -121,7 +121,7 @@ void Game::gameLoop() { initSection(_sectionNumber); _sectionHandler->postLoadSection(); - _scene._spriteSlots.clear(true); + _scene._spriteSlots.reset(); if (_sectionNumber == _currentSectionNumber) { sectionLoop(); @@ -164,7 +164,7 @@ void Game::sectionLoop() { if (_player._spritesLoaded) _scene._spriteSlots.releasePlayerSprites(); _vm->_palette->resetGamePalette(18, 10); - _scene._spriteSlots.clear(true); + _scene._spriteSlots.reset(); } else { _vm->_palette->initGamePalette(); } diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 17c579bddd..8521c2e0b4 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -126,7 +126,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { if (palFlag) _vm->_palette->resetGamePalette(18, 10); - _spriteSlots.clear(false); + _spriteSlots.reset(false); _sequences.clear(); _kernelMessages.clear(); @@ -166,7 +166,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { _bandsRange = _sceneInfo->_yBandsEnd - _sceneInfo->_yBandsStart; _scaleRange = _sceneInfo->_maxScale - _sceneInfo->_minScale; - _spriteSlots.clear(false); + _spriteSlots.reset(false); _interfaceY = MADS_SCENE_HEIGHT; _spritesCount = _sprites.size(); diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp index e8c5a37298..f703ce3b3a 100644 --- a/engines/mads/sequence.cpp +++ b/engines/mads/sequence.cpp @@ -50,10 +50,12 @@ namespace MADS { /*------------------------------------------------------------------------*/ -#define TIMER_LIST_SIZE 30 +#define SEQUENCE_LIST_SIZE 30 SequenceList::SequenceList(MADSEngine *vm) : _vm(vm) { - for (int i = 0; i < TIMER_LIST_SIZE; ++i) { + // IMPORTANT: Preallocate timer slots. Note that sprite slots refer to entries + // in this list by index, so we can't just add or delete entries later + for (int i = 0; i < SEQUENCE_LIST_SIZE; ++i) { SequenceEntry rec; rec._active = false; rec._dynamicHotspotIndex = -1; @@ -239,7 +241,7 @@ bool SequenceList::loadSprites(int seqIndex) { if (seqEntry._frameIndex > seqEntry._numSprites) { result = true; if (seqEntry._animType == ANIMTYPE_CYCLED) { - // Reset back to the starting frame (cyclic) + // back to the starting frame (cyclic) seqEntry._frameIndex = seqEntry._frameStart; } else { diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp index 82e45deffc..b18efa223b 100644 --- a/engines/mads/sprites.cpp +++ b/engines/mads/sprites.cpp @@ -168,7 +168,7 @@ SpriteSlots::SpriteSlots(MADSEngine *vm) : _vm(vm) { SpriteSlot::_vm = vm; } -void SpriteSlots::clear(bool flag) { +void SpriteSlots::reset(bool flag) { _vm->_game->_scene._textDisplay.clear(); if (flag) diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h index 2a85115330..0e4e86a273 100644 --- a/engines/mads/sprites.h +++ b/engines/mads/sprites.h @@ -153,7 +153,7 @@ public: * Clears any pending slot data and schedules a full screen refresh. * @param flag Also reset sprite list */ - void clear(bool flag); + void reset(bool flag = true); /** * Delete any sprites used by the player |