[Scummvm-cvs-logs] SF.net SVN: scummvm:[52508] scummvm/trunk/engines/sci/engine

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Fri Sep 3 20:15:00 CEST 2010


Revision: 52508
          http://scummvm.svn.sourceforge.net/scummvm/?rev=52508&view=rev
Author:   m_kiewitz
Date:     2010-09-03 18:14:59 +0000 (Fri, 03 Sep 2010)

Log Message:
-----------
SCI: kClone/kDisposeClone behaviour more accurate

now also checking -info- selector, if object is supposed to get freed. Fixes kq4 early hanging (in intro, when opening door, etc.)

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kscripts.cpp
    scummvm/trunk/engines/sci/engine/selector.cpp
    scummvm/trunk/engines/sci/engine/selector.h
    scummvm/trunk/engines/sci/engine/static_selectors.cpp

Modified: scummvm/trunk/engines/sci/engine/kscripts.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kscripts.cpp	2010-09-03 17:49:22 UTC (rev 52507)
+++ scummvm/trunk/engines/sci/engine/kscripts.cpp	2010-09-03 18:14:59 UTC (rev 52508)
@@ -172,27 +172,37 @@
 	s->_segMan->getScript(parent_obj->getPos().segment)->incrementLockers();
 	s->_segMan->getScript(clone_obj->getPos().segment)->incrementLockers();
 
+	// Mark as clone for scripts as well
+	uint16 infoSelector = readSelectorValue(s->_segMan, clone_addr, SELECTOR(_info_));
+	writeSelectorValue(s->_segMan, clone_addr, SELECTOR(_info_), (infoSelector & 0x7fff) | 1);
+
 	return clone_addr;
 }
 
 extern void _k_view_list_mark_free(EngineState *s, reg_t off);
 
 reg_t kDisposeClone(EngineState *s, int argc, reg_t *argv) {
-	reg_t victim_addr = argv[0];
-	Clone *victim_obj = s->_segMan->getObject(victim_addr);
+	reg_t obj = argv[0];
+	Clone *object = s->_segMan->getObject(obj);
 
-	if (!victim_obj) {
+	if (!object) {
 		error("Attempt to dispose non-class/object at %04x:%04x",
-		         PRINT_REG(victim_addr));
+		         PRINT_REG(obj));
 		return s->r_acc;
 	}
 
-	if (!victim_obj->isClone()) {
-		// SCI silently ignores this behaviour; some games actually depend on it
+	if (!object->isClone()) {
+		// SCI silently ignores non-clones; some games actually depend on it
 		return s->r_acc;
 	}
 
-	victim_obj->markAsFreed();
+	// SCI uses this technique to find out, if it's a clone and if it's supposed to get freed
+	//  At least kq4early relies on this behaviour. The scripts clone "Sound", then set bit 1 manually
+	//  and call kDisposeClone later. In that case we may not free it, otherwise we will run into issues
+	//  later, because kIsObject would then return false and Sound object wouldn't get checked.
+	uint16 infoSelector = readSelectorValue(s->_segMan, obj, SELECTOR(_info_));
+	if ((infoSelector & 3) == 1)
+		object->markAsFreed();
 
 	return s->r_acc;
 }

Modified: scummvm/trunk/engines/sci/engine/selector.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/selector.cpp	2010-09-03 17:49:22 UTC (rev 52507)
+++ scummvm/trunk/engines/sci/engine/selector.cpp	2010-09-03 18:14:59 UTC (rev 52508)
@@ -50,7 +50,7 @@
 void Kernel::mapSelectors() {
 	// species
 	// superClass
-	// -info-
+	FIND_SELECTOR2(_info_, "-info-");
 	FIND_SELECTOR(y);
 	FIND_SELECTOR(x);
 	FIND_SELECTOR(view);

Modified: scummvm/trunk/engines/sci/engine/selector.h
===================================================================
--- scummvm/trunk/engines/sci/engine/selector.h	2010-09-03 17:49:22 UTC (rev 52507)
+++ scummvm/trunk/engines/sci/engine/selector.h	2010-09-03 18:14:59 UTC (rev 52508)
@@ -40,6 +40,7 @@
 	}
 
 	// Statically defined selectors, (almost the) same in all SCI versions
+	Selector _info_;
 	Selector y;
 	Selector x;
 	Selector view, loop, cel; ///< Description of a specific image

Modified: scummvm/trunk/engines/sci/engine/static_selectors.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/static_selectors.cpp	2010-09-03 17:49:22 UTC (rev 52507)
+++ scummvm/trunk/engines/sci/engine/static_selectors.cpp	2010-09-03 18:14:59 UTC (rev 52508)
@@ -98,6 +98,7 @@
 #endif
 
 static const SelectorRemap sciSelectorRemap[] = {
+	{    SCI_VERSION_0_EARLY,     SCI_VERSION_1_LATE,     "-info-",   2 },
 	{    SCI_VERSION_0_EARLY,     SCI_VERSION_0_LATE,   "moveDone", 170 },
 	{    SCI_VERSION_0_EARLY,     SCI_VERSION_0_LATE,     "points", 316 },
 	{    SCI_VERSION_0_EARLY,     SCI_VERSION_0_LATE,      "flags", 368 },
@@ -106,6 +107,7 @@
 	{    SCI_VERSION_1_EARLY,     SCI_VERSION_1_LATE,  "topString", 101 },
 	{    SCI_VERSION_1_EARLY,     SCI_VERSION_1_LATE,      "flags", 102 },
 	// SCI1.1
+	{        SCI_VERSION_1_1,        SCI_VERSION_2_1,     "-info-",4103 },
 	{        SCI_VERSION_1_1,        SCI_VERSION_1_1,    "nodePtr",  41 },
 	{        SCI_VERSION_1_1,        SCI_VERSION_1_1, "cantBeHere",  54 },
 	{        SCI_VERSION_1_1,        SCI_VERSION_1_1,  "topString",  98 },


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list