aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine/gc.cpp
diff options
context:
space:
mode:
authormd52011-02-28 14:22:16 +0200
committermd52011-02-28 15:56:03 +0200
commit0d555c497d7208d0fa686f1b2369a52841873990 (patch)
tree41e30bc5bbe13f79e26b4f60e6192b3b3bc79d5b /engines/sci/engine/gc.cpp
parent9a60c58a8d1c91eb5731eaae0093b0ee4b68958f (diff)
downloadscummvm-rg350-0d555c497d7208d0fa686f1b2369a52841873990.tar.gz
scummvm-rg350-0d555c497d7208d0fa686f1b2369a52841873990.tar.bz2
scummvm-rg350-0d555c497d7208d0fa686f1b2369a52841873990.zip
SCI: Moved hunk pointer handling to the GC, and removed some related workarounds
SCI scripts can contain stale pointers, which are used later on. We now delete the contents of hunk entries without invalidating the relevant pointers and let the GC clear the references. Many thanks to waltervn and wjp for all their work and help on this.
Diffstat (limited to 'engines/sci/engine/gc.cpp')
-rw-r--r--engines/sci/engine/gc.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/engines/sci/engine/gc.cpp b/engines/sci/engine/gc.cpp
index 7692613ee5..e080ad6e4b 100644
--- a/engines/sci/engine/gc.cpp
+++ b/engines/sci/engine/gc.cpp
@@ -25,6 +25,7 @@
#include "sci/engine/gc.h"
#include "common/array.h"
+#include "sci/graphics/ports.h"
namespace Sci {
@@ -84,6 +85,18 @@ static void processWorkList(SegManager *segMan, WorklistManager &wm, const Commo
}
}
+static void processEngineHunkList(WorklistManager &wm) {
+ PortList windowList = g_sci->_gfxPorts->_windowList;
+
+ for (PortList::const_iterator it = windowList.begin(); it != windowList.end(); ++it) {
+ // FIXME: We also store Port objects in the window list.
+ // We should add a check that we really only pass windows here...
+ Window *wnd = ((Window *)*it);
+ wm.push(wnd->hSaved1);
+ wm.push(wnd->hSaved2);
+ }
+}
+
AddrSet *findAllActiveReferences(EngineState *s) {
assert(!s->_executionStack.empty());
@@ -142,6 +155,7 @@ AddrSet *findAllActiveReferences(EngineState *s) {
debugC(kDebugLevelGC, "[GC] -- Finished explicitly loaded scripts, done with root set");
processWorkList(s->_segMan, wm, heap);
+ processEngineHunkList(wm);
return normalizeAddresses(s->_segMan, wm._map);
}