diff options
Diffstat (limited to 'engines/mads/scene.cpp')
-rw-r--r-- | engines/mads/scene.cpp | 105 |
1 files changed, 103 insertions, 2 deletions
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index cf7ba6c674..46190d12be 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -22,16 +22,26 @@ #include "common/scummsys.h" #include "mads/scene.h" +#include "mads/mads.h" +#include "mads/nebular/nebular_scenes.h" namespace MADS { -Scene::Scene() { +Scene::Scene(MADSEngine *vm): _vm(vm) { _sectionNum = 1; - _sectionNum2 = -1; + _sectionNumPrior = -1; _priorSectionNum = 0; _priorSceneId = 0; _nextSceneId = 0; _currentSceneId = 0; + _vocabCount = 0; + _vocabBuffer = nullptr; + _sceneLogic = nullptr; +} + +Scene::~Scene() { + delete[] _vocabBuffer; + delete _sceneLogic; } void Scene::clearSprites(bool flag) { @@ -45,6 +55,86 @@ void Scene::clearSprites(bool flag) { _spriteSlots.push_back(SpriteSlot(ST_FULL_SCREEN_REFRESH, -1)); } +/** + * Releases any sprites used by the player + */ +void Scene::releasePlayerSprites() { + Player &player = _vm->_game->player(); + + if (player._spritesLoaded && player._numSprites > 0) { + int spriteEnd = player._spriteListStart + player._numSprites - 1; + do { + deleteSpriteEntry(spriteEnd); + } while (--spriteEnd >= player._spriteListStart); + } +} + +void Scene::deleteSpriteEntry(int listIndex) { + delete _spriteList[listIndex]; + _spriteList.remove_at(listIndex); +} + +void Scene::clearDynamicHotspots() { + _dynamicHotspots.clear(); + _dynamicHotspotsChanged = false; +} + +void Scene::clearVocab() { + freeVocab(); + _vocabCount = 0; +} + +void Scene::freeVocab() { + delete[] _vocabBuffer; + _vocabBuffer = nullptr; +} + +void Scene::addActiveVocab(int vocabId) { + if (activeVocabIndexOf(vocabId) == -1) { + assert(_activeVocabs.size() < 200); + _activeVocabs.push_back(vocabId); + } +} + +int Scene::activeVocabIndexOf(int vocabId) { + for (uint i = 0; i < _activeVocabs.size(); ++i) { + if (_activeVocabs[i] == vocabId) + return i; + } + + return -1; +} + +void Scene::addVisitedScene(int sceneId) { + if (!visitedScenesExists(sceneId)) + _visitedScenes.push_back(sceneId); +} + +bool Scene::visitedScenesExists(int sceneId) { + for (int i = 0; i < _visitedScenes.size(); ++i) { + if (_visitedScenes[i] == sceneId) + return true; + } + + return false; +} + +void Scene::loadScene() { + delete _sceneLogic; + + switch (_vm->getGameID()) { + case GType_RexNebular: + _sceneLogic = Nebular::SceneFactory::createScene(this); + break; + default: + error("Unknown game"); + } +} + +void Scene::free() { + warning("TODO: Scene::free"); +} + /*------------------------------------------------------------------------*/ SpriteSlot::SpriteSlot() { @@ -74,4 +164,15 @@ TextDisplay::TextDisplay() { _col1 = _col2 = 0; } +/*------------------------------------------------------------------------*/ + +DynamicHotspot::DynamicHotspot() { + _seqIndex = 0; + _facing = 0; + _descId = 0; + _field14 = 0; + _articleNumber = 0; + _cursor = 0; +} + } // End of namespace MADS |