diff options
author | Filippos Karapetis | 2010-05-23 16:44:36 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-05-23 16:44:36 +0000 |
commit | 9be4f6250cc88a1638299b3661b9896f4ebf57ed (patch) | |
tree | 7688a087653930d4dd1c555d3804fb40068a610c /engines/sci | |
parent | b069b9fe9691f1285446a89152cb9e295d15807c (diff) | |
download | scummvm-rg350-9be4f6250cc88a1638299b3661b9896f4ebf57ed.tar.gz scummvm-rg350-9be4f6250cc88a1638299b3661b9896f4ebf57ed.tar.bz2 scummvm-rg350-9be4f6250cc88a1638299b3661b9896f4ebf57ed.zip |
Made shrink_execution_stack() a member of EngineState
svn-id: r49159
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/engine/kmisc.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/savegame.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/state.cpp | 9 | ||||
-rw-r--r-- | engines/sci/engine/state.h | 6 | ||||
-rw-r--r-- | engines/sci/engine/vm.cpp | 13 | ||||
-rw-r--r-- | engines/sci/engine/vm.h | 6 |
6 files changed, 19 insertions, 19 deletions
diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp index 74368b8c71..22295dca41 100644 --- a/engines/sci/engine/kmisc.cpp +++ b/engines/sci/engine/kmisc.cpp @@ -39,7 +39,7 @@ reg_t kRestartGame(EngineState *s, int argc, reg_t *argv) { s->restarting_flags |= SCI_GAME_IS_RESTARTING_NOW; s->restarting_flags &= ~SCI_GAME_WAS_RESTARTED_AT_LEAST_ONCE; // This appears to help - shrink_execution_stack(s, s->execution_stack_base + 1); + s->shrinkStackToBase(); script_abort_flag = 1; // Force vm to abort ASAP return NULL_REG; diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index 2532d174a1..8dc06dab01 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -1025,7 +1025,7 @@ void gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { s->successor = retval; // Set successor script_abort_flag = 2; // Abort current game with replay - shrink_execution_stack(s, s->execution_stack_base + 1); + s->shrinkStackToBase(); } bool get_savegame_metadata(Common::SeekableReadStream *stream, SavegameMetadata *meta) { diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp index bd78639c77..dfc4c39464 100644 --- a/engines/sci/engine/state.cpp +++ b/engines/sci/engine/state.cpp @@ -135,6 +135,15 @@ void EngineState::setRoomNumber(uint16 roomNumber) { script_000->_localsBlock->_locals[13] = make_reg(0, roomNumber); } +void EngineState::shrinkStackToBase() { + uint size = execution_stack_base + 1; + assert(_executionStack.size() >= size); + Common::List<ExecStack>::iterator iter = _executionStack.begin(); + for (uint i = 0; i < size; ++i) + ++iter; + _executionStack.erase(iter, _executionStack.end()); +} + static kLanguage charToLanguage(const char c) { switch (c) { case 'F': diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h index ad2b0f7058..cc7b371308 100644 --- a/engines/sci/engine/state.h +++ b/engines/sci/engine/state.h @@ -155,6 +155,12 @@ public: uint16 currentRoomNumber() const; void setRoomNumber(uint16 roomNumber); + /** + * Shrink execution stack to size. + * Contains an assert it is not already smaller. + */ + void shrinkStackToBase(); + /* System strings */ SegmentId sys_strings_segment; SystemStrings *sys_strings; diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index bf447419e8..1e252dac46 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -724,7 +724,7 @@ void run_vm(EngineState *s, bool restoring) { } if (!restoring) - s->execution_stack_base = s->_executionStack.size()-1; + s->execution_stack_base = s->_executionStack.size() - 1; #ifndef DISABLE_VALIDATIONS // Initialize maximum variable count @@ -1183,7 +1183,7 @@ void run_vm(EngineState *s, bool restoring) { StackPtr old_fp = scriptState.xs->fp; ExecStack *old_xs = &(s->_executionStack.back()); - if ((int)s->_executionStack.size()-1 == s->execution_stack_base) { // Have we reached the base? + if ((int)s->_executionStack.size() - 1 == s->execution_stack_base) { // Have we reached the base? s->execution_stack_base = old_execution_stack_base; // Restore stack base s->_executionStack.pop_back(); @@ -1756,15 +1756,6 @@ void quit_vm() { g_debugState.runningStep = 0; } -void shrink_execution_stack(EngineState *s, uint size) { - assert(s->_executionStack.size() >= size); - Common::List<ExecStack>::iterator iter; - iter = s->_executionStack.begin(); - for (uint i = 0; i < size; ++i) - ++iter; - s->_executionStack.erase(iter, s->_executionStack.end()); -} - reg_t* ObjVarRef::getPointer(SegManager *segMan) const { Object *o = segMan->getObject(obj); if (!o) return 0; diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h index 8e40fed818..97a01051d6 100644 --- a/engines/sci/engine/vm.h +++ b/engines/sci/engine/vm.h @@ -469,12 +469,6 @@ int game_exit(EngineState *s); void quit_vm(); /** - * Shrink execution stack to size. - * Contains an assert it is not already smaller. - */ -void shrink_execution_stack(EngineState *s, uint size); - -/** * Read a PMachine instruction from a memory buffer and return its length. * * @param[in] src address from which to start parsing |