diff options
author | Eugene Sandulenko | 2016-06-30 10:24:01 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-08-03 23:40:36 +0200 |
commit | 0b6d950729296c177ad502328fd5b5e3b0bb04c9 (patch) | |
tree | 2908aea7a91d22d8ffb2da8135ddc4ff4de4f300 /engines/director/lingo/lingo-code.cpp | |
parent | a279faf251f1703355b5d7dbaf2b935a25e21047 (diff) | |
download | scummvm-rg350-0b6d950729296c177ad502328fd5b5e3b0bb04c9.tar.gz scummvm-rg350-0b6d950729296c177ad502328fd5b5e3b0bb04c9.tar.bz2 scummvm-rg350-0b6d950729296c177ad502328fd5b5e3b0bb04c9.zip |
DIRECTOR: Lingo: Store and restore local variables in scope.
Diffstat (limited to 'engines/director/lingo/lingo-code.cpp')
-rw-r--r-- | engines/director/lingo/lingo-code.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp index 31aeac6716..9bc6b48b90 100644 --- a/engines/director/lingo/lingo-code.cpp +++ b/engines/director/lingo/lingo-code.cpp @@ -404,6 +404,13 @@ void Lingo::c_call() { fp->sp = sym; fp->retpc = g_lingo->_pc; fp->retscript = g_lingo->_currentScript; + fp->localvars = g_lingo->_localvars; + + // Clean up current scope local variables + for (SymbolHash::const_iterator h = g_lingo->_localvars->begin(); h != g_lingo->_localvars->end(); ++h) + g_lingo->_vars.erase(h->_key); + + g_lingo->_localvars = new SymbolHash; g_lingo->_callstack.push_back(fp); @@ -419,6 +426,18 @@ void Lingo::c_procret() { g_lingo->_currentScript = fp->retscript; g_lingo->_pc = fp->retpc; + // Clean up current scope local variables and clean up memory + for (SymbolHash::const_iterator h = g_lingo->_localvars->begin(); h != g_lingo->_localvars->end(); ++h) { + g_lingo->_vars.erase(h->_key); + delete h->_value; + } + delete g_lingo->_localvars; + + // Restore local variables + g_lingo->_localvars = fp->localvars; + for (SymbolHash::const_iterator h = g_lingo->_localvars->begin(); h != g_lingo->_localvars->end(); ++h) + g_lingo->_vars[h->_key] = h->_value; + delete fp; g_lingo->_returning = true; |