From 5478cbe9c8f9f119d621b91d3fe01f62691bde57 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 23 Dec 2015 23:22:08 +0100 Subject: WAGE: Implement non0direct comparisons --- engines/wage/script.cpp | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) (limited to 'engines/wage') diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp index 8953fe1507..ae31d636ba 100644 --- a/engines/wage/script.cpp +++ b/engines/wage/script.cpp @@ -651,34 +651,38 @@ bool Script::eval(Operand *lhs, const char *op, Operand *rhs) { return compare(lhs, rhs, comparators[cmp].cmp); } -#if 0 // Now, try partial matches. + Operand *c1, *c2; for (int cmp = 0; comparators[cmp].op != 0; cmp++) { - if (comparators[cmp].op == op[0]) - if (lhs->_typecomparators[cmp].o1 == lhs->_type) - } - - for (PairEvaluator e : handlers) { - Operand converted; - if (e.lhsType == o1.type && (converted = convertOperand(o2, e.rhsType)) != null) { - e.evaluatePair(o1, converted); - return; - } else if (e.rhsType == o2.type && (converted = convertOperand(o1, e.lhsType)) != null) { - e.evaluatePair(converted, o2); - return; + if (comparators[cmp].op == op[0]) { + if (comparators[cmp].o1 == lhs->_type && + (c2 = convertOperand(rhs, comparators[cmp].o2)) != NULL) { + bool res = compare(lhs, c2, comparators[cmp].cmp); + delete c2; + + return res; + } else if (comparators[cmp].o2 == rhs->_type && + (c1 = convertOperand(lhs, comparators[cmp].o1)) != NULL) { + bool res = compare(c1, rhs, comparators[cmp].cmp); + delete c1; + return res; + } } } // Now, try double conversion. - for (PairEvaluator e : handlers) { - Operand c1, c2; - if ((c1 = convertOperand(o1, e.lhsType)) != null && - (c2 = convertOperand(o2, e.rhsType)) != null) { - e.evaluatePair(c1, c2); - return; + for (int cmp = 0; comparators[cmp].op != 0; cmp++) { + if ((c1 = convertOperand(lhs, comparators[cmp].o1)) != NULL) { + if ((c2 = convertOperand(rhs, comparators[cmp].o2)) != NULL) { + bool res = compare(c1, c2, comparators[cmp].cmp); + delete c1; + delete c2; + + return res; + } + delete c1; } } -#endif } return false; -- cgit v1.2.3