aboutsummaryrefslogtreecommitdiff
path: root/engines/parallaction/parallaction_br.cpp
diff options
context:
space:
mode:
authorNicola Mettifogo2009-01-04 14:23:20 +0000
committerNicola Mettifogo2009-01-04 14:23:20 +0000
commitf2b495ba2d31fc6cdfd07130c9491dea026c07cb (patch)
tree64e20efe7bdaf26335cc6eb8163a3c1c984233d9 /engines/parallaction/parallaction_br.cpp
parent4273d0db92f37dcaefea280022e9d6b2effafeb9 (diff)
downloadscummvm-rg350-f2b495ba2d31fc6cdfd07130c9491dea026c07cb.tar.gz
scummvm-rg350-f2b495ba2d31fc6cdfd07130c9491dea026c07cb.tar.bz2
scummvm-rg350-f2b495ba2d31fc6cdfd07130c9491dea026c07cb.zip
Implemented counters in BRA. Only valid answer options are shown, and counter calculations in scripts are performed.
svn-id: r35723
Diffstat (limited to 'engines/parallaction/parallaction_br.cpp')
-rw-r--r--engines/parallaction/parallaction_br.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/engines/parallaction/parallaction_br.cpp b/engines/parallaction/parallaction_br.cpp
index 7d7fe660bc..5989d2c9b1 100644
--- a/engines/parallaction/parallaction_br.cpp
+++ b/engines/parallaction/parallaction_br.cpp
@@ -326,6 +326,64 @@ void Parallaction_br::changeCharacter(const char *name) {
_char._ani->_flags |= kFlagsActive;
}
+bool Parallaction_br::counterExists(const Common::String &name) {
+ return Table::notFound != _countersNames->lookup(name.c_str());
+}
+
+int Parallaction_br::getCounterValue(const Common::String &name) {
+ int index = _countersNames->lookup(name.c_str());
+ if (index != Table::notFound) {
+ return _counters[index - 1];
+ }
+ return 0;
+}
+
+void Parallaction_br::setCounterValue(const Common::String &name, int value) {
+ int index = _countersNames->lookup(name.c_str());
+ if (index != Table::notFound) {
+ _counters[index - 1] = value;
+ }
+}
+
+void Parallaction_br::testCounterCondition(const Common::String &name, int op, int value) {
+ int index = _countersNames->lookup(name.c_str());
+ if (index == Table::notFound) {
+ clearLocationFlags(kFlagsTestTrue);
+ return;
+ }
+
+ int c = _counters[index - 1];
+
+// these definitions must match those in parser_br.cpp
+#define CMD_TEST 25
+#define CMD_TEST_GT 26
+#define CMD_TEST_LT 27
+
+ bool res = false;
+ switch (op) {
+ case CMD_TEST:
+ res = (c == value);
+ break;
+
+ case CMD_TEST_GT:
+ res = (c > value);
+ break;
+
+ case CMD_TEST_LT:
+ res = (c < value);
+ break;
+
+ default:
+ error("unknown operator in testCounterCondition");
+ }
+
+ if (res) {
+ setLocationFlags(kFlagsTestTrue);
+ } else {
+ clearLocationFlags(kFlagsTestTrue);
+ }
+}
+
} // namespace Parallaction