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

fuzzie fuzzie at fuzzie.org
Thu Dec 8 23:17:52 CET 2011


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:
ef22475988 MOHAWK: Implement LB getProperty/setProperty.


Commit: ef224759888ae627743c64cb4a47fc6a30874189
    https://github.com/scummvm/scummvm/commit/ef224759888ae627743c64cb4a47fc6a30874189
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2011-12-08T14:15:48-08:00

Commit Message:
MOHAWK: Implement LB getProperty/setProperty.

Changed paths:
    engines/mohawk/livingbooks.h
    engines/mohawk/livingbooks_code.cpp
    engines/mohawk/livingbooks_code.h



diff --git a/engines/mohawk/livingbooks.h b/engines/mohawk/livingbooks.h
index 1ab6e4d..cde6357 100644
--- a/engines/mohawk/livingbooks.h
+++ b/engines/mohawk/livingbooks.h
@@ -424,6 +424,9 @@ public:
 
 	Common::List<LBItem *>::iterator _iterator;
 
+	// TODO: make private
+	Common::HashMap<Common::String, LBValue, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _variables;
+
 protected:
 	MohawkEngine_LivingBooks *_vm;
 	LBPage *_page;
diff --git a/engines/mohawk/livingbooks_code.cpp b/engines/mohawk/livingbooks_code.cpp
index 8e7c69b..e821e7e 100644
--- a/engines/mohawk/livingbooks_code.cpp
+++ b/engines/mohawk/livingbooks_code.cpp
@@ -847,8 +847,8 @@ CodeCommandInfo generalCommandInfo[NUM_GENERAL_COMMANDS] = {
 	{ "deleteAt", &LBCode::cmdDeleteAt },
 	{ "clearList", &LBCode::cmdUnimplemented },
 	{ "setWorld", 0 },
-	{ "setProperty", 0 },
-	{ "getProperty", 0 },
+	{ "setProperty", &LBCode::cmdSetProperty },
+	{ "getProperty", &LBCode::cmdGetProperty },
 	{ "copyList", 0 },
 	{ "invoke", 0 },
 	{ "exec", &LBCode::cmdExec },
@@ -1189,6 +1189,45 @@ void LBCode::cmdDeleteAt(const Common::Array<LBValue> &params) {
 	params[0].list->array.remove_at(params[1].integer - 1);
 }
 
+void LBCode::cmdSetProperty(const Common::Array<LBValue> &params) {
+	if (params.size() < 2 || params.size() > 3)
+		error("incorrect number of parameters (%d) to setProperty", params.size());
+
+	Common::String name;
+	LBValue val;
+	LBItem *target = _currSource;
+	if (params.size() == 3) {
+		target = resolveItem(params[0]);
+		if (!target)
+			error("attempted setProperty on invalid item (%s)", params[0].toString().c_str());
+		name = params[1].toString();
+		val = params[2];
+	} else {
+		name = params[0].toString();
+		val = params[1];
+	}
+
+	target->_variables[name] = val;
+}
+
+void LBCode::cmdGetProperty(const Common::Array<LBValue> &params) {
+	if (params.size() < 1 || params.size() > 2)
+		error("incorrect number of parameters (%d) to getProperty", params.size());
+
+	Common::String name;
+	LBItem *target = _currSource;
+	if (params.size() == 2) {
+		target = resolveItem(params[0]);
+		if (!target)
+			error("attempted getProperty on invalid item (%s)", params[0].toString().c_str());
+		name = params[1].toString();
+	} else {
+		name = params[0].toString();
+	}
+
+	_stack.push(target->_variables[name]);
+}
+
 void LBCode::cmdExec(const Common::Array<LBValue> &params) {
 	if (params.size() != 1)
 		error("incorrect number of parameters (%d) to exec", params.size());
diff --git a/engines/mohawk/livingbooks_code.h b/engines/mohawk/livingbooks_code.h
index 2cb1994..a8d5e2d 100644
--- a/engines/mohawk/livingbooks_code.h
+++ b/engines/mohawk/livingbooks_code.h
@@ -270,6 +270,8 @@ public:
 	void cmdSetAt(const Common::Array<LBValue> &params);
 	void cmdListLen(const Common::Array<LBValue> &params);
 	void cmdDeleteAt(const Common::Array<LBValue> &params);
+	void cmdSetProperty(const Common::Array<LBValue> &params);
+	void cmdGetProperty(const Common::Array<LBValue> &params);
 	void cmdExec(const Common::Array<LBValue> &params);
 	void cmdReturn(const Common::Array<LBValue> &params);
 	void cmdSetPlayParams(const Common::Array<LBValue> &params);






More information about the Scummvm-git-logs mailing list