mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 13:50:13 +00:00
SCI: Refactor away SciEngine::exitGame
This commit is contained in:
parent
8dac2204cd
commit
62a5b6dc95
@ -677,11 +677,32 @@ void SciEngine::runGame() {
|
||||
do {
|
||||
_gamestate->_executionStackPosChanged = false;
|
||||
run_vm(_gamestate);
|
||||
exitGame();
|
||||
|
||||
// Stop audio and sound components, unless loading a game.
|
||||
// EngineState::saveLoadWithSerializer has already handled that.
|
||||
if (_gamestate->abortScriptProcessing != kAbortLoadGame) {
|
||||
if (_audio) { // SCI16
|
||||
_audio->stopAllAudio();
|
||||
}
|
||||
_sync->stop();
|
||||
_soundCmd->clearPlayList();
|
||||
}
|
||||
|
||||
// Clear execution stack
|
||||
_gamestate->_executionStack.clear();
|
||||
_gamestate->xs = nullptr;
|
||||
|
||||
// Close all opened file handles
|
||||
_gamestate->_fileHandles.clear();
|
||||
_gamestate->_fileHandles.resize(5);
|
||||
|
||||
_guestAdditions->sciEngineRunGameHook();
|
||||
|
||||
if (_gamestate->abortScriptProcessing == kAbortRestartGame) {
|
||||
// SCI16 game has been restarted with kRestartGame16.
|
||||
// Reset engine state and prepare the VM to call the play method
|
||||
// on the next iteration, but set the gameIsRestarting flag so
|
||||
// that scripts can detect the restart with kGameIsRestarting.
|
||||
_gamestate->_segMan->resetSegMan();
|
||||
initGame();
|
||||
initStackBaseWithSelector(SELECTOR(play));
|
||||
@ -694,8 +715,10 @@ void SciEngine::runGame() {
|
||||
_gamestate->abortScriptProcessing = kAbortNone;
|
||||
_guestAdditions->reset();
|
||||
} else if (_gamestate->abortScriptProcessing == kAbortLoadGame) {
|
||||
// Game has been restored from within the game or the launcher.
|
||||
// Prepare the VM to call the replay method of the game object
|
||||
// on the next iteration.
|
||||
_gamestate->abortScriptProcessing = kAbortNone;
|
||||
_gamestate->_executionStack.clear();
|
||||
initStackBaseWithSelector(SELECTOR(replay));
|
||||
_guestAdditions->patchGameSaveRestore();
|
||||
setLauncherLanguage();
|
||||
@ -804,25 +827,6 @@ void SciEngine::errorString(const char *buf_input, char *buf_output, int buf_out
|
||||
_inErrorString = false;
|
||||
}
|
||||
|
||||
void SciEngine::exitGame() {
|
||||
if (_gamestate->abortScriptProcessing != kAbortLoadGame) {
|
||||
_gamestate->_executionStack.clear();
|
||||
if (_audio) {
|
||||
_audio->stopAllAudio();
|
||||
}
|
||||
_sync->stop();
|
||||
_soundCmd->clearPlayList();
|
||||
}
|
||||
|
||||
// TODO Free parser segment here
|
||||
|
||||
// TODO Free scripts here
|
||||
|
||||
// Close all opened file handles
|
||||
_gamestate->_fileHandles.clear();
|
||||
_gamestate->_fileHandles.resize(5);
|
||||
}
|
||||
|
||||
// Invoked by debugger when a severe error occurs
|
||||
void SciEngine::severeError() {
|
||||
if (_gamestate) {
|
||||
|
@ -365,17 +365,6 @@ private:
|
||||
* or restoring a game re-initializes certain states and continues the loop.
|
||||
*/
|
||||
void runGame();
|
||||
|
||||
/**
|
||||
* "Uninitializes an initialized SCI game" was the original description.
|
||||
* This is only called by runGame immediately after calling run_vm.
|
||||
* It uninitalizes some engine state depending on the abort flag, but it also
|
||||
* has old TODO comments and doesn't uninitialize the heap. runGame does
|
||||
* just as much uninitialization after calling this, so maybe exitGame's
|
||||
* code should just be moved into runGame instead of splitting up the
|
||||
* re-initialization steps.
|
||||
*/
|
||||
void exitGame();
|
||||
|
||||
/**
|
||||
* Initializes the stack to call a method in the game object once the VM starts.
|
||||
|
Loading…
Reference in New Issue
Block a user