diff options
-rw-r--r-- | engines/fullpipe/gameloader.cpp | 2 | ||||
-rw-r--r-- | engines/fullpipe/scene.cpp | 27 | ||||
-rw-r--r-- | engines/fullpipe/scene.h | 5 | ||||
-rw-r--r-- | engines/fullpipe/scenes/scene18and19.cpp | 1 |
4 files changed, 15 insertions, 20 deletions
diff --git a/engines/fullpipe/gameloader.cpp b/engines/fullpipe/gameloader.cpp index f2c078a7fa..70cb937da4 100644 --- a/engines/fullpipe/gameloader.cpp +++ b/engines/fullpipe/gameloader.cpp @@ -420,7 +420,7 @@ bool GameLoader::unloadScene(int sceneId) { _sc2array[sceneTag]._motionController->detachAllObjects(); delete tag->_scene; - tag->_scene = 0; + tag->_scene = nullptr; _sc2array[sceneTag]._isLoaded = 0; _sc2array[sceneTag]._scene = 0; diff --git a/engines/fullpipe/scene.cpp b/engines/fullpipe/scene.cpp index 751f9924e0..76384c3785 100644 --- a/engines/fullpipe/scene.cpp +++ b/engines/fullpipe/scene.cpp @@ -68,18 +68,17 @@ bool SceneTagList::load(MfcArchive &file) { return true; } -SceneTag::SceneTag() { - _field_4 = 0; - _scene = 0; - _sceneId = 0; +SceneTag::SceneTag() : + _scene(nullptr), + _sceneId(0) {} + +SceneTag::~SceneTag() { + delete _scene; } bool SceneTag::load(MfcArchive &file) { debugC(5, kDebugLoading, "SceneTag::load()"); - _field_4 = 0; - _scene = 0; - _sceneId = file.readUint16LE(); _tag = file.readPascalString(); @@ -89,11 +88,6 @@ bool SceneTag::load(MfcArchive &file) { return true; } -SceneTag::~SceneTag() { - delete _scene; - delete _field_4; -} - void SceneTag::loadScene() { Common::String archname = genFileName(0, _sceneId, "nl"); @@ -101,20 +95,19 @@ void SceneTag::loadScene() { Common::String fname = genFileName(0, _sceneId, "sc"); - Common::SeekableReadStream *file = arch->createReadStreamForMember(fname); + Common::ScopedPtr<Common::SeekableReadStream> file(arch->createReadStreamForMember(fname)); + delete _scene; _scene = new Scene(); - MfcArchive archive(file); + MfcArchive archive(file.get()); _scene->load(archive); if (_scene->_shadows) _scene->_shadows->init(); - delete file; - - g_fp->_currArchive = 0; + g_fp->_currArchive = nullptr; } Scene::Scene() : _sceneId(0), _field_BC(0) {} diff --git a/engines/fullpipe/scene.h b/engines/fullpipe/scene.h index dd559a3cf2..cc4cf17d64 100644 --- a/engines/fullpipe/scene.h +++ b/engines/fullpipe/scene.h @@ -65,6 +65,7 @@ class Scene : public Background { MessageQueue *getMessageQueueByName(const Common::String &name); void deleteStaticANIObject(StaticANIObject *obj); + /** takes ownership of the passed obj */ void addStaticANIObject(StaticANIObject *obj, bool addList2); void setPictureObjectsFlag4(); @@ -94,14 +95,14 @@ class Scene : public Background { class SceneTag : public CObject { public: - CObject *_field_4; Common::String _tag; + /** owned, but cannot use ScopedPtr because this object must be copyable */ Scene *_scene; int16 _sceneId; public: SceneTag(); - ~SceneTag(); + virtual ~SceneTag(); virtual bool load(MfcArchive &file); void loadScene(); diff --git a/engines/fullpipe/scenes/scene18and19.cpp b/engines/fullpipe/scenes/scene18and19.cpp index 7e26632cee..9181bc7d65 100644 --- a/engines/fullpipe/scenes/scene18and19.cpp +++ b/engines/fullpipe/scenes/scene18and19.cpp @@ -130,6 +130,7 @@ void scene19_setMovements(Scene *sc, int entranceId) { void scene19_preload() { for (SceneTagList::iterator s = g_fp->_gameProject->_sceneTagList->begin(); s != g_fp->_gameProject->_sceneTagList->end(); ++s) { if (s->_sceneId == SC_18) { + delete s->_scene; s->_scene = g_fp->_scene3; break; |