DIRECTOR: Check output of thawLingoPlayState

This commit is contained in:
Scott Percival 2024-06-18 18:23:34 +08:00
parent fb77e59dd5
commit eb86d2794c
No known key found for this signature in database
3 changed files with 17 additions and 15 deletions

View File

@ -135,17 +135,18 @@ bool Score::processFrozenScripts(bool recursion, int count) {
// Unfreeze the play script if the special flag is set
if (g_lingo->_playDone) {
g_lingo->_playDone = false;
_window->thawLingoPlayState();
Symbol currentScript = _window->getLingoState()->callstack.front()->sp;
g_lingo->switchStateFromWindow();
bool completed = g_lingo->execute();
if (!completed) {
debugC(3, kDebugLingoExec, "Score::processFrozenScripts(): State froze again mid-thaw, interrupting");
return false;
} else if (currentScript == g_lingo->_currentInputEvent) {
// script that just completed was the current input event, clear the flag
debugC(3, kDebugEvents, "Score::processFrozenScripts(): Input event completed");
g_lingo->_currentInputEvent = Symbol();
if (_window->thawLingoPlayState()) {
Symbol currentScript = _window->getLingoState()->callstack.front()->sp;
g_lingo->switchStateFromWindow();
bool completed = g_lingo->execute();
if (!completed) {
debugC(3, kDebugLingoExec, "Score::processFrozenScripts(): State froze again mid-thaw, interrupting");
return false;
} else if (currentScript == g_lingo->_currentInputEvent) {
// script that just completed was the current input event, clear the flag
debugC(3, kDebugEvents, "Score::processFrozenScripts(): Input event completed");
g_lingo->_currentInputEvent = Symbol();
}
}
}

View File

@ -649,19 +649,20 @@ void Window::freezeLingoPlayState() {
debugC(kDebugLingoExec, 3, "Freezing Lingo play state");
}
void Window::thawLingoPlayState() {
bool Window::thawLingoPlayState() {
if (!_lingoPlayState) {
warning("Tried to thaw when there's no frozen play state, ignoring");
return;
return false;
}
if (!_lingoState->callstack.empty()) {
warning("Can't thaw a Lingo state in mid-execution, ignoring");
return;
return false;
}
delete _lingoState;
debugC(kDebugLingoExec, 3, "Thawing Lingo play state");
_lingoState = _lingoPlayState;
_lingoPlayState = nullptr;
return true;
}

View File

@ -164,7 +164,7 @@ public:
void freezeLingoState();
void thawLingoState();
void freezeLingoPlayState();
void thawLingoPlayState();
bool thawLingoPlayState();
LingoState *getLastFrozenLingoState() { return _frozenLingoStates.empty() ? nullptr : _frozenLingoStates[_frozenLingoStates.size() - 1]; }
// events.cpp