Clean up debugger Restart function and move to SCUMM restart function

svn-id: r8263
This commit is contained in:
James Brown 2003-06-02 05:38:45 +00:00
parent ee886a6be2
commit 9be08a55f9
3 changed files with 38 additions and 39 deletions

View file

@ -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;

View file

@ -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;
}
}

View file

@ -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() {