[Scummvm-git-logs] scummvm master -> f384f578deebaaa3fb13d55c8685e04758c00b48
sev-
noreply at scummvm.org
Fri Jul 14 12:51:24 UTC 2023
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:
f384f578de DIRECTOR: LINGO: Use STRING to RETRIEVE symbol key property
Commit: f384f578deebaaa3fb13d55c8685e04758c00b48
https://github.com/scummvm/scummvm/commit/f384f578deebaaa3fb13d55c8685e04758c00b48
Author: Harishankar Kumar (hari01584 at gmail.com)
Date: 2023-07-14T14:51:20+02:00
Commit Message:
DIRECTOR: LINGO: Use STRING to RETRIEVE symbol key property
This is a special edge case where a string can be used to retrieve a
property which has its key as symbol, ie something like [#abc:"xyz],
and using "abc" in comparison to retrieve the property. It is however
worth noting that this special case is only when retrieving a property,
ie a string "abc" is not equal to its symbolic version #abc.
Fixes misplaced <Void> in game saves of 'totaldistortion' when
sleeping to bed.
Changed paths:
engines/director/lingo/lingo-code.cpp
engines/director/lingo/tests/lists.lingo
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index 6ae01ef3f1d..d4bef99f910 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -1271,6 +1271,16 @@ Datum LC::compareArrays(Datum (*compareFunc)(Datum, Datum), Datum d1, Datum d2,
b = value ? t.v : t.p;
}
+ // Special case, we can retrieve symbolic key by giving their string representation, ie
+ // for arr [a: "abc", "b": "def"], both getProp(arr, "a") and getProp(arr, #a) will return "abc",
+ // vice-versa is also true, ie getProp(arr, "b") and getProp(arr, #b) will return "def"
+ if (a.type == SYMBOL && b.type == STRING) {
+ a = Datum(a.asString());
+ } else if (a.type == STRING && b.type == SYMBOL) {
+ b = Datum(b.asString());
+ }
+
+
res = compareFunc(a, b);
if (!location) {
if (res.u.i == 0) {
diff --git a/engines/director/lingo/tests/lists.lingo b/engines/director/lingo/tests/lists.lingo
index 18356a2de0a..55ea56482d4 100644
--- a/engines/director/lingo/tests/lists.lingo
+++ b/engines/director/lingo/tests/lists.lingo
@@ -48,7 +48,7 @@ set res to machinery = a
set res to machinery >= a
-- property Array tests
-set propArray to [501: "cast", 502: "value", 1.5: "script", a: "score", #b: "member"]
+set propArray to [501: "cast", 502: "value", 1.5: "script", a: "score", #b: "member", "color": "red"]
set var to getPropAt(propArray, 1)
scummvmAssertEqual(var, 501)
set var to getAt(propArray, 1)
@@ -58,6 +58,10 @@ set var to getProp(propArray, 1.5)
scummvmAssertEqual(var, "script")
set var to getProp(propArray, #a)
scummvmAssertEqual(var, "score")
+set var to getProp(propArray, "a")
+scummvmAssertEqual(var, "score")
+set var to getProp(propArray, #color)
+scummvmAssertEqual(var, "red")
set var to getProp(propArray, #b)
scummvmAssertEqual(var, "member")
@@ -139,3 +143,15 @@ put 5 + b -- rect(25, 25, 25, 25)
set proplist_without_keys = ["key": "value", "keyless expr 1", "keyless expr 2"]
set proplist_with_keys = ["key": "value", 2: "keyless expr 1", 3: "keyless expr 2"]
scummvmAssert(proplist_without_keys = proplist_with_keys)
+
+-- list with symbol or string as key
+set templst to [#mood: 1]
+set tempmood to the mood of templst
+scummvmAssert(tempmood = 1)
+put templst
+
+-- assign and check
+set the mood of templst to 2
+set tempmood to the mood of templst
+scummvmAssert(tempmood = 2)
+put templst
More information about the Scummvm-git-logs
mailing list