Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/engine/virtualmachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
9 changes: 8 additions & 1 deletion src/engine/virtualmachine_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down