diff options
author | johndoe123 | 2013-01-10 00:08:41 +0000 |
---|---|---|
committer | Willem Jan Palenstijn | 2013-05-08 20:47:39 +0200 |
commit | fec1d7816a3e9924db7eb617eda1a6f3fd7b8978 (patch) | |
tree | 4e03d0a26dacd3666eb58becd4ac4befd2b197a6 | |
parent | 30178e46e522c6d741e82e282f3f3edc1fab4825 (diff) | |
download | scummvm-rg350-fec1d7816a3e9924db7eb617eda1a6f3fd7b8978.tar.gz scummvm-rg350-fec1d7816a3e9924db7eb617eda1a6f3fd7b8978.tar.bz2 scummvm-rg350-fec1d7816a3e9924db7eb617eda1a6f3fd7b8978.zip |
NEVERHOOD: Implement resource cache purging and purge it after each scene
-rw-r--r-- | engines/neverhood/resourceman.cpp | 10 | ||||
-rw-r--r-- | engines/neverhood/resourceman.h | 1 | ||||
-rw-r--r-- | engines/neverhood/scene.cpp | 3 |
3 files changed, 14 insertions, 0 deletions
diff --git a/engines/neverhood/resourceman.cpp b/engines/neverhood/resourceman.cpp index 7b7d5cf236..9e5f9ae52f 100644 --- a/engines/neverhood/resourceman.cpp +++ b/engines/neverhood/resourceman.cpp @@ -116,4 +116,14 @@ void ResourceMan::unloadResource(ResourceHandle &resourceHandle) { } } +void ResourceMan::purgeResources() { + for (Common::HashMap<uint32, ResourceData*>::iterator it = _data.begin(); it != _data.end(); ++it) { + ResourceData *resourceData = (*it)._value; + if (resourceData->dataRefCount == 0) { + delete resourceData->data; + resourceData->data = NULL; + } + } +} + } // End of namespace Neverhood diff --git a/engines/neverhood/resourceman.h b/engines/neverhood/resourceman.h index e83de240ed..5a3697fe0d 100644 --- a/engines/neverhood/resourceman.h +++ b/engines/neverhood/resourceman.h @@ -80,6 +80,7 @@ public: void queryResource(uint32 fileHash, ResourceHandle &resourceHandle); void loadResource(ResourceHandle &resourceHandle); void unloadResource(ResourceHandle &resourceHandle); + void purgeResources(); protected: typedef Common::HashMap<uint32, ResourceFileEntry> EntriesMap; Common::Array<BlbArchive*> _archives; diff --git a/engines/neverhood/scene.cpp b/engines/neverhood/scene.cpp index 6141ee4487..c899a59408 100644 --- a/engines/neverhood/scene.cpp +++ b/engines/neverhood/scene.cpp @@ -70,6 +70,9 @@ Scene::~Scene() { delete *iter; // Don't delete surfaces since they always belong to an entity + + // Purge the resources after each scene + _vm->_res->purgeResources(); } |