[Scummvm-cvs-logs] scummvm master -> c826047cc44943d25ea3ba74a958a7ab34989b8a

dreammaster dreammaster at scummvm.org
Sat Jan 16 05:39:29 CET 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
c826047cc4 MADS: Implement conversation set node script opcode


Commit: c826047cc44943d25ea3ba74a958a7ab34989b8a
    https://github.com/scummvm/scummvm/commit/c826047cc44943d25ea3ba74a958a7ab34989b8a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-01-15T23:38:58-05:00

Commit Message:
MADS: Implement conversation set node script opcode

Changed paths:
    engines/mads/conversations.cpp
    engines/mads/conversations.h



diff --git a/engines/mads/conversations.cpp b/engines/mads/conversations.cpp
index 207b85f..5f273ea 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 e7bf423..e124787 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






More information about the Scummvm-git-logs mailing list