[Scummvm-git-logs] scummvm master -> 1851b9eee3e4361f45050b4a8bfa66b7b82d28b5

sev- noreply at scummvm.org
Sun Nov 5 20:54:10 UTC 2023


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:
e4c00147ad DIRECTOR: Fix "the palette of cast" access
1851b9eee3 DIRECTOR: Fix resolution of "me" objects


Commit: e4c00147ad52fd20c0a95109087b2fb23c9980dd
    https://github.com/scummvm/scummvm/commit/e4c00147ad52fd20c0a95109087b2fb23c9980dd
Author: Scott Percival (code at moral.net.au)
Date: 2023-11-05T21:54:07+01:00

Commit Message:
DIRECTOR: Fix "the palette of cast" access

Changed paths:
    engines/director/castmember/bitmap.cpp


diff --git a/engines/director/castmember/bitmap.cpp b/engines/director/castmember/bitmap.cpp
index 2f019ffb01d..dd632ebf908 100644
--- a/engines/director/castmember/bitmap.cpp
+++ b/engines/director/castmember/bitmap.cpp
@@ -704,7 +704,12 @@ Datum BitmapCastMember::getField(int field) {
 		d.u.farr->arr.push_back(_regY);
 		break;
 	case kThePalette:
-		d = _clut;
+		// D5 and below return an integer for this field
+		if (_clut.castLib > 0) {
+			d = Datum(_clut.member + 0x20000 * (_clut.castLib - 1));
+		} else {
+			d = Datum(_clut.member);
+		}
 		break;
 	case kThePicture:
 		d.type = PICTUREREF;
@@ -736,14 +741,26 @@ bool BitmapCastMember::setField(int field, const Datum &d) {
 		return true;
 	case kThePalette:
 		{
-			// FIXME: not multicast safe
-			int id = d.asInt();
-			if (id > 0) {
-				_clut = CastMemberID(d.asInt(), DEFAULT_CAST_LIB);
-			} else if (id < 0) {
-				_clut = CastMemberID(d.asInt(), -1);
+			CastMemberID newClut;
+			if (d.isCastRef()) {
+				newClut = *d.u.cast;
 			} else {
-				_clut = CastMemberID(0, 0);
+				int id = d.asInt();
+				if (id > 0) {
+					// For palette IDs, D5 and above use multiples of 0x20000 to denote
+					// the castLib in the integer representation
+					newClut = CastMemberID(id % 0x20000, 1 + (id / 0x20000));
+				} else if (id < 0) {
+					// Negative integer refers to one of the builtin palettes
+					newClut = CastMemberID(id, -1);
+				} else {
+					// 0 indicates a fallback to the default palette settings
+					newClut = CastMemberID(0, 0);
+				}
+			}
+			if (newClut != _clut) {
+				_clut = newClut;
+				_modified = true;
 			}
 			return true;
 		}


Commit: 1851b9eee3e4361f45050b4a8bfa66b7b82d28b5
    https://github.com/scummvm/scummvm/commit/1851b9eee3e4361f45050b4a8bfa66b7b82d28b5
Author: Scott Percival (code at moral.net.au)
Date: 2023-11-05T21:54:07+01:00

Commit Message:
DIRECTOR: Fix resolution of "me" objects

In factory methods, the first argument is usually the "me" object.
When calling the method from a different script context, this is used
to set Lingo's current me object. However, when calling the method
from the -same- script context, this is ignored. You can pass whatever
nonsense you like in as argument 1; the value will be ignored and
"me" will resolve as the current me object.

Fixes several broken scripts in The Dark Eye.

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


diff --git a/engines/director/lingo/lingo-bytecode.cpp b/engines/director/lingo/lingo-bytecode.cpp
index fea5a8edc12..a4ffdfc3fd4 100644
--- a/engines/director/lingo/lingo-bytecode.cpp
+++ b/engines/director/lingo/lingo-bytecode.cpp
@@ -633,11 +633,9 @@ void LC::cb_thepush() {
 
 		warning("cb_thepush: me object has no property '%s', type: %d", name.c_str(), g_lingo->_state->me.type);
 	} else {
-		warning("cb_thepush: no me object");
+		g_lingo->lingoError("cb_thepush: no me object");
 	}
-	Datum result;
-	result.type = VOID;
-	g_lingo->push(result);
+	g_lingo->pushVoid();
 }
 
 void LC::cb_thepush2() {
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index 41ac52eda3d..20a53d0b757 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -1653,7 +1653,11 @@ Datum Lingo::varFetch(const Datum &var, bool silent) {
 		{
 			Common::String name = *var.u.s;
 			g_debugger->varReadHook(name);
-			if (_state->localVars && _state->localVars->contains(name)) {
+			// "me" is a special case; even if there is a local variable or argument called "me",
+			// the current me object will take precedence.
+			if (name == "me" && _state->me.type == OBJECT) {
+				return _state->me;
+			} else if (_state->localVars && _state->localVars->contains(name)) {
 				return (*_state->localVars)[name];
 			}
 			debugC(1, kDebugLingoExec, "varFetch: local variable %s not defined", name.c_str());




More information about the Scummvm-git-logs mailing list