aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Snover2017-11-14 12:58:38 -0600
committerEugene Sandulenko2017-11-18 22:35:12 +0100
commitc85f409a0b2fa1094ebd1a51c088d2d830383d38 (patch)
tree7c8ff6215994946f631309f305bdf1da8ede3caf
parent1337f04122cac5f0343090ac23119e4133624db0 (diff)
downloadscummvm-rg350-c85f409a0b2fa1094ebd1a51c088d2d830383d38.tar.gz
scummvm-rg350-c85f409a0b2fa1094ebd1a51c088d2d830383d38.tar.bz2
scummvm-rg350-c85f409a0b2fa1094ebd1a51c088d2d830383d38.zip
FULLPIPE: Remove memory leaks and manual memory management in Scene
-rw-r--r--engines/fullpipe/gameloader.cpp2
-rw-r--r--engines/fullpipe/scene.cpp21
-rw-r--r--engines/fullpipe/scene.h7
-rw-r--r--engines/fullpipe/scenes.cpp6
4 files changed, 14 insertions, 22 deletions
diff --git a/engines/fullpipe/gameloader.cpp b/engines/fullpipe/gameloader.cpp
index 32c2d0d2db..4ed1890de5 100644
--- a/engines/fullpipe/gameloader.cpp
+++ b/engines/fullpipe/gameloader.cpp
@@ -286,7 +286,7 @@ bool preloadCallback(PreloadItem &pre, int flag) {
if (g_fp->_soundEnabled) {
g_fp->_currSoundListCount = 1;
- g_fp->_currSoundList1[0] = g_fp->accessScene(SC_COMMON)->_soundList;
+ g_fp->_currSoundList1[0] = g_fp->accessScene(SC_COMMON)->_soundList.get();
}
g_vars->scene18_inScene18p1 = false;
diff --git a/engines/fullpipe/scene.cpp b/engines/fullpipe/scene.cpp
index 6295e3b2d6..751f9924e0 100644
--- a/engines/fullpipe/scene.cpp
+++ b/engines/fullpipe/scene.cpp
@@ -117,18 +117,9 @@ void SceneTag::loadScene() {
g_fp->_currArchive = 0;
}
-Scene::Scene() {
- _sceneId = 0;
- _field_BC = 0;
- _shadows = 0;
- _soundList = 0;
- _libHandle = 0;
-}
+Scene::Scene() : _sceneId(0), _field_BC(0) {}
Scene::~Scene() {
- delete _soundList;
- delete _shadows;
-
// _faObjlist is not used
for (uint i = 0; i < _messageQueueList.size(); i++)
@@ -141,8 +132,6 @@ Scene::~Scene() {
_staticANIObjectList1.clear();
- delete _libHandle;
-
// delete _field_BC;
}
@@ -206,7 +195,7 @@ bool Scene::load(MfcArchive &file) {
assert(0);
}
- _libHandle = g_fp->_currArchive;
+ _libHandle.reset(g_fp->_currArchive);
if (_picObjList.size() > 0 && !_bgname.empty()) {
char fname[260];
@@ -231,12 +220,14 @@ bool Scene::load(MfcArchive &file) {
Shadows *shd = new Shadows();
if (shd->loadFile(shdname))
- _shadows = shd;
+ _shadows.reset(shd);
+ else
+ delete shd;
Common::String slsname = genFileName(0, _sceneId, "sls");
if (g_fp->_soundEnabled) {
- _soundList = new SoundList();
+ _soundList.reset(new SoundList());
if (g_fp->_flgSoundList) {
Common::String nlname = genFileName(17, _sceneId, "nl");
diff --git a/engines/fullpipe/scene.h b/engines/fullpipe/scene.h
index 9a684ce7bc..dd559a3cf2 100644
--- a/engines/fullpipe/scene.h
+++ b/engines/fullpipe/scene.h
@@ -23,6 +23,7 @@
#ifndef FULLPIPE_SCENE_H
#define FULLPIPE_SCENE_H
+#include "common/ptr.h"
#include "fullpipe/gfx.h"
namespace Fullpipe {
@@ -35,12 +36,12 @@ class Scene : public Background {
Common::Array<StaticANIObject *> _staticANIObjectList2;
Common::Array<MessageQueue *> _messageQueueList;
// PtrList _faObjectList; // not used
- Shadows *_shadows;
- SoundList *_soundList;
+ Common::ScopedPtr<Shadows> _shadows;
+ Common::ScopedPtr<SoundList> _soundList;
int16 _sceneId;
Common::String _sceneName;
int _field_BC;
- NGIArchive *_libHandle;
+ Common::ScopedPtr<NGIArchive> _libHandle;
public:
Scene();
diff --git a/engines/fullpipe/scenes.cpp b/engines/fullpipe/scenes.cpp
index 896ea5a3fb..034d2a7383 100644
--- a/engines/fullpipe/scenes.cpp
+++ b/engines/fullpipe/scenes.cpp
@@ -573,15 +573,15 @@ bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) {
if (_soundEnabled) {
if (scene->_soundList) {
_currSoundListCount = 2;
- _currSoundList1[0] = accessScene(SC_COMMON)->_soundList;
- _currSoundList1[1] = scene->_soundList;
+ _currSoundList1[0] = accessScene(SC_COMMON)->_soundList.get();
+ _currSoundList1[1] = scene->_soundList.get();
for (int i = 0; i < scene->_soundList->getCount(); i++) {
scene->_soundList->getSoundByIndex(i).updateVolume();
}
} else {
_currSoundListCount = 1;
- _currSoundList1[0] = accessScene(SC_COMMON)->_soundList;
+ _currSoundList1[0] = accessScene(SC_COMMON)->_soundList.get();
}
}