diff options
author | Eugene Sandulenko | 2016-07-11 00:41:14 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-08-03 23:40:36 +0200 |
commit | 4d2e4a8c7345ae996b9ed6c8c3fbc3bc5f063ac8 (patch) | |
tree | ac1c121207157cab02cd8a3c5120572d7d3db678 /engines/director | |
parent | ffdb3f9d0f8f05b1735f7b447485d2d126c05c09 (diff) | |
download | scummvm-rg350-4d2e4a8c7345ae996b9ed6c8c3fbc3bc5f063ac8.tar.gz scummvm-rg350-4d2e4a8c7345ae996b9ed6c8c3fbc3bc5f063ac8.tar.bz2 scummvm-rg350-4d2e4a8c7345ae996b9ed6c8c3fbc3bc5f063ac8.zip |
DIRECTOR: Lingo: Nicer error recovery during execution
Diffstat (limited to 'engines/director')
-rw-r--r-- | engines/director/lingo/lingo-code.cpp | 23 | ||||
-rw-r--r-- | engines/director/lingo/lingo-funcs.cpp | 2 |
2 files changed, 21 insertions, 4 deletions
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp index 24325be9f5..a8881d7888 100644 --- a/engines/director/lingo/lingo-code.cpp +++ b/engines/director/lingo/lingo-code.cpp @@ -608,14 +608,25 @@ void Lingo::c_call() { Common::String name((char *)&(*g_lingo->_currentScript)[g_lingo->_pc]); g_lingo->_pc += g_lingo->calcStringAlignment(name.c_str()); + int nargs = READ_UINT32(&(*g_lingo->_currentScript)[g_lingo->_pc++]); + if (!g_lingo->_handlers.contains(name)) { - error("Call to undefined handler '%s'", name.c_str()); + warning("Call to undefined handler '%s'. Dropping %d stack items", name.c_str(), nargs); + + for (int i = 0; i < nargs; i++) + g_lingo->pop(); + + // Push dummy value + Datum d; + d.u.i = 0; + d.type = VOID; + g_lingo->push(d); + + return; } Symbol *sym = g_lingo->_handlers[name]; - int nargs = READ_UINT32(&(*g_lingo->_currentScript)[g_lingo->_pc++]); - for (int i = nargs; i < sym->nargs; i++) { Datum d; @@ -643,6 +654,12 @@ void Lingo::c_call() { } void Lingo::c_procret() { + if (!g_lingo->_callstack.size()) { + warning("Call stack underflow"); + g_lingo->_returning = true; + return; + } + CFrame *fp = g_lingo->_callstack.back(); g_lingo->_currentScript = fp->retscript; diff --git a/engines/director/lingo/lingo-funcs.cpp b/engines/director/lingo/lingo-funcs.cpp index fbb65ea1a0..50120cf036 100644 --- a/engines/director/lingo/lingo-funcs.cpp +++ b/engines/director/lingo/lingo-funcs.cpp @@ -190,7 +190,7 @@ void Lingo::func_mciwait(Common::String &s) { } void Lingo::func_goto(Common::String &frame, Common::String &movie) { - if (!_vm->_movies->contains(movie)) + if (!_vm->_movies || !_vm->_movies->contains(movie)) error("Movie %s does not exist", movie.c_str()); _vm->_currentScore = _vm->_movies->getVal(movie); |