diff --git a/src/engine/virtualmachine.cpp b/src/engine/virtualmachine.cpp index c700c728..f4b2668a 100644 --- a/src/engine/virtualmachine.cpp +++ b/src/engine/virtualmachine.cpp @@ -190,15 +190,14 @@ void VirtualMachine::moveToLastCheckpoint() * \param[in] savePos Changes the return value of savePos(). * \param[in] breakAtomic Whether to break the frame after stopping the script. * \param[in] goBack Whether to go back so that the current instruction can run again in the future. - * \note Nothing will happen if the script is set to run without screen refresh. + * \note If the script is set to run without screen refresh, the VM won't stop. + * The only parameter which won't be ignored is goBack. */ void VirtualMachine::stop(bool savePos, bool breakAtomic, bool goBack) { - if (impl->warp) - return; impl->stop = true; - impl->savePos = savePos; - impl->atomic = !breakAtomic; + impl->savePos = savePos && !impl->warp; + impl->atomic = !breakAtomic || impl->warp; impl->goBack = goBack; } diff --git a/src/engine/virtualmachine_p.cpp b/src/engine/virtualmachine_p.cpp index 9cc7d0c4..2fb13ad6 100644 --- a/src/engine/virtualmachine_p.cpp +++ b/src/engine/virtualmachine_p.cpp @@ -201,6 +201,9 @@ unsigned int *VirtualMachinePrivate::run(unsigned int *pos, bool reset) atEnd = true; return pos; } else { + if (callTree.size() == 1) + warp = false; + pos = callTree.back(); callTree.pop_back(); procedureArgTree.pop_back(); @@ -689,7 +692,11 @@ do_exec : { // This is for example used in the wait block (to call it again with the same time value). } else FREE_REGS(ret); - return pos; + + if (!warp) // TODO: This should always return if there's a "warp timer" enabled + return pos; + + DISPATCH(); // this avoids freeing registers after "stopping" a warp script } FREE_REGS(ret); DISPATCH();