[Scummvm-git-logs] scummvm master -> fc1831a462659b8d79d56b2d8409eb97ad727e97
djsrv
dservilla at gmail.com
Mon Jul 26 17:07:53 UTC 2021
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
5890475fae DIRECTOR: LINGO: Make CFrame field names more consistent
7f0ae2b827 DIRECTOR: LINGO: Improve switching between windows
fc1831a462 DIRECTOR: LINGO: Replace _hasFrozenContext
Commit: 5890475fae521981dc7c70b4cea4898271e9c0bc
https://github.com/scummvm/scummvm/commit/5890475fae521981dc7c70b4cea4898271e9c0bc
Author: djsrv (dservilla at gmail.com)
Date: 2021-07-26T12:59:06-04:00
Commit Message:
DIRECTOR: LINGO: Make CFrame field names more consistent
Changed paths:
engines/director/lingo/lingo-code.cpp
engines/director/lingo/lingo.cpp
engines/director/lingo/lingo.h
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index cac2fde665..813d9f7641 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -226,11 +226,11 @@ void Lingo::pushContext(const Symbol funcSym, bool allowRetVal, Datum defaultRet
debugC(5, kDebugLingoExec, "Pushing frame %d", callstack.size() + 1);
CFrame *fp = new CFrame;
- fp->retpc = g_lingo->_pc;
- fp->retscript = g_lingo->_currentScript;
- fp->retctx = g_lingo->_currentScriptContext;
+ fp->retPC = g_lingo->_pc;
+ fp->retScript = g_lingo->_currentScript;
+ fp->retContext = g_lingo->_currentScriptContext;
fp->retFreezeContext = g_lingo->_freezeContext;
- fp->localvars = g_lingo->_localvars;
+ fp->retLocalVars = g_lingo->_localvars;
fp->retMe = g_lingo->_currentMe;
fp->sp = funcSym;
fp->allowRetVal = allowRetVal;
@@ -325,16 +325,16 @@ void Lingo::popContext() {
delete g_lingo->_currentScriptContext;
}
- g_lingo->_currentScript = fp->retscript;
- g_lingo->_currentScriptContext = fp->retctx;
+ g_lingo->_currentScript = fp->retScript;
+ g_lingo->_currentScriptContext = fp->retContext;
g_lingo->_freezeContext = fp->retFreezeContext;
- g_lingo->_pc = fp->retpc;
+ g_lingo->_pc = fp->retPC;
g_lingo->_currentMe = fp->retMe;
// Restore local variables
if (!fp->sp.anonymous) {
g_lingo->cleanLocalVars();
- g_lingo->_localvars = fp->localvars;
+ g_lingo->_localvars = fp->retLocalVars;
}
if (debugChannelSet(2, kDebugLingoExec)) {
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index b88203b6af..835d6cec15 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -291,7 +291,7 @@ void Lingo::printCallStack(uint pc) {
CFrame *frame = callstack[i];
uint framePc = pc;
if (i < (int)callstack.size() - 1)
- framePc = callstack[i + 1]->retpc;
+ framePc = callstack[i + 1]->retPC;
if (frame->sp.type != VOIDSYM) {
debugC(2, kDebugLingoExec, "#%d %s:%d", i + 1,
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index 86b828c952..635f6bbbd0 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -195,16 +195,16 @@ typedef Common::HashMap<Common::String, TheEntity *, Common::IgnoreCase_Hash, Co
typedef Common::HashMap<Common::String, TheEntityField *, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> TheEntityFieldHash;
struct CFrame { /* proc/func call stack frame */
- Symbol sp; /* symbol table entry */
- int retpc; /* where to resume after return */
- ScriptData *retscript; /* which script to resume after return */
- ScriptContext *retctx; /* which script context to use after return */
- bool retFreezeContext; /* whether the context should be frozen after return */
- DatumHash *localvars;
- Datum retMe; /* which me obj to use after return */
- uint stackSizeBefore;
- bool allowRetVal; /* whether to allow a return value */
- Datum defaultRetVal; /* default return value */
+ Symbol sp; /* symbol table entry */
+ int retPC; /* where to resume after return */
+ ScriptData *retScript; /* which script to resume after return */
+ ScriptContext *retContext; /* which script context to use after return */
+ bool retFreezeContext; /* whether the context should be frozen after return */
+ DatumHash *retLocalVars;
+ Datum retMe; /* which me obj to use after return */
+ uint stackSizeBefore;
+ bool allowRetVal; /* whether to allow a return value */
+ Datum defaultRetVal; /* default return value */
};
struct LingoEvent {
Commit: 7f0ae2b827039826a3b9f7cc4fa0db12e8017bc2
https://github.com/scummvm/scummvm/commit/7f0ae2b827039826a3b9f7cc4fa0db12e8017bc2
Author: djsrv (dservilla at gmail.com)
Date: 2021-07-26T12:59:06-04:00
Commit Message:
DIRECTOR: LINGO: Improve switching between windows
This saves/loads more Lingo state to the window so that running Lingo in
multiple windows is safer.
Changed paths:
engines/director/director.cpp
engines/director/lingo/lingo-code.cpp
engines/director/lingo/lingo.h
engines/director/window.cpp
engines/director/window.h
diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index 8017769a21..688df233f6 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -198,7 +198,9 @@ Common::Error DirectorEngine::run() {
processEvents();
_currentWindow = _stage;
+ g_lingo->loadStateFromWindow();
loop = _currentWindow->step();
+ g_lingo->saveStateToWindow();
if (loop) {
DatumArray *windowList = g_lingo->_windowList.u.farr;
@@ -207,7 +209,9 @@ Common::Error DirectorEngine::run() {
continue;
_currentWindow = static_cast<Window *>((*windowList)[i].u.obj);
+ g_lingo->loadStateFromWindow();
_currentWindow->step();
+ g_lingo->saveStateToWindow();
}
}
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index 813d9f7641..dde5082b12 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -220,6 +220,26 @@ void LC::c_xpop() {
g_lingo->pop();
}
+void Lingo::loadStateFromWindow() {
+ Window *window = _vm->getCurrentWindow();
+ _pc = window->_retPC;
+ _currentScript = window->_retScript;
+ _currentScriptContext = window->_retContext;
+ _freezeContext = window->_retFreezeContext;
+ _localvars = window->_retLocalVars;
+ _currentMe = window->_retMe;
+}
+
+void Lingo::saveStateToWindow() {
+ Window *window = _vm->getCurrentWindow();
+ window->_retPC = _pc;
+ window->_retScript = _currentScript;
+ window->_retContext = _currentScriptContext;
+ window->_retFreezeContext = _freezeContext;
+ window->_retLocalVars = _localvars;
+ window->_retMe = _currentMe;
+}
+
void Lingo::pushContext(const Symbol funcSym, bool allowRetVal, Datum defaultRetVal) {
Common::Array<CFrame *> &callstack = _vm->getCurrentWindow()->_callstack;
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index 635f6bbbd0..6095d0148f 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -287,6 +287,8 @@ public:
public:
void execute();
+ void loadStateFromWindow();
+ void saveStateToWindow();
void pushContext(const Symbol funcSym, bool allowRetVal, Datum defaultRetVal);
void popContext();
void cleanLocalVars();
diff --git a/engines/director/window.cpp b/engines/director/window.cpp
index a2268b9e26..ffc818082e 100644
--- a/engines/director/window.cpp
+++ b/engines/director/window.cpp
@@ -62,6 +62,11 @@ Window::Window(int id, bool scrollable, bool resizable, bool editable, Graphics:
_titleVisible = true;
updateBorderType();
+ _retPC = 0;
+ _retScript = nullptr;
+ _retContext = nullptr;
+ _retFreezeContext = false;
+ _retLocalVars = nullptr;
_hasFrozenLingo = false;
}
diff --git a/engines/director/window.h b/engines/director/window.h
index 1375800376..7d8da5a219 100644
--- a/engines/director/window.h
+++ b/engines/director/window.h
@@ -172,7 +172,14 @@ public:
Common::List<MovieReference> _movieStack;
bool _newMovieStarted;
+ // saved Lingo state
Common::Array<CFrame *> _callstack;
+ uint _retPC;
+ ScriptData *_retScript;
+ ScriptContext *_retContext;
+ bool _retFreezeContext;
+ DatumHash *_retLocalVars;
+ Datum _retMe;
bool _hasFrozenLingo;
private:
Commit: fc1831a462659b8d79d56b2d8409eb97ad727e97
https://github.com/scummvm/scummvm/commit/fc1831a462659b8d79d56b2d8409eb97ad727e97
Author: djsrv (dservilla at gmail.com)
Date: 2021-07-26T12:59:06-04:00
Commit Message:
DIRECTOR: LINGO: Replace _hasFrozenContext
This fixes https://trello.com/c/bucHPI2F/429-majestic-regression
hasFrozenContext is now a function which checks the call stack for
frozen contexts. Not updating this variable manually leaves less room
for error.
Changed paths:
engines/director/lingo/lingo-code.cpp
engines/director/lingo/lingo-funcs.cpp
engines/director/lingo/lingo.h
engines/director/score.cpp
engines/director/window.cpp
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index dde5082b12..d3119ce797 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -364,6 +364,19 @@ void Lingo::popContext() {
delete fp;
}
+bool Lingo::hasFrozenContext() {
+ if (g_lingo->_freezeContext)
+ return true;
+
+ Common::Array<CFrame *> &callstack = _vm->getCurrentWindow()->_callstack;
+ for (uint i = 0; i < callstack.size(); i++) {
+ if (callstack[i]->retFreezeContext)
+ return true;
+ }
+
+ return false;
+}
+
void LC::c_constpush() {
Common::String name(g_lingo->readString());
diff --git a/engines/director/lingo/lingo-funcs.cpp b/engines/director/lingo/lingo-funcs.cpp
index cd8ae4fc7a..9a5b78781d 100644
--- a/engines/director/lingo/lingo-funcs.cpp
+++ b/engines/director/lingo/lingo-funcs.cpp
@@ -197,9 +197,8 @@ void Lingo::func_goto(Datum &frame, Datum &movie) {
// If there isn't already frozen Lingo (e.g. from a previous func_goto we haven't yet unfrozen),
// freeze this script context. We'll return to it after entering the next frame.
- if (!stage->_hasFrozenLingo) {
+ if (!g_lingo->hasFrozenContext()) {
g_lingo->_freezeContext = true;
- stage->_hasFrozenLingo = true;
}
if (movie.type != VOID) {
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index 6095d0148f..569662504e 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -291,6 +291,7 @@ public:
void saveStateToWindow();
void pushContext(const Symbol funcSym, bool allowRetVal, Datum defaultRetVal);
void popContext();
+ bool hasFrozenContext();
void cleanLocalVars();
void varAssign(const Datum &var, const Datum &value);
Datum varFetch(const Datum &var, bool silent = false);
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index 5d73339b64..fd17bd6836 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -441,7 +441,6 @@ void Score::update() {
g_lingo->_freezeContext = false;
g_lingo->execute();
}
- _window->_hasFrozenLingo = false;
}
byte tempo = _frames[_currentFrame]->_tempo;
diff --git a/engines/director/window.cpp b/engines/director/window.cpp
index ffc818082e..9f706638f9 100644
--- a/engines/director/window.cpp
+++ b/engines/director/window.cpp
@@ -67,7 +67,6 @@ Window::Window(int id, bool scrollable, bool resizable, bool editable, Graphics:
_retContext = nullptr;
_retFreezeContext = false;
_retLocalVars = nullptr;
- _hasFrozenLingo = false;
}
Window::~Window() {
More information about the Scummvm-git-logs
mailing list