diff options
author | Eugene Sandulenko | 2016-08-22 19:16:23 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-08-22 19:16:43 +0200 |
commit | ec23290df109c72b3bd76a1cedc7ddb9a9da76c0 (patch) | |
tree | 96cd0543e4157b6b4961a439d197cff8ecbb621e | |
parent | 9517c39397601422b9aeda61c6a0a5a8e098f31f (diff) | |
download | scummvm-rg350-ec23290df109c72b3bd76a1cedc7ddb9a9da76c0.tar.gz scummvm-rg350-ec23290df109c72b3bd76a1cedc7ddb9a9da76c0.tar.bz2 scummvm-rg350-ec23290df109c72b3bd76a1cedc7ddb9a9da76c0.zip |
DIRECTOR: Lingo: Fix factory method execution
-rw-r--r-- | engines/director/lingo/lingo-builtins.cpp | 12 | ||||
-rw-r--r-- | engines/director/lingo/lingo.h | 1 |
2 files changed, 12 insertions, 1 deletions
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp index 6738d4b707..b7d4b4de3f 100644 --- a/engines/director/lingo/lingo-builtins.cpp +++ b/engines/director/lingo/lingo-builtins.cpp @@ -183,6 +183,14 @@ void Lingo::dropStack(int nargs) { pop(); } +void Lingo::drop(int num) { + if (num > _stack.size() - 1) { + warning("Incorrect number of elements to drop from stack: %d > %d", num, _stack.size() - 1); + return; + } + _stack.remove_at(_stack.size() - 1 - num); +} + /////////////////// // Math @@ -794,9 +802,11 @@ void Lingo::factoryCall(Common::String &name, int nargs) { Datum method = _stack[_stack.size() - nargs + 0]; + drop(nargs - 1); + s = name + "-" + *method.u.s; - debugC(3, kDebugLingoExec, "Stack size before call: %d", _stack.size()); + debugC(3, kDebugLingoExec, "Stack size before call: %d, nargs: %d", _stack.size(), nargs); call(s, nargs); debugC(3, kDebugLingoExec, "Stack size after call: %d", _stack.size()); diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h index b197abd9d7..a4eea7aa60 100644 --- a/engines/director/lingo/lingo.h +++ b/engines/director/lingo/lingo.h @@ -295,6 +295,7 @@ public: void printStubWithArglist(const char *funcname, int nargs); void convertVOIDtoString(int arg, int nargs); void dropStack(int nargs); + void drop(int num); static void b_abs(int nargs); static void b_atan(int nargs); |