[Scummvm-cvs-logs] CVS: scummvm/scumm debugger.cpp,1.58,1.59 script.cpp,1.108,1.109 scummvm.cpp,2.201,2.202

James Brown ender at users.sourceforge.net
Sun Jun 1 22:39:07 CEST 2003


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv8183/scumm

Modified Files:
	debugger.cpp script.cpp scummvm.cpp 
Log Message:
Clean up debugger Restart function and move to SCUMM restart function


Index: debugger.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/debugger.cpp,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- debugger.cpp	1 Jun 2003 14:30:25 -0000	1.58
+++ debugger.cpp	2 Jun 2003 05:38:45 -0000	1.59
@@ -343,22 +343,7 @@
 }
 
 bool ScummDebugger::Cmd_Restart(int argc, const char **argv) {
-	// Reset some stuff
-	_s->_currentRoom = 0;
-	_s->_currentScript = 0xFF;
-	_s->killAllScriptsExceptCurrent();
-	_s->setShake(0);
-	_s->_sound->stopAllSounds();
-
-	// Reinit things
-	_s->allocateArrays();			// Reallocate arrays
-	_s->readIndexFile();			// Reread index (reset objectstate etc)
-	_s->createResource(rtTemp, 6, 500); 	// Create temp buffer
-	_s->initScummVars();			// Reinit scumm variables
-	_s->_sound->setupSound();		// Reinit sound engine
-
-	// Re-run bootscript
-	_s->runScript(1, 0, 0, &_s->_bootParam);
+	_s->restart();
 
 	_detach_now = true;
 	return false;

Index: script.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script.cpp,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -d -r1.108 -r1.109
--- script.cpp	1 Jun 2003 10:28:45 -0000	1.108
+++ script.cpp	2 Jun 2003 05:38:45 -0000	1.109
@@ -789,13 +789,17 @@
 	ss = vm.slot;
 	for (i = 0; i < NUM_SCRIPT_SLOT; i++, ss++) {
 		if (ss->where == WIO_ROOM || ss->where == WIO_FLOBJECT) {
-			if (ss->cutsceneOverride != 0)
-				error("Object %d stopped with active cutscene/override in exit", ss->number);
+			if (ss->cutsceneOverride != 0) {
+				warning("Object %d stopped with active cutscene/override in exit", ss->number);
+				ss->cutsceneOverride = 0;
+			}
 			ss->status = ssDead;
 		} else if (ss->where == WIO_LOCAL) {
 			// HACK to make Indy3 Demo work
-			if (ss->cutsceneOverride != 0 && !(_gameId == GID_INDY3 && _roomResource == 3))
-				error("Script %d stopped with active cutscene/override in exit", ss->number);
+			if (ss->cutsceneOverride != 0 && !(_gameId == GID_INDY3 && _roomResource == 3)) {
+				warning("Script %d stopped with active cutscene/override in exit", ss->number);
+				ss->cutsceneOverride = 0;
+			}
 			ss->status = ssDead;
 		}
 	}

Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scummvm.cpp,v
retrieving revision 2.201
retrieving revision 2.202
diff -u -d -r2.201 -r2.202
--- scummvm.cpp	2 Jun 2003 02:25:24 -0000	2.201
+++ scummvm.cpp	2 Jun 2003 05:38:45 -0000	2.202
@@ -1751,25 +1751,35 @@
 }
 
 void Scumm::restart() {
-	// TODO: implement restart
-	// To implement this, there are two approaches (at least):
-	// 1) Manually cleanup all vars, etc. and run the bootscript again
-	// 2) Use the savegame system
-	// For 2, we could modify the savegame system to allow us to "save" to a memory
-	// block. We then do that at the start of the game, just before invoking the 
-	// bootscript (or maybe just after launching it, whatever). Then to restart
-	// we simply load the state. Easy, hu? :-)
-	//
-	// For 1), we first have to clean up / restructure the current init code. Right now
-	// we have the code which inits the state spread over at least these functions:
-	// The constructor, launch, scummInit, readIndexFile
-	// Problem is, the init code is not very logically distributed over those.
-	// We should first clean this up... Code that sets up fixed state (e.g. gdi._vm = this)
-	// can be moved to either the constructor or maybe scummInit. Code that 
-	// might be useful for restart should be moved to a seperate function.
-	// Finally, all the init code in launch should go - launch should only contain
-	// a few function calls and not much else, iMHO.
-	error("Restart not implemented");
+// TODO: Check this function - we should probably be reinitting a lot more stuff, and I suspect
+//	 this leaks memory like a sieve
+
+	int i;
+
+	// Reset some stuff
+	_currentRoom = 0;
+	_currentScript = 0xFF;
+	killAllScriptsExceptCurrent();
+	setShake(0);
+	_sound->stopAllSounds();
+
+        // Empty variables
+	for (i=0;i<255;i++)
+		_scummVars[i] = 0;
+
+	// Empty inventory
+	for (i=0;i<_numGlobalObjects;i++)
+		clearOwnerOf(i);
+
+	// Reinit things
+	allocateArrays();                   // Reallocate arrays
+	readIndexFile();                    // Reread index (reset objectstate etc)
+	createResource(rtTemp, 6, 500);     // Create temp buffer
+	initScummVars();                    // Reinit scumm variables
+	_sound->setupSound();               // Reinit sound engine
+
+	// Re-run bootscript
+	runScript(1, 0, 0, &_bootParam);
 }
 
 void Scumm::processKbd() {





More information about the Scummvm-git-logs mailing list