aboutsummaryrefslogtreecommitdiff
path: root/engines/wage/script.cpp
diff options
context:
space:
mode:
authorEugene Sandulenko2016-01-02 12:55:22 +0100
committerEugene Sandulenko2016-01-02 12:55:22 +0100
commit0870ac88b8ce03753bf6114d2c0a76f5a638b61d (patch)
tree160b5afd9855ab7f039976bb899b992006f60693 /engines/wage/script.cpp
parent8d6e8118423088ba5c126e2cedf79bb3f41492f6 (diff)
downloadscummvm-rg350-0870ac88b8ce03753bf6114d2c0a76f5a638b61d.tar.gz
scummvm-rg350-0870ac88b8ce03753bf6114d2c0a76f5a638b61d.tar.bz2
scummvm-rg350-0870ac88b8ce03753bf6114d2c0a76f5a638b61d.zip
WAGE: Implement evalClickCondition
Diffstat (limited to 'engines/wage/script.cpp')
-rw-r--r--engines/wage/script.cpp45
1 files changed, 43 insertions, 2 deletions
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 778c0c8269..13b2617509 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -749,10 +749,51 @@ Script::Operand *Script::convertOperand(Operand *operand, int type) {
return NULL;
}
+bool Script::evalClickEquality(Operand *lhs, Operand *rhs, bool partialMatch) {
+ bool result = false;
+ if (lhs->_value.obj == NULL || rhs->_value.obj == NULL) {
+ result = false;
+ } else if (lhs->_value.obj == rhs->_value.obj) {
+ result = true;
+ } else if (rhs->_type == STRING) {
+ Common::String str = rhs->toString();
+ str.toLowercase();
+
+ if (lhs->_type == CHR || lhs->_type == OBJ) {
+ Common::String name = lhs->_value.designed->_name;
+ name.toLowercase();
+
+ if (partialMatch)
+ result = name.contains(str);
+ else
+ result = name.equals(str);
+ }
+ }
+ return result;
+}
+
bool Script::evalClickCondition(Operand *lhs, const char *op, Operand *rhs) {
- warning("STUB: evalClickCondition");
+ // TODO: check if >> can be used for click inputs
+ if (strcmp(op, "==") && strcmp(op, "=") && strcmp(op, "<") && strcmp(op, ">")) {
+ error("Unknown operation '%s' for Script::evalClickCondition", op);
+ }
- return false;
+ bool partialMatch = strcmp(op, "==");
+ bool result;
+ if (lhs->_type == CLICK_INPUT) {
+ result = evalClickEquality(lhs, rhs, partialMatch);
+ } else {
+ result = evalClickEquality(rhs, lhs, partialMatch);
+ }
+ if (!strcmp(op, "<") || !strcmp(op, ">")) {
+ // CLICK$<FOO only matches if there was a click
+ if (_inputClick == NULL) {
+ result = false;
+ } else {
+ result = !result;
+ }
+ }
+ return result;
}
void Script::takeObj(Obj *obj) {