[Scummvm-git-logs] scummvm master -> 5d060132fb7b8b459c146f6e7689ccf40c9d69b4

sev- sev at scummvm.org
Fri May 15 08:04:13 UTC 2020


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

Summary:
0649b280dc DIRECTOR: LINGO: Fix parray comparison
1ecb21b530 DIRECTOR: LINGO: Handle array equality peculiarity
5d060132fb DIRECTOR: LINGO: Add tests for array comparison


Commit: 0649b280dc0f6fe9b5e474dd247720419308951a
    https://github.com/scummvm/scummvm/commit/0649b280dc0f6fe9b5e474dd247720419308951a
Author: djsrv (dservilla at gmail.com)
Date: 2020-05-15T10:04:08+02:00

Commit Message:
DIRECTOR: LINGO: Fix parray comparison

Comparison operators now check parrays' values, not their keys.

Changed paths:
    engines/director/lingo/lingo-code.cpp


diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index b1bb7bca4d..ad381094a4 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -1040,7 +1040,7 @@ Datum LC::compareArrays(Datum (*compareFunc)(Datum, Datum), Datum d1, Datum d2,
 Datum LC::eqData(Datum d1, Datum d2) {
 	if (d1.type == ARRAY || d2.type == ARRAY ||
 			d1.type == PARRAY || d2.type == PARRAY) {
-		return LC::compareArrays(LC::eqData, d1, d2);
+		return LC::compareArrays(LC::eqData, d1, d2, false, true);
 	}
 	d1.u.i = (d1.compareTo(d2, true) == 0) ? 1 : 0;
 	d1.type = INT;
@@ -1054,8 +1054,9 @@ void LC::c_eq() {
 }
 
 Datum LC::neqData(Datum d1, Datum d2) {
-	if (d1.type == ARRAY || d2.type == ARRAY) {
-		return LC::compareArrays(LC::neqData, d1, d2);
+	if (d1.type == ARRAY || d2.type == ARRAY ||
+			d1.type == PARRAY || d2.type == PARRAY) {
+		return LC::compareArrays(LC::neqData, d1, d2, false, true);
 	}
 	d1.u.i = (d1.compareTo(d2, true) != 0) ? 1 : 0;
 	d1.type = INT;
@@ -1069,8 +1070,9 @@ void LC::c_neq() {
 }
 
 Datum LC::gtData(Datum d1, Datum d2) {
-	if (d1.type == ARRAY || d2.type == ARRAY) {
-		return LC::compareArrays(LC::gtData, d1, d2);
+	if (d1.type == ARRAY || d2.type == ARRAY ||
+			d1.type == PARRAY || d2.type == PARRAY) {
+		return LC::compareArrays(LC::gtData, d1, d2, false, true);
 	}
 	d1.u.i = (d1.compareTo(d2) > 0) ? 1 : 0;
 	d1.type = INT;
@@ -1084,8 +1086,9 @@ void LC::c_gt() {
 }
 
 Datum LC::ltData(Datum d1, Datum d2) {
-	if (d1.type == ARRAY || d2.type == ARRAY) {
-		return LC::compareArrays(LC::ltData, d1, d2);
+	if (d1.type == ARRAY || d2.type == ARRAY ||
+			d1.type == PARRAY || d2.type == PARRAY) {
+		return LC::compareArrays(LC::ltData, d1, d2, false, true);
 	}
 	d1.u.i = (d1.compareTo(d2) < 0) ? 1 : 0;
 	d1.type = INT;
@@ -1099,8 +1102,9 @@ void LC::c_lt() {
 }
 
 Datum LC::geData(Datum d1, Datum d2) {
-	if (d1.type == ARRAY || d2.type == ARRAY) {
-		return LC::compareArrays(LC::geData, d1, d2);
+	if (d1.type == ARRAY || d2.type == ARRAY ||
+			d1.type == PARRAY || d2.type == PARRAY) {
+		return LC::compareArrays(LC::geData, d1, d2, false, true);
 	}
 	d1.u.i = (d1.compareTo(d2) >= 0) ? 1 : 0;
 	d1.type = INT;
@@ -1114,8 +1118,9 @@ void LC::c_ge() {
 }
 
 Datum LC::leData(Datum d1, Datum d2) {
-	if (d1.type == ARRAY || d2.type == ARRAY) {
-		return LC::compareArrays(LC::leData, d1, d2);
+	if (d1.type == ARRAY || d2.type == ARRAY ||
+			d1.type == PARRAY || d2.type == PARRAY) {
+		return LC::compareArrays(LC::leData, d1, d2, false, true);
 	}
 	d1.u.i = (d1.compareTo(d2) <= 0) ? 1 : 0;
 	d1.type = INT;


Commit: 1ecb21b53067080c147e8a0fc7a6e7d2860c23ce
    https://github.com/scummvm/scummvm/commit/1ecb21b53067080c147e8a0fc7a6e7d2860c23ce
Author: djsrv (dservilla at gmail.com)
Date: 2020-05-15T10:04:08+02:00

Commit Message:
DIRECTOR: LINGO: Handle array equality peculiarity

Lingo always returns 0 for = and <> if the left array is longer.

Changed paths:
    engines/director/lingo/lingo-code.cpp


diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index ad381094a4..45f59def0e 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -1038,6 +1038,15 @@ Datum LC::compareArrays(Datum (*compareFunc)(Datum, Datum), Datum d1, Datum d2,
 }
 
 Datum LC::eqData(Datum d1, Datum d2) {
+	// Lingo doesn't bother checking list equality if the left is longer
+	if (d1.type == ARRAY && d2.type == ARRAY &&
+			d1.u.farr->size() > d2.u.farr->size()) {
+		return Datum(0);
+	}
+	if (d1.type == PARRAY && d2.type == PARRAY &&
+			d1.u.parr->size() > d2.u.parr->size()) {
+		return Datum(0);
+	}
 	if (d1.type == ARRAY || d2.type == ARRAY ||
 			d1.type == PARRAY || d2.type == PARRAY) {
 		return LC::compareArrays(LC::eqData, d1, d2, false, true);
@@ -1054,6 +1063,15 @@ void LC::c_eq() {
 }
 
 Datum LC::neqData(Datum d1, Datum d2) {
+	// Lingo doesn't bother checking list equality if the left is longer
+	if (d1.type == ARRAY && d2.type == ARRAY &&
+			d1.u.farr->size() > d2.u.farr->size()) {
+		return Datum(0);
+	}
+	if (d1.type == PARRAY && d2.type == PARRAY &&
+			d1.u.parr->size() > d2.u.parr->size()) {
+		return Datum(0);
+	}
 	if (d1.type == ARRAY || d2.type == ARRAY ||
 			d1.type == PARRAY || d2.type == PARRAY) {
 		return LC::compareArrays(LC::neqData, d1, d2, false, true);


Commit: 5d060132fb7b8b459c146f6e7689ccf40c9d69b4
    https://github.com/scummvm/scummvm/commit/5d060132fb7b8b459c146f6e7689ccf40c9d69b4
Author: djsrv (dservilla at gmail.com)
Date: 2020-05-15T10:04:08+02:00

Commit Message:
DIRECTOR: LINGO: Add tests for array comparison

Changed paths:
    engines/director/lingo/tests/lists.lingo


diff --git a/engines/director/lingo/tests/lists.lingo b/engines/director/lingo/tests/lists.lingo
index 4a29c88011..640cd054dd 100644
--- a/engines/director/lingo/tests/lists.lingo
+++ b/engines/director/lingo/tests/lists.lingo
@@ -28,3 +28,16 @@ set res to 1 + b
 set res to a = a
 set res to a = b
 set res to a < b
+
+set a to [0, 0]
+set b to [0]
+set res to a = b
+set res to a >= b
+set res to b = a
+set res to b >= a
+
+set a to [#a:6, #b:3, #c:8, #d:5]
+set res to a = machinery
+set res to a >= machinery
+set res to machinery = a
+set res to machinery >= a




More information about the Scummvm-git-logs mailing list