[Scummvm-cvs-logs] scummvm master -> db536da8d3838bc69cd2c18f49d62e9151d425a5

wjp wjp at usecode.org
Mon Feb 28 21:42:06 CET 2011


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
ce288024b4 SCI: Fix crash with hunk refs in logkernel output
db536da8d3 SCI: Skip Ports when iterating over Windows in GC


Commit: ce288024b495032d15940dc4b93069a3bc845f48
    https://github.com/scummvm/scummvm/commit/ce288024b495032d15940dc4b93069a3bc845f48
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2011-02-28T12:37:12-08:00

Commit Message:
SCI: Fix crash with hunk refs in logkernel output

Changed paths:
    engines/sci/engine/vm.cpp



diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp
index 43d38a4..e00ec59 100644
--- a/engines/sci/engine/vm.cpp
+++ b/engines/sci/engine/vm.cpp
@@ -632,18 +632,41 @@ static void	logKernelCall(const KernelFunction *kernelCall, const KernelSubFunct
 				debugN(" (%s)", s->_segMan->getObjectName(argv[parmNr]));
 				break;
 			case SIG_TYPE_REFERENCE:
-				if (kernelCall->function == kSaid) {
-					SegmentRef saidSpec = s->_segMan->dereference(argv[parmNr]);
-					if (saidSpec.isRaw) {
-						debugN(" ('");
-						g_sci->getVocabulary()->debugDecipherSaidBlock(saidSpec.raw);
-						debugN("')");
+			{
+				SegmentObj *mobj = s->_segMan->getSegmentObj(argv[parmNr].segment);
+				switch (mobj->getType()) {
+				case SEG_TYPE_HUNK:
+				{
+					HunkTable *ht = (HunkTable*)mobj;
+					int index = argv[parmNr].offset;
+					if (ht->isValidEntry(index)) {
+						// NOTE: This ", deleted" isn't as useful as it could
+						// be because it prints the status _after_ the kernel
+						// call.
+						debugN(" ('%s' hunk%s)", ht->_table[index].type, ht->_table[index].mem ? "" : ", deleted");
+					} else
+						debugN(" (INVALID hunk ref)");
+					break;
+				}
+				default:
+					// TODO: Any other segment types which could
+					// use special handling?
+
+					if (kernelCall->function == kSaid) {
+						SegmentRef saidSpec = s->_segMan->dereference(argv[parmNr]);
+						if (saidSpec.isRaw) {
+							debugN(" ('");
+							g_sci->getVocabulary()->debugDecipherSaidBlock(saidSpec.raw);
+							debugN("')");
+						} else {
+							debugN(" (non-raw said-spec)");
+						}
 					} else {
-						debugN(" (non-raw said-spec)");
+						debugN(" ('%s')", s->_segMan->getString(argv[parmNr]).c_str());
 					}
-				} else {
-					debugN(" ('%s')", s->_segMan->getString(argv[parmNr]).c_str());
+					break;
 				}
+			}
 			default:
 				break;
 			}


Commit: db536da8d3838bc69cd2c18f49d62e9151d425a5
    https://github.com/scummvm/scummvm/commit/db536da8d3838bc69cd2c18f49d62e9151d425a5
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2011-02-28T12:37:12-08:00

Commit Message:
SCI: Skip Ports when iterating over Windows in GC

Changed paths:
    engines/sci/engine/gc.cpp
    engines/sci/graphics/helpers.h
    engines/sci/graphics/ports.cpp
    engines/sci/graphics/ports.h



diff --git a/engines/sci/engine/gc.cpp b/engines/sci/engine/gc.cpp
index e080ad6..15be17f 100644
--- a/engines/sci/engine/gc.cpp
+++ b/engines/sci/engine/gc.cpp
@@ -89,11 +89,11 @@ 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);
+		if ((*it)->isWindow()) {
+			Window *wnd = ((Window *)*it);
+			wm.push(wnd->hSaved1);
+			wm.push(wnd->hSaved2);
+		}
 	}
 }
 
diff --git a/engines/sci/graphics/helpers.h b/engines/sci/graphics/helpers.h
index f6cb214..3c6515a 100644
--- a/engines/sci/graphics/helpers.h
+++ b/engines/sci/graphics/helpers.h
@@ -45,6 +45,10 @@ typedef int GuiResourceId; // is a resource-number and -1 means no parameter giv
 
 typedef int16 TextAlignment;
 
+#define PORTS_FIRSTWINDOWID 2
+#define PORTS_FIRSTSCRIPTWINDOWID 3
+
+
 struct Port {
 	uint16 id;
 	int16 top, left;
@@ -62,6 +66,8 @@ struct Port {
 		fontHeight(0), fontId(0), greyedOutput(false),
 		penClr(0), backClr(0xFF), penMode(0), counterTillFree(0) {
 	}
+
+	bool isWindow() const { return id >= PORTS_FIRSTWINDOWID && id != 0xFFFF; }
 };
 
 struct Window : public Port, public Common::Serializable {
diff --git a/engines/sci/graphics/ports.cpp b/engines/sci/graphics/ports.cpp
index b19a862..9aa539a 100644
--- a/engines/sci/graphics/ports.cpp
+++ b/engines/sci/graphics/ports.cpp
@@ -246,8 +246,10 @@ void GfxPorts::beginUpdate(Window *wnd) {
 	PortList::iterator it = _windowList.reverse_begin();
 	const PortList::iterator end = Common::find(_windowList.begin(), _windowList.end(), wnd);
 	while (it != end) {
-		// FIXME: We also store Port objects in the window list.
-		// We should add a check that we really only pass windows here...
+		// We also store Port objects in the window list, but they
+		// shouldn't be encountered during this iteration.
+		assert((*it)->isWindow());
+
 		updateWindow((Window *)*it);
 		--it;
 	}
@@ -263,8 +265,10 @@ void GfxPorts::endUpdate(Window *wnd) {
 	assert(it != end);
 
 	while (++it != end) {
-		// FIXME: We also store Port objects in the window list.
-		// We should add a check that we really only pass windows here...
+		// We also store Port objects in the window list, but they
+		// shouldn't be encountered during this iteration.
+		assert((*it)->isWindow());
+
 		updateWindow((Window *)*it);
 	}
 
diff --git a/engines/sci/graphics/ports.h b/engines/sci/graphics/ports.h
index b94d54a..9faee2b 100644
--- a/engines/sci/graphics/ports.h
+++ b/engines/sci/graphics/ports.h
@@ -37,9 +37,6 @@ class GfxPaint16;
 class GfxScreen;
 class GfxText16;
 
-#define PORTS_FIRSTWINDOWID 2
-#define PORTS_FIRSTSCRIPTWINDOWID 3
-
 // window styles
 enum {
 	SCI_WINDOWMGR_STYLE_TRANSPARENT = (1 << 0),






More information about the Scummvm-git-logs mailing list