aboutsummaryrefslogtreecommitdiff
path: root/engines/mads
diff options
context:
space:
mode:
authorPaul Gilbert2016-01-15 23:38:58 -0500
committerPaul Gilbert2016-01-15 23:38:58 -0500
commitc826047cc44943d25ea3ba74a958a7ab34989b8a (patch)
tree2119734b79e038179cab6e8853a07f93d6cb9036 /engines/mads
parentdd7f1421d4d90d6b84cd61817beb19ee560fb4e7 (diff)
downloadscummvm-rg350-c826047cc44943d25ea3ba74a958a7ab34989b8a.tar.gz
scummvm-rg350-c826047cc44943d25ea3ba74a958a7ab34989b8a.tar.bz2
scummvm-rg350-c826047cc44943d25ea3ba74a958a7ab34989b8a.zip
MADS: Implement conversation set node script opcode
Diffstat (limited to 'engines/mads')
-rw-r--r--engines/mads/conversations.cpp32
-rw-r--r--engines/mads/conversations.h7
2 files changed, 33 insertions, 6 deletions
diff --git a/engines/mads/conversations.cpp b/engines/mads/conversations.cpp
index 207b85fe85..5f273eabbb 100644
--- a/engines/mads/conversations.cpp
+++ b/engines/mads/conversations.cpp
@@ -439,7 +439,7 @@ int GameConversations::executeEntry(int index) {
_nextStartNode->_val = var0._val;
bool flag = true;
- for (uint scriptIdx = 0; scriptIdx < dlg._script.size(); ) {
+ for (uint scriptIdx = 0; scriptIdx < dlg._script.size() && flag; ) {
ScriptEntry &scrEntry = dlg._script[scriptIdx];
if (scrEntry._command == CMD_END)
break;
@@ -461,6 +461,10 @@ int GameConversations::executeEntry(int index) {
error("Conversation script generated error");
break;
+ case CMD_NODE:
+ flag = !scriptNode(scrEntry);
+ break;
+
case CMD_GOTO: {
bool gotoFlag = scrEntry._conditionals[0].evaluate();
if (gotoFlag) {
@@ -537,6 +541,24 @@ void GameConversations::scriptMessage(ScriptEntry &scrEntry) {
}
}
+bool GameConversations::scriptNode(ScriptEntry &scrEntry) {
+ bool doFlag = scrEntry._conditionals[0].evaluate();
+ if (!doFlag)
+ return false;
+
+ ConversationVar &var0 = _runningConv->_cnd._vars[0];
+ int val1 = scrEntry._conditionals[1].evaluate();
+ int val2 = scrEntry._conditionals[2].evaluate();
+
+ var0._val = val1;
+ if (val1 >= 0)
+ _nextStartNode->_val = val1;
+ else if (val2 >= 0)
+ _nextStartNode->_val = val2;
+
+ return true;
+}
+
/*------------------------------------------------------------------------*/
void ConversationData::load(const Common::String &filename) {
@@ -811,7 +833,7 @@ void ScriptEntry::load(Common::SeekableReadStream &s) {
// Get in the conditional values
int numConditionals = 1;
- if (_command == CMD_7)
+ if (_command == CMD_NODE)
numConditionals = 3;
else if (_command == CMD_ASSIGN)
numConditionals = 2;
@@ -859,7 +881,7 @@ void ScriptEntry::load(Common::SeekableReadStream &s) {
}
case CMD_ERROR:
- case CMD_7:
+ case CMD_NODE:
// These opcodes have no extra parameters
break;
@@ -888,7 +910,7 @@ void ScriptEntry::Conditional::load(Common::SeekableReadStream &s) {
_param1._val = 0;
} else {
_param1._isVariable = s.readByte() != 0;
- _param1._val = s.readUint16LE();
+ _param1._val = s.readSint16LE();
}
if (_operation == CONDOP_ABORT || _operation == CONDOP_VALUE) {
@@ -896,7 +918,7 @@ void ScriptEntry::Conditional::load(Common::SeekableReadStream &s) {
_param2._val = 0;
} else {
_param2._isVariable = s.readByte() != 0;
- _param2._val = s.readUint16LE();
+ _param2._val = s.readSint16LE();
}
}
diff --git a/engines/mads/conversations.h b/engines/mads/conversations.h
index e7bf4232f4..e1247875c5 100644
--- a/engines/mads/conversations.h
+++ b/engines/mads/conversations.h
@@ -56,7 +56,7 @@ enum DialogCommand {
CMD_MESSAGE1 = 4,
CMD_MESSAGE2 = 5,
CMD_ERROR = 6,
- CMD_7 = 7,
+ CMD_NODE = 7,
CMD_GOTO = 8,
CMD_ASSIGN = 9,
CMD_DIALOG_END = 255
@@ -374,6 +374,11 @@ private:
* Handle messages
*/
void scriptMessage(ScriptEntry &scrEntry);
+
+ /**
+ * Handle node changes
+ */
+ bool scriptNode(ScriptEntry &scrEntry);
public:
/**
* Constructor