aboutsummaryrefslogtreecommitdiff
path: root/engines/wage/script.cpp
diff options
context:
space:
mode:
authorEugene Sandulenko2016-01-04 12:07:22 +0100
committerEugene Sandulenko2016-01-04 12:07:22 +0100
commit5843a180539c55756ec2644223120f7bc6238f57 (patch)
treef92404a4f8af8cc950c41c387dc2b26db4b9631c /engines/wage/script.cpp
parent3b48d90f13159afc3b877929b63bea6a8467694c (diff)
downloadscummvm-rg350-5843a180539c55756ec2644223120f7bc6238f57.tar.gz
scummvm-rg350-5843a180539c55756ec2644223120f7bc6238f57.tar.bz2
scummvm-rg350-5843a180539c55756ec2644223120f7bc6238f57.zip
WAGE: Fix Script::processMove(), so it works with double conversion too
Diffstat (limited to 'engines/wage/script.cpp')
-rw-r--r--engines/wage/script.cpp112
1 files changed, 58 insertions, 54 deletions
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index c08b06be22..951a5d31a1 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -665,6 +665,60 @@ bool Script::compare(Operand *o1, Operand *o2, int comparator) {
return false;
}
+bool Script::evaluatePair(Operand *lhs, const char *op, Operand *rhs) {
+ for (int cmp = 0; comparators[cmp].op != 0; cmp++) {
+ if (comparators[cmp].op != op[0])
+ continue;
+
+ if (comparators[cmp].o1 == lhs->_type && comparators[cmp].o2 == rhs->_type)
+ return compare(lhs, rhs, comparators[cmp].cmp);
+ }
+
+ // Now, try partial matches.
+ Operand *c1, *c2;
+ for (int cmp = 0; comparators[cmp].op != 0; cmp++) {
+ if (comparators[cmp].op != op[0])
+ continue;
+
+ 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 (int cmp = 0; comparators[cmp].op != 0; cmp++) {
+ if (comparators[cmp].op != op[0])
+ continue;
+
+ if (comparators[cmp].o1 == lhs->_type || comparators[cmp].o2 == rhs->_type)
+ continue;
+
+ 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;
+ }
+ }
+
+ warning("UNHANDLED CASE: [lhs=%d/%s, op=%s rhs=%d/%s]",
+ lhs->_type, lhs->toString().c_str(), op, rhs->_type, rhs->toString().c_str());
+
+
+ return false;
+}
+
bool Script::eval(Operand *lhs, const char *op, Operand *rhs) {
bool result = false;
@@ -695,51 +749,7 @@ bool Script::eval(Operand *lhs, const char *op, Operand *rhs) {
return result;
} else {
- for (int cmp = 0; comparators[cmp].op != 0; cmp++) {
- if (comparators[cmp].op != op[0])
- continue;
-
- if (comparators[cmp].o1 == lhs->_type && comparators[cmp].o2 == rhs->_type)
- return compare(lhs, rhs, comparators[cmp].cmp);
- }
-
- // Now, try partial matches.
- Operand *c1, *c2;
- for (int cmp = 0; comparators[cmp].op != 0; cmp++) {
- if (comparators[cmp].op != op[0])
- continue;
-
- 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 (int cmp = 0; comparators[cmp].op != 0; cmp++) {
- if (comparators[cmp].op != op[0])
- continue;
-
- if (comparators[cmp].o1 == lhs->_type || comparators[cmp].o2 == rhs->_type)
- continue;
-
- 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;
- }
- }
+ return evaluatePair(lhs, op, rhs);
}
return false;
@@ -868,16 +878,10 @@ void Script::processMove() {
if (skip != 0xfd)
error("No end for MOVE: %02x", skip);
- for (int cmp = 0; comparators[cmp].op != 0; cmp++) {
- if (comparators[cmp].op != 'M')
- continue;
-
- if (comparators[cmp].o1 == what->_type && comparators[cmp].o2 == to->_type) {
- compare(what, to, comparators[cmp].cmp);
+ debug(6, "MOVE: [what=%d/%s, to=%d/%s]",
+ what->_type, what->toString().c_str(), to->_type, to->toString().c_str());
- break;
- }
- }
+ evaluatePair(what, "M", to);
}
void Script::processLet() {