Skip to content

Commit 4b4b47d

Browse files
committed
fix #146: Allow stopping "warp" scripts
1 parent 26edb40 commit 4b4b47d

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/engine/virtualmachine.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,14 @@ void VirtualMachine::moveToLastCheckpoint()
190190
* \param[in] savePos Changes the return value of savePos().
191191
* \param[in] breakAtomic Whether to break the frame after stopping the script.
192192
* \param[in] goBack Whether to go back so that the current instruction can run again in the future.
193-
* \note Nothing will happen if the script is set to run without screen refresh.
193+
* \note If the script is set to run without screen refresh, the VM won't stop.
194+
* The only parameter which won't be ignored is goBack.
194195
*/
195196
void VirtualMachine::stop(bool savePos, bool breakAtomic, bool goBack)
196197
{
197-
if (impl->warp)
198-
return;
199198
impl->stop = true;
200-
impl->savePos = savePos;
201-
impl->atomic = !breakAtomic;
199+
impl->savePos = savePos && !impl->warp;
200+
impl->atomic = !breakAtomic || impl->warp;
202201
impl->goBack = goBack;
203202
}
204203

src/engine/virtualmachine_p.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,11 @@ do_exec : {
689689
// This is for example used in the wait block (to call it again with the same time value).
690690
} else
691691
FREE_REGS(ret);
692-
return pos;
692+
693+
if (!warp) // TODO: This should always return if there's a "warp timer" enabled
694+
return pos;
695+
696+
DISPATCH(); // this avoids freeing registers after "stopping" a warp script
693697
}
694698
FREE_REGS(ret);
695699
DISPATCH();

0 commit comments

Comments
 (0)