aboutsummaryrefslogtreecommitdiff
path: root/engines/toltecs
diff options
context:
space:
mode:
authorFilippos Karapetis2011-10-19 20:23:31 +0000
committerWillem Jan Palenstijn2011-11-20 22:43:11 +0100
commit5298859cbaa97b1fab98e6687fee8357a8bec199 (patch)
treeae258cbb9d8caefd23ce1277392bc24b9a61c3c5 /engines/toltecs
parent2b29dfe0c796a5077fea4e5b0a6dff9a3feeb1b6 (diff)
downloadscummvm-rg350-5298859cbaa97b1fab98e6687fee8357a8bec199.tar.gz
scummvm-rg350-5298859cbaa97b1fab98e6687fee8357a8bec199.tar.bz2
scummvm-rg350-5298859cbaa97b1fab98e6687fee8357a8bec199.zip
TOLTECS: The resource cache is now purged when changing rooms
Diffstat (limited to 'engines/toltecs')
-rw-r--r--engines/toltecs/TODO.txt1
-rw-r--r--engines/toltecs/resource.cpp12
-rw-r--r--engines/toltecs/resource.h1
-rw-r--r--engines/toltecs/script.cpp1
4 files changed, 13 insertions, 2 deletions
diff --git a/engines/toltecs/TODO.txt b/engines/toltecs/TODO.txt
index ae913ef6e4..449ffcbe15 100644
--- a/engines/toltecs/TODO.txt
+++ b/engines/toltecs/TODO.txt
@@ -12,7 +12,6 @@ TODO
delta-frames so currently, once restored, the screen is wrong. This is only observed in
a few places.
- Add "Quit game" functionality to the menu
-- Flush the resource cache when changing rooms, otherwise the game will keep eating up memory
BUGS
------
diff --git a/engines/toltecs/resource.cpp b/engines/toltecs/resource.cpp
index 62dbca3141..e1e3cb9ac7 100644
--- a/engines/toltecs/resource.cpp
+++ b/engines/toltecs/resource.cpp
@@ -90,7 +90,17 @@ ResourceCache::ResourceCache(ToltecsEngine *vm) : _vm(vm) {
}
ResourceCache::~ResourceCache() {
- // TODO: Delete resources
+ purgeCache();
+}
+
+void ResourceCache::purgeCache() {
+ for (ResourceMap::iterator iter = _cache.begin(); iter != _cache.end(); ++iter) {
+ delete[] iter->_value->data;
+ delete iter->_value;
+ iter->_value = 0;
+ }
+
+ _cache.clear();
}
Resource *ResourceCache::load(uint resIndex) {
diff --git a/engines/toltecs/resource.h b/engines/toltecs/resource.h
index 0201bd5daa..7f4694f0f6 100644
--- a/engines/toltecs/resource.h
+++ b/engines/toltecs/resource.h
@@ -68,6 +68,7 @@ public:
~ResourceCache();
Resource *load(uint resIndex);
+ void purgeCache();
protected:
typedef Common::HashMap<uint, Resource*> ResourceMap;
diff --git a/engines/toltecs/script.cpp b/engines/toltecs/script.cpp
index 8f534ef398..780e9ef215 100644
--- a/engines/toltecs/script.cpp
+++ b/engines/toltecs/script.cpp
@@ -896,6 +896,7 @@ void ScriptInterpreter::sfLoadAddPalette() {
void ScriptInterpreter::sfLoadScene() {
if (arg8(3) == 0) {
_vm->_sound->stopSpeech();
+ _vm->_res->purgeCache();
_vm->loadScene(arg16(4));
} else {
_vm->_screen->loadMouseCursor(arg16(4));