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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Mon Sep 13 15:17:56 CEST 2010


Revision: 52702
          http://scummvm.svn.sourceforge.net/scummvm/?rev=52702&view=rev
Author:   thebluegr
Date:     2010-09-13 13:17:55 +0000 (Mon, 13 Sep 2010)

Log Message:
-----------
SCI: Proper fix for bug #3038837 - "HOYLE3: EGA/VGA Crashes" and some cleanup

System scripts (i.e. 0 and 900-999) are now protected and never destroyed during a
game

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/script.cpp
    scummvm/trunk/engines/sci/engine/script.h
    scummvm/trunk/engines/sci/engine/seg_manager.cpp

Modified: scummvm/trunk/engines/sci/engine/script.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/script.cpp	2010-09-13 12:53:27 UTC (rev 52701)
+++ scummvm/trunk/engines/sci/engine/script.cpp	2010-09-13 13:17:55 UTC (rev 52702)
@@ -310,25 +310,6 @@
 void Script::decrementLockers() {
 	if (_lockers > 0)
 		_lockers--;
-
-	// WORKAROUND for bug #3038837: HOYLE3: EGA/VGA Crashes
-	// This is caused by script 0 lockers reaching zero. Since
-	// this should never happen, I'm confident in making this a
-	// non-specific fix. We can't just reset lockers to 1, because
-	// the objects associated with the script are already marked
-	// to be deleted at this point, thus we need to reload the
-	// script itself. If we don't, the game will surely error
-	// out later on, because of objects associated with this
-	// script which are incorrectly marked to be deleted. For
-	// example, in Hoyle 3, if you exit Checkers and reenter
-	// checkers, the game will crash when selecting a player.
-	//
-	// TODO: Figure out why this happens, and fix it properly!
-	if (_nr == 0 && _lockers == 0) {
-		init(0, g_sci->getResMan());
-		load(g_sci->getResMan());
-	}
-
 }
 
 int Script::getLockers() const {
@@ -577,6 +558,13 @@
 	relocate(make_reg(segmentId, READ_SCI11ENDIAN_UINT16(_heapStart)));
 }
 
+void Script::initialiseObjects(SegManager *segMan, SegmentId segmentId) {
+	if (getSciVersion() >= SCI_VERSION_1_1)
+		initialiseObjectsSci11(segMan, segmentId);
+	else
+		initialiseObjectsSci0(segMan, segmentId);
+}
+
 reg_t Script::findCanonicAddress(SegManager *segMan, reg_t addr) const {
 	addr.offset = 0;
 	return addr;

Modified: scummvm/trunk/engines/sci/engine/script.h
===================================================================
--- scummvm/trunk/engines/sci/engine/script.h	2010-09-13 12:53:27 UTC (rev 52701)
+++ scummvm/trunk/engines/sci/engine/script.h	2010-09-13 13:17:55 UTC (rev 52702)
@@ -159,15 +159,8 @@
 	 * @param segMan	A reference to the segment manager
 	 * @param segmentId	The script's segment id
 	 */
-	void initialiseObjectsSci0(SegManager *segMan, SegmentId segmentId);
+	void initialiseObjects(SegManager *segMan, SegmentId segmentId);
 
-	/**
-	 * Initializes the script's objects (SCI1.1+)
-	 * @param segMan	A reference to the segment manager
-	 * @param segmentId	The script's segment id
-	 */
-	void initialiseObjectsSci11(SegManager *segMan, SegmentId segmentId);
-
 	// script lock operations
 
 	/** Increments the number of lockers of this script by one. */
@@ -260,6 +253,20 @@
 	void relocate(reg_t block);
 
 	bool relocateLocal(SegmentId segment, int location);
+
+	/**
+	 * Initializes the script's objects (SCI0)
+	 * @param segMan	A reference to the segment manager
+	 * @param segmentId	The script's segment id
+	 */
+	void initialiseObjectsSci0(SegManager *segMan, SegmentId segmentId);
+
+	/**
+	 * Initializes the script's objects (SCI1.1+)
+	 * @param segMan	A reference to the segment manager
+	 * @param segmentId	The script's segment id
+	 */
+	void initialiseObjectsSci11(SegManager *segMan, SegmentId segmentId);
 };
 
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/engine/seg_manager.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/seg_manager.cpp	2010-09-13 12:53:27 UTC (rev 52701)
+++ scummvm/trunk/engines/sci/engine/seg_manager.cpp	2010-09-13 13:17:55 UTC (rev 52702)
@@ -1004,13 +1004,8 @@
 	scr->load(_resMan);
 	scr->initialiseLocals(this);
 	scr->initialiseClasses(this);
+	scr->initialiseObjects(this, segmentId);
 
-	if (getSciVersion() >= SCI_VERSION_1_1) {
-		scr->initialiseObjectsSci11(this, segmentId);
-	} else {
-		scr->initialiseObjectsSci0(this, segmentId);
-	}
-
 	return segmentId;
 }
 
@@ -1074,8 +1069,12 @@
 				if (superclass_script == script_nr) {
 					if (scr->getLockers())
 						scr->decrementLockers();  // Decrease lockers if this is us ourselves
-				} else
-					uninstantiateScript(superclass_script);
+				} else {
+					// Uninstantiate superclass, but never uninstantiate
+					// system scripts, i.e. script 0 and scripts 900-999 - bug #3038837
+					if (superclass_script != 0 && superclass_script < 900)
+						uninstantiateScript(superclass_script);
+				}
 				// Recurse to assure that the superclass lockers number gets decreased
 			}
 


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