diff options
Diffstat (limited to 'engines/director')
-rw-r--r-- | engines/director/lingo/lingo-code.cpp | 2 | ||||
-rw-r--r-- | engines/director/lingo/lingo-codegen.cpp | 8 | ||||
-rw-r--r-- | engines/director/lingo/lingo.h | 2 |
3 files changed, 9 insertions, 3 deletions
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp index 05ad0ccfc3..b2607edd55 100644 --- a/engines/director/lingo/lingo-code.cpp +++ b/engines/director/lingo/lingo-code.cpp @@ -1002,7 +1002,7 @@ void Lingo::c_whencode() { int entity = g_lingo->_currentEntityId; g_lingo->_currentEntityId = 0; - Symbol *sym = g_lingo->define(eventname, start, 0, NULL, end); + Symbol *sym = g_lingo->define(eventname, start, 0, NULL, end, false); // Redefine, but not remove code g_lingo->_currentEntityId = entity; diff --git a/engines/director/lingo/lingo-codegen.cpp b/engines/director/lingo/lingo-codegen.cpp index 2f31f5c1d9..2ba3c0940c 100644 --- a/engines/director/lingo/lingo-codegen.cpp +++ b/engines/director/lingo/lingo-codegen.cpp @@ -212,7 +212,7 @@ void Lingo::cleanLocalVars() { g_lingo->_localvars = 0; } -Symbol *Lingo::define(Common::String &name, int start, int nargs, Common::String *prefix, int end) { +Symbol *Lingo::define(Common::String &name, int start, int nargs, Common::String *prefix, int end, bool removeCode) { if (prefix) name = *prefix + "-" + name; @@ -244,6 +244,12 @@ Symbol *Lingo::define(Common::String &name, int start, int nargs, Common::String sym->nargs = nargs; sym->maxArgs = nargs; + // Now remove all defined code from the _currentScript + if (removeCode) + for (int i = end - 1; i >= start; i--) { + _currentScript->remove_at(i); + } + return sym; } diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h index 13dbc0a785..872ac214a8 100644 --- a/engines/director/lingo/lingo.h +++ b/engines/director/lingo/lingo.h @@ -214,7 +214,7 @@ public: void popContext(); Symbol *lookupVar(const char *name, bool create = true, bool putInGlobalList = false); void cleanLocalVars(); - Symbol *define(Common::String &s, int start, int nargs, Common::String *prefix = NULL, int end = -1); + Symbol *define(Common::String &s, int start, int nargs, Common::String *prefix = NULL, int end = -1, bool removeCode = true); void processIf(int elselabel, int endlabel); int alignTypes(Datum &d1, Datum &d2); |