diff options
author | Paul Gilbert | 2015-03-22 09:51:37 -0400 |
---|---|---|
committer | Paul Gilbert | 2015-03-22 09:51:37 -0400 |
commit | e444d989bb3470650020cb2c3f0fdb7b2fcab70a (patch) | |
tree | 9232d6357c0f5106176d12d29060106b1c1c05d4 /engines/sherlock | |
parent | 3c77a521dc07a8c0954b11b26dda382817776b9e (diff) | |
download | scummvm-rg350-e444d989bb3470650020cb2c3f0fdb7b2fcab70a.tar.gz scummvm-rg350-e444d989bb3470650020cb2c3f0fdb7b2fcab70a.tar.bz2 scummvm-rg350-e444d989bb3470650020cb2c3f0fdb7b2fcab70a.zip |
SHERLOCK: Implemented scene freeing code
Diffstat (limited to 'engines/sherlock')
-rw-r--r-- | engines/sherlock/inventory.cpp | 2 | ||||
-rw-r--r-- | engines/sherlock/objects.cpp | 2 | ||||
-rw-r--r-- | engines/sherlock/objects.h | 4 | ||||
-rw-r--r-- | engines/sherlock/scene.cpp | 42 | ||||
-rw-r--r-- | engines/sherlock/scene.h | 6 | ||||
-rw-r--r-- | engines/sherlock/sherlock.cpp | 2 | ||||
-rw-r--r-- | engines/sherlock/sherlock.h | 1 | ||||
-rw-r--r-- | engines/sherlock/sound.cpp | 4 | ||||
-rw-r--r-- | engines/sherlock/sound.h | 1 |
9 files changed, 42 insertions, 22 deletions
diff --git a/engines/sherlock/inventory.cpp b/engines/sherlock/inventory.cpp index cbb69f1041..2a277a6331 100644 --- a/engines/sherlock/inventory.cpp +++ b/engines/sherlock/inventory.cpp @@ -106,7 +106,7 @@ void Inventory::loadGraphics() { int Inventory::findInv(const Common::String &name) { int result = -1; - for (uint idx = 0; (idx < _holdings) && result == -1; ++idx) { + for (int idx = 0; (idx < _holdings) && result == -1; ++idx) { if (scumm_stricmp(name.c_str(), _names[idx].c_str()) == 0) result = idx; } diff --git a/engines/sherlock/objects.cpp b/engines/sherlock/objects.cpp index 1643bef7b0..bbe2c9d4d2 100644 --- a/engines/sherlock/objects.cpp +++ b/engines/sherlock/objects.cpp @@ -946,7 +946,7 @@ void CAnim::synchronize(Common::SeekableReadStream &s) { /*----------------------------------------------------------------*/ -InvGraphicType::InvGraphicType() { +SceneImage::SceneImage() { _images = nullptr; _maxFrames = 0; _filesize = 0; diff --git a/engines/sherlock/objects.h b/engines/sherlock/objects.h index ee82faf99c..2ac2e16da0 100644 --- a/engines/sherlock/objects.h +++ b/engines/sherlock/objects.h @@ -223,12 +223,12 @@ struct CAnim { void synchronize(Common::SeekableReadStream &s); }; -struct InvGraphicType { +struct SceneImage { ImageFile *_images; // Object images int _maxFrames; // How many frames in object int _filesize; // File size - InvGraphicType(); + SceneImage(); } ; } // End of namespace Sherlock diff --git a/engines/sherlock/scene.cpp b/engines/sherlock/scene.cpp index e0b5dc1711..18ccdd4050 100644 --- a/engines/sherlock/scene.cpp +++ b/engines/sherlock/scene.cpp @@ -149,13 +149,7 @@ Scene::Scene(SherlockEngine *vm): _vm(vm) { Scene::~Scene() { delete _controlPanel; delete _controls; - clear(); -} - -/** - * Takes care of clearing any scene data - */ -void Scene::clear() { + freeScene(); } /** @@ -203,10 +197,27 @@ void Scene::selectScene() { * Fres all the graphics and other dynamically allocated data for the scene */ void Scene::freeScene() { + _vm->_talk->freeTalkVars(); _vm->_inventory->freeInventory(); + _vm->_sound->freeSong(); + _vm->_sound->freeLoadedSounds(); + if (!_vm->_loadingSavedGame) + saveSceneStatus(); + else + _vm->_loadingSavedGame = false; + + _sequenceBuffer.clear(); + _descText.clear(); + _walkData.clear(); + _cAnim.clear(); + _bgShapes.clear(); _roomBounds.clear(); _canimShapes.clear(); + + for (uint idx = 0; idx < _images.size(); ++idx) + delete _images[idx]._images; + _images.clear(); } /** @@ -225,6 +236,7 @@ bool Scene::loadScene(const Common::String &filename) { Sound &sound = *_vm->_sound; bool flag; + freeScene(); _walkedInScene = false; _ongoingCans = 0; @@ -232,7 +244,6 @@ bool Scene::loadScene(const Common::String &filename) { _roomBounds.clear(); _roomBounds.push_back(Common::Rect(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT)); - clear(); _descText.clear(); _comments = ""; _bgShapes.clear(); @@ -287,17 +298,17 @@ bool Scene::loadScene(const Common::String &filename) { if (_lzwMode) delete infoStream; - // Set up inv list - _inv.resize(bgHeader._numImages + 1); + // Set up the list of images used by the scene + _images.resize(bgHeader._numImages + 1); for (int idx = 0; idx < bgHeader._numImages; ++idx) { - _inv[idx + 1]._filesize = bgInfo[idx]._filesize; - _inv[idx + 1]._maxFrames = bgInfo[idx]._maxFrames; + _images[idx + 1]._filesize = bgInfo[idx]._filesize; + _images[idx + 1]._maxFrames = bgInfo[idx]._maxFrames; // Read in the image data Common::SeekableReadStream *imageStream = !_lzwMode ? rrmStream : decompressLZ(*rrmStream, bgInfo[idx]._filesize); - _inv[idx + 1]._images = new ImageFile(*imageStream); + _images[idx + 1]._images = new ImageFile(*imageStream); if (_lzwMode) delete imageStream; @@ -315,7 +326,7 @@ bool Scene::loadScene(const Common::String &filename) { _bgShapes[idx]._position = Common::Point(0, 0); _bgShapes[idx]._oldSize = Common::Point(1, 1); - _bgShapes[idx]._images = _inv[_bgShapes[idx]._misc]._images; + _bgShapes[idx]._images = _images[_bgShapes[idx]._misc]._images; _bgShapes[idx]._imageFrame = !_bgShapes[idx]._images ? (ImageFrame *)nullptr : &(*_bgShapes[idx]._images)[0]; } @@ -1437,5 +1448,8 @@ void Scene::clearInfo() { } } +void Scene::saveSceneStatus() { + // TODO +} } // End of namespace Sherlock diff --git a/engines/sherlock/scene.h b/engines/sherlock/scene.h index 25c97c097a..3cdb20ac0f 100644 --- a/engines/sherlock/scene.h +++ b/engines/sherlock/scene.h @@ -133,6 +133,8 @@ private: void updateBackground(); void checkBgShapes(ImageFrame *frame, const Common::Point &pt); + + void saveSceneStatus(); public: int _currentScene; int _goToScene; @@ -159,7 +161,7 @@ public: Common::Array<Object> _bgShapes; Common::Array<CAnim> _cAnim; Common::Array<byte> _sequenceBuffer; - Common::Array<InvGraphicType> _inv; + Common::Array<SceneImage> _images; int _walkDirectory[MAX_ZONES][MAX_ZONES]; Common::Array<byte> _walkData; Common::Array<Exit> _exits; @@ -176,8 +178,6 @@ public: Scene(SherlockEngine *vm); ~Scene(); - void clear(); - void selectScene(); void freeScene(); diff --git a/engines/sherlock/sherlock.cpp b/engines/sherlock/sherlock.cpp index e023bf9b16..ad590e3ffd 100644 --- a/engines/sherlock/sherlock.cpp +++ b/engines/sherlock/sherlock.cpp @@ -43,6 +43,7 @@ SherlockEngine::SherlockEngine(OSystem *syst, const SherlockGameDescription *gam _talk = nullptr; _useEpilogue2 = false; _justLoaded = false; + _loadingSavedGame = false; _onChessboard = false; _slowChess = false; _menuCounter = 0; @@ -126,7 +127,6 @@ void SherlockEngine::sceneLoop() { } _scene->freeScene(); - _talk->freeTalkVars(); _people->freeWalk(); } diff --git a/engines/sherlock/sherlock.h b/engines/sherlock/sherlock.h index 11bea9bdcd..b84f6d7429 100644 --- a/engines/sherlock/sherlock.h +++ b/engines/sherlock/sherlock.h @@ -96,6 +96,7 @@ public: Common::String _titleOverride; bool _useEpilogue2; bool _justLoaded; + bool _loadingSavedGame; int _oldCharPoint; // Old scene Common::Point _over; // Old map position Common::Array<Common::Point> _map; // Map locations for each scene diff --git a/engines/sherlock/sound.cpp b/engines/sherlock/sound.cpp index e8e433fa84..5e7df5607f 100644 --- a/engines/sherlock/sound.cpp +++ b/engines/sherlock/sound.cpp @@ -56,6 +56,10 @@ void Sound::playCachedSound(int index) { // TODO } +void Sound::freeLoadedSounds() { + // TODO +} + void Sound::clearCache() { // TODO } diff --git a/engines/sherlock/sound.h b/engines/sherlock/sound.h index 3f32f2724a..74e8db3611 100644 --- a/engines/sherlock/sound.h +++ b/engines/sherlock/sound.h @@ -55,6 +55,7 @@ public: void cacheSound(const Common::String &name, int index); void playLoadedSound(int bufNum, int waitMode); void playCachedSound(int index); + void freeLoadedSounds(); void clearCache(); void stopSound(); int loadSong(int songNumber); |