diff options
author | Denis Kasak | 2009-06-12 11:32:44 +0000 |
---|---|---|
committer | Denis Kasak | 2009-06-12 11:32:44 +0000 |
commit | 02cd93421dcedfdb2d3fd0005707e3d351368f1d (patch) | |
tree | 84a61b7889bd9de658cd7d010ff2be8fc6eb178e /engines/draci | |
parent | fc22ab5748420f49f1c761fbc7a248ef3adce65f (diff) | |
download | scummvm-rg350-02cd93421dcedfdb2d3fd0005707e3d351368f1d.tar.gz scummvm-rg350-02cd93421dcedfdb2d3fd0005707e3d351368f1d.tar.bz2 scummvm-rg350-02cd93421dcedfdb2d3fd0005707e3d351368f1d.zip |
Fixed evaluation of GPL mathematical expressions. The evaluator now checks that, at the end of the evaluation, the stack only contains one value (i.e. the result of the expression).
svn-id: r41477
Diffstat (limited to 'engines/draci')
-rw-r--r-- | engines/draci/gpldisasm.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/engines/draci/gpldisasm.cpp b/engines/draci/gpldisasm.cpp index 17ed5c7494..ee7b128529 100644 --- a/engines/draci/gpldisasm.cpp +++ b/engines/draci/gpldisasm.cpp @@ -160,6 +160,10 @@ void handleMathExpression(Common::MemoryReadStream &reader) { uint16 value; while (1) { if (obj == kMathEnd) { + // Check whether the expression was evaluated correctly + // The stack should contain only one value after the evaluation + // i.e. the result of the expression + assert(stk.size() == 1 && "Mathematical expression error"); break; } @@ -177,6 +181,10 @@ void handleMathExpression(Common::MemoryReadStream &reader) { value = reader.readUint16LE(); stk.pop(); stk.pop(); + + // FIXME: Pushing dummy value for now, but should push return value + stk.push(0); + debugC(3, kDraciBytecodeDebugLevel, "\t\t-operator %s", operators[value-1].c_str()); break; @@ -189,6 +197,8 @@ void handleMathExpression(Common::MemoryReadStream &reader) { case kMathFunctionCall: value = reader.readUint16LE(); + + stk.pop(); // FIXME: Pushing dummy value for now, but should push return value stk.push(0); |