[Scummvm-git-logs] scummvm master -> 1b8e614bc8f668065a0df956f43243f225afd9a3

sev- noreply at scummvm.org
Wed May 31 21:16:31 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:
1b8e614bc8 DIRECTOR: Fix b_offset implementation and make it case-insensitive


Commit: 1b8e614bc8f668065a0df956f43243f225afd9a3
    https://github.com/scummvm/scummvm/commit/1b8e614bc8f668065a0df956f43243f225afd9a3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-05-31T23:16:02+02:00

Commit Message:
DIRECTOR: Fix b_offset implementation and make it case-insensitive

It must use Director character order.

This also implemented d_strstr() function as strstr() replacement

The side effect of it is the7colors navigation was broken. It contains
the following code:

  set offs = offset("ROOM.I/O",the pathname) - 1
  set path = chars(the pathname,1,offs)&"01.Colidor:"

the pathname is "01ROOM:Room.I/O:" that does not match "ROOM.I/O"

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


diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 21818526f4e..d924ea173d7 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -526,7 +526,7 @@ void LB::b_offset(int nargs) {
 	Common::String source = g_lingo->pop().asString();
 	Common::String target = g_lingo->pop().asString();
 
-	const char *str = strstr(source.c_str(), target.c_str());
+	const char *str = d_strstr(source.c_str(), target.c_str());
 
 	if (str == nullptr)
 		g_lingo->push(Datum(0));
diff --git a/engines/director/util.cpp b/engines/director/util.cpp
index 2f62451ae69..7263382ed42 100644
--- a/engines/director/util.cpp
+++ b/engines/director/util.cpp
@@ -1478,6 +1478,29 @@ int compareStrings(const Common::String &s1, const Common::String &s2) {
 	return c1 - c2;
 }
 
+const char *d_strstr(const char *str, const char *substr) {
+	int len = strlen(substr);
+	const char *ref = substr;
+
+	while (*str && *ref) {
+		uint32 c1 = getCharOrder(*str);
+		uint32 c2 = getCharOrder(*ref);
+
+		str++;
+
+		if (c1 == c2)
+			ref++;
+
+		if (!*ref)
+			return (str - len);
+
+		if (len == (ref - substr))
+			ref = substr;
+	}
+
+	return NULL;
+}
+
 void DirectorEngine::delayMillis(uint32 delay) {
 	if (debugChannelSet(-1, kDebugFast))
 		return;
diff --git a/engines/director/util.h b/engines/director/util.h
index 8b90f30a648..ce23ff548e5 100644
--- a/engines/director/util.h
+++ b/engines/director/util.h
@@ -95,6 +95,9 @@ int charToNum(Common::u32char_type_t ch);
 Common::u32char_type_t numToChar(int num);
 int compareStrings(const Common::String &s1, const Common::String &s2);
 
+// Our implementation of strstr() with Director character order
+const char *d_strstr(const char *str, const char *substr);
+
 Common::String encodePathForDump(const Common::String &path);
 
 Common::String utf8ToPrintable(const Common::String &str);




More information about the Scummvm-git-logs mailing list