From b6b1402368b8f33c825af095bec210829ad33cd3 Mon Sep 17 00:00:00 2001 From: Denis Kasak Date: Tue, 7 Jul 2009 20:57:14 +0000 Subject: * Changed Game::_variables to public since the GPL interpreter needs to use it and made it int instead of uint16 * Implemented variable accessing by the math evaluator * Fixed bug from previous commit (should have used && when checking for ending instructions, not ||) svn-id: r42242 --- engines/draci/game.cpp | 2 +- engines/draci/game.h | 3 ++- engines/draci/script.cpp | 9 ++++++--- 3 files changed, 9 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp index cbdeff22ef..072d205436 100644 --- a/engines/draci/game.cpp +++ b/engines/draci/game.cpp @@ -96,7 +96,7 @@ Game::Game(DraciEngine *vm) : _vm(vm) { file = initArchive.getFile(2); unsigned int numVariables = file->_length / sizeof (int16); - _variables = new int16[numVariables]; + _variables = new int[numVariables]; Common::MemoryReadStream variableData(file->_data, file->_length); for (i = 0; i < numVariables; ++i) { diff --git a/engines/draci/game.h b/engines/draci/game.h index e47f14bd98..1c572f95e9 100644 --- a/engines/draci/game.h +++ b/engines/draci/game.h @@ -131,13 +131,14 @@ public: GameObject *getObject(uint objNum); + int *_variables; + private: DraciEngine *_vm; GameInfo *_info; Person *_persons; uint16 *_dialogOffsets; - int16 *_variables; byte *_itemStatus; GameObject *_objects; Room _currentRoom; diff --git a/engines/draci/script.cpp b/engines/draci/script.cpp index 5ffed256ea..f45f45cb76 100644 --- a/engines/draci/script.cpp +++ b/engines/draci/script.cpp @@ -297,8 +297,11 @@ int Script::handleMathExpression(Common::MemoryReadStream &reader) { case kMathVariable: value = reader.readUint16LE(); - stk.push(value); - debugC(3, kDraciBytecodeDebugLevel, "\t\tvariable: %d", value); + + stk.push(_vm->_game->_variables[value-1]); + + debugC(3, kDraciBytecodeDebugLevel, "\t\tvariable: %d (%d)", value, + _vm->_game->_variables[value-1]); break; case kMathFunctionCall: @@ -458,7 +461,7 @@ int Script::run(GPL2Program program, uint16 offset) { (this->*(cmd->_handler))(params); } - } while (cmd->_name != "gplend" || cmd->_name != "exit"); + } while (cmd->_name != "gplend" && cmd->_name != "exit"); return 0; } -- cgit v1.2.3