From 3735f79d5b3d81665a7f91f955ec58951abddaef Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 1 Sep 2016 10:24:31 +0200 Subject: DIRECTOR: Lingo: Implemented when..then keyword logic --- engines/director/lingo/lingo-code.cpp | 4 +++- engines/director/lingo/lingo-codegen.cpp | 7 +++++-- engines/director/lingo/lingo.h | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp index 9e3350a1df..d7b91d2839 100644 --- a/engines/director/lingo/lingo-code.cpp +++ b/engines/director/lingo/lingo-code.cpp @@ -760,7 +760,9 @@ void Lingo::c_whencode() { start += g_lingo->calcStringAlignment(eventname.c_str()); - warning("STUB: c_whencode([%5d][%5d], %s)", start, end, eventname.c_str()); + g_lingo->define(eventname, start, 0, NULL, end); + + debugC(3, kDebugLingoExec, "c_whencode([%5d][%5d], %s)", start, end, eventname.c_str()); g_lingo->_pc = end; } diff --git a/engines/director/lingo/lingo-codegen.cpp b/engines/director/lingo/lingo-codegen.cpp index c145184a19..440efb5b44 100644 --- a/engines/director/lingo/lingo-codegen.cpp +++ b/engines/director/lingo/lingo-codegen.cpp @@ -191,7 +191,7 @@ void Lingo::cleanLocalVars() { delete g_lingo->_localvars; } -void Lingo::define(Common::String &name, int start, int nargs, Common::String *prefix) { +void Lingo::define(Common::String &name, int start, int nargs, Common::String *prefix, int end) { Symbol *sym; if (prefix) @@ -214,7 +214,10 @@ void Lingo::define(Common::String &name, int start, int nargs, Common::String *p delete sym->u.defn; } - sym->u.defn = new ScriptData(&(*_currentScript)[start], _currentScript->size() - start + 1); + if (end == -1) + end = _currentScript->size(); + + sym->u.defn = new ScriptData(&(*_currentScript)[start], end - start + 1); sym->nargs = nargs; } diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h index 0b3121574b..464e4eeaa1 100644 --- a/engines/director/lingo/lingo.h +++ b/engines/director/lingo/lingo.h @@ -198,7 +198,7 @@ public: void popContext(); Symbol *lookupVar(const char *name, bool create = true, bool putInGlobalList = false); void cleanLocalVars(); - void define(Common::String &s, int start, int nargs, Common::String *prefix = NULL); + void define(Common::String &s, int start, int nargs, Common::String *prefix = NULL, int end = -1); void processIf(int elselabel, int endlabel); int alignTypes(Datum &d1, Datum &d2); -- cgit v1.2.3