From 1f03acd5bba9b29164edfe7bf8cac7e841cf6cca Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 24 Dec 2019 15:32:36 +0100 Subject: DIRECTOR: LINGO: Added preprocessing for 'when' statements with 'if' --- engines/director/lingo/lingo-preprocessor.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'engines') diff --git a/engines/director/lingo/lingo-preprocessor.cpp b/engines/director/lingo/lingo-preprocessor.cpp index 8d4f74fdea..fd9cab91ff 100644 --- a/engines/director/lingo/lingo-preprocessor.cpp +++ b/engines/director/lingo/lingo-preprocessor.cpp @@ -265,6 +265,29 @@ Common::String Lingo::codePreprocessor(const char *s, bool simple) { debugC(2, kDebugLingoParse, "second-if"); iflevel--; } + } else if (tok.equals("when")) { + debugC(2, kDebugLingoParse, "start-when"); + + if (strstr(lineStart, "if") && strstr(lineStart, "then")) { + tok = prevtok(&line.c_str()[line.size() - 1], lineStart, &prevEnd); + debugC(2, kDebugLingoParse, "when-start-if <%s>", tok.c_str()); + + if (tok.equals("if")) { + debugC(2, kDebugLingoParse, "when-end-if"); + tok = prevtok(prevEnd, lineStart); + + if (tok.equals("end")) { + // do nothing, we open and close same line + debugC(2, kDebugLingoParse, "when-end-end"); + } else { + res += " end if"; + } + } else { + res += " end if"; + } + } + } else { + debugC(2, kDebugLingoParse, "nothing"); } } -- cgit v1.2.3