diff options
author | James Brown | 2003-06-02 05:38:45 +0000 |
---|---|---|
committer | James Brown | 2003-06-02 05:38:45 +0000 |
commit | 9be08a55f9e54f8cf7e49f2a202a8c373a113d3a (patch) | |
tree | 96a26aed4e10c4fb54094473470d406a80004f80 | |
parent | ee886a6be29f1f9a6fca13c11b8b53b92b69c882 (diff) | |
download | scummvm-rg350-9be08a55f9e54f8cf7e49f2a202a8c373a113d3a.tar.gz scummvm-rg350-9be08a55f9e54f8cf7e49f2a202a8c373a113d3a.tar.bz2 scummvm-rg350-9be08a55f9e54f8cf7e49f2a202a8c373a113d3a.zip |
Clean up debugger Restart function and move to SCUMM restart function
svn-id: r8263
-rw-r--r-- | scumm/debugger.cpp | 17 | ||||
-rw-r--r-- | scumm/script.cpp | 12 | ||||
-rw-r--r-- | scumm/scummvm.cpp | 48 |
3 files changed, 38 insertions, 39 deletions
diff --git a/scumm/debugger.cpp b/scumm/debugger.cpp index d55a4e764e..79c91c92ba 100644 --- a/scumm/debugger.cpp +++ b/scumm/debugger.cpp @@ -343,22 +343,7 @@ bool ScummDebugger::Cmd_Exit(int argc, const char **argv) { } 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; diff --git a/scumm/script.cpp b/scumm/script.cpp index 17b2a1b30c..0661494f0e 100644 --- a/scumm/script.cpp +++ b/scumm/script.cpp @@ -789,13 +789,17 @@ void Scumm::killScriptsAndResources() { 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; } } diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp index 8e783ae8d5..07bc403a11 100644 --- a/scumm/scummvm.cpp +++ b/scumm/scummvm.cpp @@ -1751,25 +1751,35 @@ void Scumm::shutDown() { } 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() { |