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

rvanlaar roland at rolandvanlaar.nl
Sun Aug 2 10:21:16 UTC 2020


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

Summary:
030dae11b7 DIRECTOR: Lingo: improve scummvmAssertEqual output
af4fb28dd9 DIRECTOR: LINGO: Improve charOf and charToOf


Commit: 030dae11b745d1e7826e36cd72a8d141fd2e9869
    https://github.com/scummvm/scummvm/commit/030dae11b745d1e7826e36cd72a8d141fd2e9869
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2020-08-02T11:12:37+02:00

Commit Message:
DIRECTOR: Lingo: improve scummvmAssertEqual output

Use the same variable order in the message as in the call.

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


diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 41855b4f99..b7ebcc3d58 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -2439,8 +2439,8 @@ void LB::b_scummvmassert(int nargs) {
 }
 
 void LB::b_scummvmassertequal(int nargs) {
-	Datum d1 = g_lingo->pop();
 	Datum d2 = g_lingo->pop();
+	Datum d1 = g_lingo->pop();
 
 	int result = d1.equalTo(d2);
 	if (!result) {


Commit: af4fb28dd92bf8fd814f2c38fd56cb3638c1c1fb
    https://github.com/scummvm/scummvm/commit/af4fb28dd92bf8fd814f2c38fd56cb3638c1c1fb
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2020-08-02T12:13:42+02:00

Commit Message:
DIRECTOR: LINGO: Improve charOf and charToOf

- Allow for floats as indexes
    Note: D3 does a round, D4 a floor
- Bugfix charToOf: correctly format substr parameters.
    substr 2nd parameter the length of the requested substring
    not a posTo.

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


diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index ef370b3b6e..f6e7233ca7 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -1041,14 +1041,14 @@ void LC::c_charOf() {
 	Datum d2 = g_lingo->pop(); // string
 	Datum d1 = g_lingo->pop(); // index
 
-    if (d1.type != INT || d2.type != STRING ) {
+    if ((d1.type != INT && d1.type != FLOAT) || d2.type != STRING) {
 		warning("LC::c_charOf(): Called with wrong data types: %s and %s", d1.type2str(), d2.type2str());
 		g_lingo->push(Datum(""));
 		return;
 	}
 
 	Datum res;
-	int index = d1.u.i;
+	int index = d1.asInt();
 	Common::String chunkExpr = *d2.u.s;
 
 	if (index < 1)
@@ -1065,14 +1065,14 @@ void LC::c_charToOf() {
 	Datum d2 = g_lingo->pop(); // indexFrom
 	Datum d1 = g_lingo->pop(); // indexTo
 
-	if (d1.type != INT || d2.type != INT || d3.type != STRING) {
+	if ((d1.type != INT && d1.type != FLOAT) || (d2.type != INT && d2.type != FLOAT) || d3.type != STRING) {
 		warning("LC::c_charToOf(): Called with wrong data types: %s, %s and %s", d1.type2str(), d2.type2str(), d3.type2str());
 		g_lingo->push(Datum(""));
 		return;
 	}
 
-	int indexFrom = d1.u.i;
-	int indexTo = d2.u.i;
+	int indexFrom = d1.asInt();
+	int indexTo = d2.asInt();
 	Common::String chunkExpr = *d3.u.s;
 
 	Datum res;
@@ -1086,7 +1086,7 @@ void LC::c_charToOf() {
 	else if (uint(indexFrom) > chunkExpr.size())
 		res = Datum("");
 	else
-		res = Datum(chunkExpr.substr(indexFrom - 1, indexTo - 1));
+		res = Datum(chunkExpr.substr(indexFrom - 1, indexTo - indexFrom + 1));
 	g_lingo->push(res);
 }
 
diff --git a/engines/director/lingo/tests/strings.lingo b/engines/director/lingo/tests/strings.lingo
index b406a652c7..ef2a223366 100644
--- a/engines/director/lingo/tests/strings.lingo
+++ b/engines/director/lingo/tests/strings.lingo
@@ -39,35 +39,32 @@ scummvmAssertEqual(test, return)
 set string to "Macromedia"
 set res to char 6 of string
 scummvmAssertEqual(res, "m")
-put "m" && res
 
 -- error and bounds checks
 set res to  char 60 of string
 scummvmAssertEqual(res, EMPTY)
-put "" && res
 set res to char 0 of string
 scummvmAssertEqual(res, string)
-put string && res
+set res to char 5.4 of string
+scummvmAssertEqual(res, "o")
 
 -- LC::charToOf
 set string to "Macromedia"
 set res to char 6 to 9 of string
-put "media" && res
-scummvmAssertEqual(res, "media")
+scummvmAssertEqual(res, "medi")
 
 -- error and bounds checks
+set res to char 5.4 to 7.9 of string
+scummvmAssertEqual(res, "ome")
+
 set res to char 6 to 5 of string
-put "" && res
-scummvmAssert(res="")
+scummvmAssertEqual(res, "")
 
 set res to char 6 to 60 of string
-put "media" && res
 scummvmAssertEqual(res, "media")
 
 set res to char -1 to -2 of string
-put string && res
 scummvmAssertEqual(res, string)
 
 set res to char 50 to 60 of string
-put "" && res
 scummvmAssertEqual(res, "")




More information about the Scummvm-git-logs mailing list