diff options
author | Eugene Sandulenko | 2016-06-20 19:40:56 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-08-03 23:40:36 +0200 |
commit | 34acb99ec53684a37a035244b602c62868027497 (patch) | |
tree | 776cfe0f0ff9be2fb301d21ce4291e5e609a406d | |
parent | db2380077fee7b6bccba4262fa25f55e50a2981a (diff) | |
download | scummvm-rg350-34acb99ec53684a37a035244b602c62868027497.tar.gz scummvm-rg350-34acb99ec53684a37a035244b602c62868027497.tar.bz2 scummvm-rg350-34acb99ec53684a37a035244b602c62868027497.zip |
DIRECTOR: Lingo: Fix 'if' statement
-rw-r--r-- | engines/director/director.cpp | 7 | ||||
-rw-r--r-- | engines/director/lingo/lingo-funcs.cpp | 18 | ||||
-rw-r--r-- | engines/director/lingo/lingo-gr.cpp | 2 | ||||
-rw-r--r-- | engines/director/lingo/lingo-gr.y | 2 |
4 files changed, 21 insertions, 8 deletions
diff --git a/engines/director/director.cpp b/engines/director/director.cpp index 1ba7e9609a..8733bc9e71 100644 --- a/engines/director/director.cpp +++ b/engines/director/director.cpp @@ -84,7 +84,12 @@ go to \"Chair\"\n\ set x = 2 + 3 * (4 / 2)\n\ put x\n", kMovieScript, 2); - _lingo->executeScript(kMovieScript, 2); +_lingo->addCode("set x = 5\n\ +if 4 > 3 then x end if\n", kMovieScript, 3); + + _lingo->executeScript(kMovieScript, 3); + + return Common::kNoError; //FIXME _mainArchive = new RIFFArchive(); diff --git a/engines/director/lingo/lingo-funcs.cpp b/engines/director/lingo/lingo-funcs.cpp index 3e3d8858b0..f9f2e5cdef 100644 --- a/engines/director/lingo/lingo-funcs.cpp +++ b/engines/director/lingo/lingo-funcs.cpp @@ -394,17 +394,25 @@ void Lingo::func_ifcode() { Datum d; int savepc = g_lingo->_pc; /* then part */ + int then = READ_LE_UINT32(&(*g_lingo->_currentScript)[savepc]); + int elsep = READ_LE_UINT32(&(*g_lingo->_currentScript)[savepc + 1]); + int end = READ_LE_UINT32(&(*g_lingo->_currentScript)[savepc + 2]); + + warning("cond: %d end: %d then: %d elesp: %d", savepc + 3, end, then, elsep); + g_lingo->execute(savepc + 3); /* condition */ d = g_lingo->pop(); + warning("res: %d", d.val); - if (d.val) - g_lingo->execute(savepc); - else if ((*g_lingo->_currentScript)[savepc + 1]) /* else part? */ - g_lingo->execute(savepc + 1); + if (d.val) { + g_lingo->execute(then); + } else if (elsep) { /* else part? */ + g_lingo->execute(elsep); + } //if (!returning) - g_lingo->_pc = savepc + 2; /* next stmt */ + g_lingo->_pc = end; /* next stmt */ } //************************ diff --git a/engines/director/lingo/lingo-gr.cpp b/engines/director/lingo/lingo-gr.cpp index 0e69b677c2..b24c43e691 100644 --- a/engines/director/lingo/lingo-gr.cpp +++ b/engines/director/lingo/lingo-gr.cpp @@ -141,7 +141,7 @@ extern int yylex(); extern int yyparse(); -void yyerror(char *s) { warning("%s", s); } +void yyerror(char *s) { error("%s", s); } using namespace Director; diff --git a/engines/director/lingo/lingo-gr.y b/engines/director/lingo/lingo-gr.y index 1bf3c9eec8..d1e5d39dc3 100644 --- a/engines/director/lingo/lingo-gr.y +++ b/engines/director/lingo/lingo-gr.y @@ -56,7 +56,7 @@ extern int yylex(); extern int yyparse(); -void yyerror(char *s) { warning("%s", s); } +void yyerror(char *s) { error("%s", s); } using namespace Director; |