[Scummvm-git-logs] scummvm master -> a41f02c69df608d0e7caf503cb90710fd7fa6e4c

rvanlaar noreply at scummvm.org
Mon Mar 14 10:04:18 UTC 2022


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:
a41f02c69d DIRECTOR: LINGO: Add comparison for Objects


Commit: a41f02c69df608d0e7caf503cb90710fd7fa6e4c
    https://github.com/scummvm/scummvm/commit/a41f02c69df608d0e7caf503cb90710fd7fa6e4c
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2022-03-14T11:04:07+01:00

Commit Message:
DIRECTOR: LINGO: Add comparison for Objects

When comparing an Object, i.e. FileIO instance, to an INT or STRING, the
Object is parsed as string and then compared. An Object's string is
<Object:hexcode>, e.g. <Object:794b8d0>. When compared to an INT, it's a
regular string compare.

This make saving and loading work again in Majestic.

Note: '#' < '0' due to ord '#' is 35 and ord '0' is 48.

Implemented changes:
- compare Object as STRING when it's an Object with INT or STRING
  comparison,
- set Objects string to start with <Object,
- include lingo test and
- remove BUILDBOT notification on invalid comparion.

Changed paths:
    engines/director/lingo/lingo.cpp
    engines/director/lingo/tests/equality.lingo


diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index 4838e94c772..8d5255202ee 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -588,6 +588,10 @@ int Lingo::getAlignedType(const Datum &d1, const Datum &d2, bool numsOnly) {
 		d1Type = INT;
 	if (d2Type == VOID)
 		d2Type = INT;
+	if (d1Type == OBJECT)
+		d1Type = STRING;
+	if (d2Type == OBJECT)
+		d2Type = STRING;
 
 	if (d1Type == FLOAT || d2Type == FLOAT) {
 		opType = FLOAT;
@@ -835,7 +839,9 @@ Common::String Datum::asString(bool printonly) const {
 		break;
 	case OBJECT:
 		if (!printonly) {
-			s = Common::String::format("#%s", u.obj->getName().c_str());
+			// Object names in Director are: "<Object:hex>"
+			// the starting '<' is important, it's used when comparing objects and integers
+			s = Common::String::format("<Object:#%s", u.obj->getName().c_str());
 		} else {
 			s = u.obj->asString();
 		}
@@ -1090,7 +1096,7 @@ CompareResult Datum::compareTo(Datum &d) const {
 			return kCompareGreater;
 		}
 	} else {
-		warning("BUILDBOT: Invalid comparison between types %s and %s", type2str(), d.type2str());
+		warning("Invalid comparison between types %s and %s", type2str(), d.type2str());
 		return kCompareError;
 	}
 }
diff --git a/engines/director/lingo/tests/equality.lingo b/engines/director/lingo/tests/equality.lingo
index dc91a083362..7e8bf9c9a48 100644
--- a/engines/director/lingo/tests/equality.lingo
+++ b/engines/director/lingo/tests/equality.lingo
@@ -14,5 +14,8 @@ scummvmAssert("test" <> #test)
 scummvmAssert("string" > 0)
 scummvmAssert("1string" < 2)
 
+-- Mimic an object
+scummvmAssert("<Object:#FileIO" > 0)
+
 -- Invalid comparisons should return FALSE
 scummvmAssert(not (#test <= 0))




More information about the Scummvm-git-logs mailing list