aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2016-01-02 12:55:22 +0100
committerEugene Sandulenko2016-01-02 12:55:22 +0100
commit0870ac88b8ce03753bf6114d2c0a76f5a638b61d (patch)
tree160b5afd9855ab7f039976bb899b992006f60693
parent8d6e8118423088ba5c126e2cedf79bb3f41492f6 (diff)
downloadscummvm-rg350-0870ac88b8ce03753bf6114d2c0a76f5a638b61d.tar.gz
scummvm-rg350-0870ac88b8ce03753bf6114d2c0a76f5a638b61d.tar.bz2
scummvm-rg350-0870ac88b8ce03753bf6114d2c0a76f5a638b61d.zip
WAGE: Implement evalClickCondition
-rw-r--r--engines/wage/script.cpp45
-rw-r--r--engines/wage/script.h2
2 files changed, 45 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) {
diff --git a/engines/wage/script.h b/engines/wage/script.h
index 0cf6785fc6..876ec0764e 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -70,6 +70,7 @@ private:
union {
Obj *obj;
Chr *chr;
+ Designed *designed;
Scene *scene;
int16 number;
String *string;
@@ -156,6 +157,7 @@ private:
bool eval(Operand *lhs, const char *op, Operand *rhs);
Operand *convertOperand(Operand *operand, int type);
bool evalClickCondition(Operand *lhs, const char *op, Operand *rhs);
+ bool evalClickEquality(Operand *lhs, Operand *rhs, bool partialMatch);
void takeObj(Obj *obj);
void processMove();
void processLet();