diff options
author | Eugene Sandulenko | 2015-12-23 11:08:04 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2015-12-27 15:41:00 +0100 |
commit | a2ac4ea859da2257bba0d60f466be4037204d4d9 (patch) | |
tree | a6ac7cf943b468eb05c49a14ab85aa75e11f6971 /engines/wage | |
parent | 60ce5fa557a82f120065d18d135e282352688c51 (diff) | |
download | scummvm-rg350-a2ac4ea859da2257bba0d60f466be4037204d4d9.tar.gz scummvm-rg350-a2ac4ea859da2257bba0d60f466be4037204d4d9.tar.bz2 scummvm-rg350-a2ac4ea859da2257bba0d60f466be4037204d4d9.zip |
WAGE: Handle NULL value Operands
Diffstat (limited to 'engines/wage')
-rw-r--r-- | engines/wage/script.cpp | 8 | ||||
-rw-r--r-- | engines/wage/script.h | 34 |
2 files changed, 31 insertions, 11 deletions
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp index 355c5da0f8..eb500d7df0 100644 --- a/engines/wage/script.cpp +++ b/engines/wage/script.cpp @@ -88,7 +88,7 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i { Operand *op = readOperand(); // TODO check op type is string or number, or something good... - appendText(op->_str); + appendText(op->toString()); byte d = _data->readByte(); if (d != 0xFD) warning("Operand 0x8B (PRINT) End Byte != 0xFD"); @@ -99,7 +99,7 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i Operand *op = readOperand(); // TODO check op type is string. _handled = true; - callbacks->playSound(op->_str); + callbacks->playSound(op->toString()); byte d = _data->readByte(); if (d != 0xFD) warning("Operand 0x8B (PRINT) End Byte != 0xFD"); @@ -112,7 +112,7 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i { Operand *op = readStringOperand(); // allows empty menu // TODO check op type is string. - _callbacks->setMenu(op->_str); + _callbacks->setMenu(op->toString()); byte d = _data->readByte(); if (d != 0xFD) warning("Operand 0x8B (PRINT) End Byte != 0xFD"); @@ -196,7 +196,7 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i Script::Operand *Script::readOperand() { byte operandType = _data->readByte(); - debug(2, "readOperand: 0x%x", operandType); + debug(2, "%x: readOperand: 0x%x", _data->pos(), operandType); Context *cont = &_world->_player->_context; switch (operandType) { diff --git a/engines/wage/script.h b/engines/wage/script.h index 7ac8356b18..1c69eb093b 100644 --- a/engines/wage/script.h +++ b/engines/wage/script.h @@ -87,43 +87,63 @@ private: Designed *inputClick; } _value; OperandTypes _type; - String _str; + Common::String _str; Operand(Obj *value, OperandTypes type) { _value.obj = value; - _str = value->toString(); _type = type; } Operand(Chr *value, OperandTypes type) { _value.chr = value; - _str = value->toString(); _type = type; } Operand(Scene *value, OperandTypes type) { _value.scene = value; - _str = value->toString(); _type = type; } Operand(int value, OperandTypes type) { _value.number = value; - _str = value; _type = type; } Operand(String *value, OperandTypes type) { _value.string = value; - _str = *value; _type = type; } Operand(Designed *value, OperandTypes type) { _value.inputClick = value; - _str = value->toString(); _type = type; } + + Common::String toString() { + char buf[128]; + + if (_value.obj == NULL) + _str = ""; + + switch(_type) { + case NUMBER: + _str = snprintf(buf, 128, "%d", _value.number); + return _str; + case STRING: + case TEXT_INPUT: + return *_value.string; + case OBJ: + return _value.obj->toString(); + case CHR: + return _value.chr->toString(); + case SCENE: + return _value.scene->toString(); + case CLICK_INPUT: + return _value.inputClick->toString(); + default: + error("Unhandled operand type: _type"); + } + } }; public: |