diff options
Diffstat (limited to 'engines/wage/script.cpp')
-rw-r--r-- | engines/wage/script.cpp | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp index 42fde9f503..782d9ee3f7 100644 --- a/engines/wage/script.cpp +++ b/engines/wage/script.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -574,6 +574,23 @@ enum { kMoveChrScene }; +static const char *typeNames[] = { + "OBJ", + "CHR", + "SCENE", + "NUMBER", + "STRING", + "CLICK_INPUT", + "TEXT_INPUT" +}; + +static const char *operandTypeToStr(int type) { + if (type < 0 || type > 6) + return "UNKNOWN"; + + return typeNames[type]; +} + struct Comparator { char op; OperandType o1; @@ -711,6 +728,9 @@ bool Script::compare(Operand *o1, Operand *o2, int comparator) { } bool Script::evaluatePair(Operand *lhs, const char *op, Operand *rhs) { + debug(7, "HANDLING CASE: [lhs=%s/%s, op=%s rhs=%s/%s]", + operandTypeToStr(lhs->_type), lhs->toString().c_str(), op, operandTypeToStr(rhs->_type), rhs->toString().c_str()); + for (int cmp = 0; comparators[cmp].op != 0; cmp++) { if (comparators[cmp].op != op[0]) continue; @@ -757,9 +777,8 @@ bool Script::evaluatePair(Operand *lhs, const char *op, Operand *rhs) { } } - warning("UNHANDLED CASE: [lhs=%d/%s, op=%s rhs=%d/%s]", - lhs->_type, lhs->toString().c_str(), op, rhs->_type, rhs->toString().c_str()); - + warning("UNHANDLED CASE: [lhs=%s/%s, op=%s rhs=%s/%s]", + operandTypeToStr(lhs->_type), lhs->toString().c_str(), op, operandTypeToStr(rhs->_type), rhs->toString().c_str()); return false; } @@ -785,8 +804,8 @@ bool Script::eval(Operand *lhs, const char *op, Operand *rhs) { result = _inputText->equalsIgnoreCase(lhs->toString()); } } else { - error("UNHANDLED CASE: [lhs=%d/%s, rhs=%d/%s]", - lhs->_type, lhs->toString().c_str(), rhs->_type, rhs->toString().c_str()); + error("UNHANDLED CASE: [lhs=%s/%s, rhs=%s/%s]", + operandTypeToStr(lhs->_type), lhs->toString().c_str(), operandTypeToStr(rhs->_type), rhs->toString().c_str()); } if (!strcmp(op, ">>")) { result = !result; @@ -847,7 +866,7 @@ bool Script::evalClickEquality(Operand *lhs, Operand *rhs, bool partialMatch) { str.toLowercase(); debug(9, "evalClickEquality(%s, %s, %d)", lhs->_value.designed->_name.c_str(), rhs->_value.designed->_name.c_str(), partialMatch); - debug(9, "l: %d r: %d (ch: %d ob: %d)", lhs->_type, rhs->_type, CHR, OBJ); + debug(9, "l: %s r: %s)", operandTypeToStr(lhs->_type), operandTypeToStr(rhs->_type)); debug(9, "class: %d", lhs->_value.inputClick->_classType); if (lhs->_value.inputClick->_classType == CHR || lhs->_value.inputClick->_classType == OBJ) { @@ -1080,7 +1099,7 @@ struct Mapping { { "\?\?\?(0xf5)", OPCODE }, { "\?\?\?(0xf6)", OPCODE }, { "\?\?\?(0xf7)", OPCODE }, - { "\?\?\?(0xf8)", OPCODE }, // 0xa8 + { "\?\?\?(0xf8)", OPCODE }, // 0xf8 { "\?\?\?(0xf9)", OPCODE }, { "\?\?\?(0xfa)", OPCODE }, { "\?\?\?(0xfb)", OPCODE }, @@ -1105,7 +1124,7 @@ void Script::convertToText() { if (c < 0x80) { if (c < 0x20) - error("Unknown code 0x%02x at %d", c, _data->pos()); + error("convertToText: Unknown code 0x%02x at %d", c, _data->pos()); do { scr->line += c; |