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

npjg noreply at scummvm.org
Mon Jan 20 01:03:20 UTC 2025


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

Summary:
060b56b1f6 MEDIASTATION: Convert more script messages to use strings
73f6b57fa9 MEDIASTATION: Move variable setting logic into Variable itself
44dd29c4c6 MEDIASTATION: Add better error messsage for missing asset
34ece3d851 MEDIASTATION: Issue warning when trying to call method on null asset
c2f32ba43c MEDIASTATION: When calling method, get literal self object value first
c94629e78a MEDIASTATION: Implement asset ID equality checking
f5d0fc8b92 MEDIASTATION: Fix typo that led to operand comparisons always being true
571ed158ba MEDIASTATION: Make overloaded operand operators const
bfd1815ed0 MEDIASTATION: Implement image spatialHide method
de65d9805e MEDIASTATION: Implement Or opcode
a87633dbd7 MEDIASTATION: Understand keyframe-related fields in frame footers
e289b8f18f MEDIASTATION: Remedy memory leaks in destructors


Commit: 060b56b1f65b9b39b0b701f75dc8325f5169fd0c
    https://github.com/scummvm/scummvm/commit/060b56b1f65b9b39b0b701f75dc8325f5169fd0c
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-19T19:45:59-05:00

Commit Message:
MEDIASTATION: Convert more script messages to use strings

Changed paths:
    engines/mediastation/contextparameters.cpp
    engines/mediastation/mediascript/eventhandler.cpp
    engines/mediastation/mediascript/operand.cpp


diff --git a/engines/mediastation/contextparameters.cpp b/engines/mediastation/contextparameters.cpp
index 0434e3dd6d2..5b0a122e413 100644
--- a/engines/mediastation/contextparameters.cpp
+++ b/engines/mediastation/contextparameters.cpp
@@ -63,7 +63,7 @@ ContextParameters::ContextParameters(Chunk &chunk) : _contextName(nullptr) {
 				error("ContextParameters::ContextParameters(): Variable with ID 0x%x already exists", variable->_id);
 			} else {
 				g_engine->_variables.setVal(variable->_id, variable);
-				debugC(5, kDebugScript, "ContextParameters::ContextParameters(): Created global variable %d", variable->_id);
+				debugC(5, kDebugScript, "ContextParameters::ContextParameters(): Created global variable %d (type: %s)", variable->_id, variableTypeToStr(variable->_type));
 			}
 			break;
 		}
diff --git a/engines/mediastation/mediascript/eventhandler.cpp b/engines/mediastation/mediascript/eventhandler.cpp
index 8acb8839e98..bf12ed3949b 100644
--- a/engines/mediastation/mediascript/eventhandler.cpp
+++ b/engines/mediastation/mediascript/eventhandler.cpp
@@ -26,11 +26,14 @@ namespace MediaStation {
 
 EventHandler::EventHandler(Chunk &chunk) {
 	_type = static_cast<EventType>(Datum(chunk).u.i);
-	debugC(5, kDebugLoading, "EventHandler::EventHandler(): Type 0x%x (@0x%llx)", static_cast<uint>(_type), static_cast<long long int>(chunk.pos()));
+	debugC(5, kDebugLoading, "EventHandler::EventHandler(): Type %s (%d) (@0x%llx)", 
+		eventTypeToStr(_type), static_cast<uint>(_type), static_cast<long long int>(chunk.pos()));
+
 	_argumentType = static_cast<EventHandlerArgumentType>(Datum(chunk).u.i);
-	debugC(5, kDebugLoading, "EventHandler::EventHandler(): Argument type 0x%x (@0x%llx)", static_cast<uint>(_argumentType), static_cast<long long int>(chunk.pos()));
-	_argumentValue = Datum(chunk);
+	debugC(5, kDebugLoading, "EventHandler::EventHandler(): Argument type %s (%d) (@0x%llx)",
+		eventHandlerArgumentTypeToStr(_argumentType), static_cast<uint>(_argumentType), static_cast<long long int>(chunk.pos()));
 
+	_argumentValue = Datum(chunk);
 	if (_argumentType != kNullEventHandlerArgument) {
 		uint lengthInBytes = Datum(chunk, kDatumTypeUint32_1).u.i;
 		debugC(5, kDebugLoading, "EventHandler::EventHandler(): Null argument type, length = 0x%x (@0x%llx)", lengthInBytes, static_cast<long long int>(chunk.pos()));
diff --git a/engines/mediastation/mediascript/operand.cpp b/engines/mediastation/mediascript/operand.cpp
index f946e379ffb..838d347c822 100644
--- a/engines/mediastation/mediascript/operand.cpp
+++ b/engines/mediastation/mediascript/operand.cpp
@@ -40,7 +40,8 @@ void Operand::putInteger(int i) {
 	}
 
 	default: {
-		error("Operand::putInteger(): Attempt to put unsupported value into operand (type 0x%x)", static_cast<uint>(_type));
+		error("Operand::putInteger(): Attempt to put integer into operand type %s (%d)", 
+			operandTypeToStr(_type), static_cast<uint>(_type));
 	}
 	}
 }
@@ -58,7 +59,8 @@ int Operand::getInteger() {
 	}
 
 	default: {
-		error("Operand::getInteger(): Attempt to get unsupported value from operand (type 0x%x)", static_cast<uint>(_type));
+		error("Operand::getInteger(): Attempt to get integer from operand type %s (%d)",
+			operandTypeToStr(_type), static_cast<uint>(_type));
 	}
 	}
 }
@@ -78,7 +80,8 @@ void Operand::putDouble(double d) {
 	}
 
 	default: {
-		error("Operand::putDouble(): Attempt to put unsupported value in operand (type 0x%x)", static_cast<uint>(_type));
+		error("Operand::putDouble(): Attempt to put double into operand type %s (%d)", 
+			operandTypeToStr(_type), static_cast<uint>(_type));
 	}
 	}
 }
@@ -96,7 +99,8 @@ double Operand::getDouble() {
 	}
 
 	default: {
-		error("Operand::getDouble(): Attempt to get unsupported value from operand (type 0x%x)", static_cast<uint>(_type));
+		error("Operand::getDouble(): Attempt to get double from operand type %s (%d)",
+			operandTypeToStr(_type), static_cast<uint>(_type));
 	}
 	}
 }
@@ -115,7 +119,8 @@ void Operand::putString(Common::String *string) {
 	}
 
 	default: {
-		error("Operand::putString(): Attempt to put unsupported value into operand (type 0x%x)", static_cast<uint>(_type));
+		error("Operand::putString(): Attempt to put string into operand type %s (%d)", 
+			operandTypeToStr(_type), static_cast<uint>(_type));
 	}
 	}
 }
@@ -132,7 +137,8 @@ Common::String *Operand::getString() {
 	}
 
 	default: {
-		error("Operand::getString(): Attempt to get unsupported value from operand (type 0x%x)", static_cast<uint>(_type));
+		error("Operand::getString(): Attempt to get string from operand type %s (%d)",
+			operandTypeToStr(_type), static_cast<uint>(_type));
 	}
 	}
 }
@@ -145,7 +151,8 @@ void Operand::putVariable(Variable *variable) {
 	}
 
 	default: {
-		error("Operand::putVariable(): Attempt to put unsupported value into operand that is not a variable (type 0x%x)", static_cast<uint>(_type));
+		error("Operand::putVariable(): Attempt to put variable into operand type %s (%d)", 
+			operandTypeToStr(_type), static_cast<uint>(_type));
 	}
 	}
 }
@@ -157,7 +164,8 @@ Variable *Operand::getVariable() {
 	}
 
 	default: {
-		error("Operand::getVariable(): Attempt to get unsupported value from operand that is not a variable (type 0x%x)", static_cast<uint>(_type));
+		error("Operand::getVariable(): Attempt to get variable from operand type %s (%d)",
+			operandTypeToStr(_type), static_cast<uint>(_type));
 	}
 	}
 }
@@ -170,7 +178,8 @@ void Operand::putFunction(uint functionId) {
 	}
 
 	default: {
-		error("Operand::putFunction(): Attempt to put unsupported value into operand that is not a function (type 0x%x)", static_cast<uint>(_type));
+		error("Operand::putFunction(): Attempt to put function ID into operand type %s (%d)", 
+			operandTypeToStr(_type), static_cast<uint>(_type));
 	}
 	}
 }
@@ -182,7 +191,8 @@ uint Operand::getFunctionId() {
 	}
 
 	default: {
-		error("Operand::getFunction(): Attempt to get unsupported value from operand that is not a function (type 0x%x)", static_cast<uint>(_type));
+		error("Operand::getFunction(): Attempt to get function ID from operand type %s (%d)",
+			operandTypeToStr(_type), static_cast<uint>(_type));
 	}
 	}
 }
@@ -201,7 +211,8 @@ void Operand::putAsset(uint32 assetId) {
 	}
 
 	default: {
-		error("Operand::putAsset(): Attempt to put asset into operand that is not an asset (type 0x%x)", static_cast<uint>(_type));
+		error("Operand::putAsset(): Attempt to put asset ID into operand type %s (%d)", 
+			operandTypeToStr(_type), static_cast<uint>(_type));
 	}
 	}
 }
@@ -222,7 +233,8 @@ Asset *Operand::getAsset() {
 	}
 
 	default: {
-		error("Operand::getAsset(): Attempt to get asset from operand that is not an asset (type 0x%x)", static_cast<uint>(_type));
+		error("Operand::getAsset(): Attempt to get asset from operand type %s (%d)",
+			operandTypeToStr(_type), static_cast<uint>(_type));
 	}
 	}
 }
@@ -239,7 +251,8 @@ uint32 Operand::getAssetId() {
 	}
 
 	default: {
-		error("Operand::getAssetId(): Attempt to get asset ID from operand that is not an asset (type 0x%x)", static_cast<uint>(_type));
+		error("Operand::getAssetId(): Attempt to get asset ID from operand type %s (%d)",
+			operandTypeToStr(_type), static_cast<uint>(_type));
 	}
 	}
 }


Commit: 73f6b57fa92cb41de45432ad684ec814d1ceb55a
    https://github.com/scummvm/scummvm/commit/73f6b57fa92cb41de45432ad684ec814d1ceb55a
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-19T19:45:59-05:00

Commit Message:
MEDIASTATION: Move variable setting logic into Variable itself

Changed paths:
    engines/mediastation/mediascript/codechunk.cpp
    engines/mediastation/mediascript/variable.cpp
    engines/mediastation/mediascript/variable.h


diff --git a/engines/mediastation/mediascript/codechunk.cpp b/engines/mediastation/mediascript/codechunk.cpp
index fcd4280b6bc..dc1ca14cf76 100644
--- a/engines/mediastation/mediascript/codechunk.cpp
+++ b/engines/mediastation/mediascript/codechunk.cpp
@@ -308,46 +308,7 @@ void CodeChunk::putVariable(uint32 id, VariableScope scope, Operand value) {
 		if (variable == nullptr) {
 			error("CodeChunk::putVariable(): Attempted to assign to a non-existent global variable %d", id);
 		}
-
-		switch (value.getType()) {
-		case kOperandTypeEmpty: {
-			error("CodeChunk::putVariable(): Cannot assign an empty operand to a variable");
-			break;
-		}
-
-		case kOperandTypeLiteral1:
-		case kOperandTypeLiteral2: {
-			variable->_value.i = value.getInteger();
-			break;
-		}
-
-		case kOperandTypeFloat1:
-		case kOperandTypeFloat2: {
-			variable->_value.d = value.getDouble();
-			break;
-		}
-
-		case kOperandTypeString: {
-			variable->_value.string = value.getString();
-			break;
-		}
-
-		case kOperandTypeAssetId: {
-			variable->_value.assetId = value.getAssetId();
-			break;
-		}
-
-		case kOperandTypeVariableDeclaration: {
-			// TODO: Will this cause a memory leak?
-			// variable = value.u.variable;
-			error("Assigning variable to another variable not supported yet");
-			break;
-		}
-
-		default: {
-			error("CodeChunk::putVariable(): Cannot put operand type 0x%x into variable", (uint)value.getType());
-		}
-		}
+		variable->putValue(value);
 		break;
 	}
 
diff --git a/engines/mediastation/mediascript/variable.cpp b/engines/mediastation/mediascript/variable.cpp
index 715068b52e9..a7c1f93c118 100644
--- a/engines/mediastation/mediascript/variable.cpp
+++ b/engines/mediastation/mediascript/variable.cpp
@@ -163,6 +163,51 @@ Operand Variable::getValue() {
 	}
 }
 
+void Variable::putValue(Operand value) {
+	switch (value.getType()) {
+	case kOperandTypeEmpty: {
+		error("Variable::putValue(): Assigning an empty operand to a variable not supported");
+	}
+
+	case kOperandTypeLiteral1:
+	case kOperandTypeLiteral2:
+	case kOperandTypeDollarSignVariable: {
+		_type = kVariableTypeInt;
+		_value.i = value.getInteger();
+		break;
+	}
+
+	case kOperandTypeFloat1:
+	case kOperandTypeFloat2: {
+		_type = kVariableTypeFloat;
+		_value.d = value.getDouble();
+		break;
+	}
+
+	case kOperandTypeString: {
+		_type = kVariableTypeString;
+		_value.string = value.getString();
+		break;
+	}
+
+	case kOperandTypeAssetId: {
+		_type = kVariableTypeAssetId;
+		_value.assetId = value.getAssetId();
+		break;
+	}
+
+	case kOperandTypeVariableDeclaration: {
+		putValue(value.getLiteralValue());
+		break;
+	}
+
+	default: {
+		error("Variable::putValue(): Assigning an unknown operand type %s (%d) to a variable not supported",
+			operandTypeToStr(value.getType()), static_cast<uint>(value.getType()));
+	}
+	}
+}
+
 Operand Variable::callMethod(BuiltInMethod method, Common::Array<Operand> &args) {
 	switch (_type) {
 	case kVariableTypeAssetId: {
diff --git a/engines/mediastation/mediascript/variable.h b/engines/mediastation/mediascript/variable.h
index 766317f247a..2163970a548 100644
--- a/engines/mediastation/mediascript/variable.h
+++ b/engines/mediastation/mediascript/variable.h
@@ -50,6 +50,7 @@ public:
 	Variable(Chunk &chunk, bool readId = true);
 
 	Operand getValue();
+	void putValue(Operand value);
 	Operand callMethod(BuiltInMethod method, Common::Array<Operand> &args);
 	~Variable();
 };


Commit: 44dd29c4c69d326a116cf357598be515e5726606
    https://github.com/scummvm/scummvm/commit/44dd29c4c69d326a116cf357598be515e5726606
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-19T19:45:59-05:00

Commit Message:
MEDIASTATION: Add better error messsage for missing asset

Changed paths:
    engines/mediastation/mediascript/codechunk.cpp


diff --git a/engines/mediastation/mediascript/codechunk.cpp b/engines/mediastation/mediascript/codechunk.cpp
index dc1ca14cf76..9adda93b2d4 100644
--- a/engines/mediastation/mediascript/codechunk.cpp
+++ b/engines/mediastation/mediascript/codechunk.cpp
@@ -388,7 +388,9 @@ Operand CodeChunk::callBuiltInMethod(BuiltInMethod method, Operand self, Common:
 		} else {
 			// This is a regular asset that we can process directly.
 			Asset *selfAsset = self.getAsset();
-			assert(selfAsset != nullptr);
+			if (selfAsset == nullptr) {
+				error("CodeChunk::callBuiltInMethod(): Attempt to call method on asset ID %d, which isn't loaded", self.getAssetId());
+			}
 			Operand returnValue = selfAsset->callMethod(method, args);
 			return returnValue;
 		}


Commit: 34ece3d851b65fd6505760da3437c79fd71dc142
    https://github.com/scummvm/scummvm/commit/34ece3d851b65fd6505760da3437c79fd71dc142
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-19T19:45:59-05:00

Commit Message:
MEDIASTATION: Issue warning when trying to call method on null asset

Previously, we just errored when getting the null asset, but that wasn't correct.

Changed paths:
    engines/mediastation/mediascript/codechunk.cpp


diff --git a/engines/mediastation/mediascript/codechunk.cpp b/engines/mediastation/mediascript/codechunk.cpp
index 9adda93b2d4..50f26b4fbe7 100644
--- a/engines/mediastation/mediascript/codechunk.cpp
+++ b/engines/mediastation/mediascript/codechunk.cpp
@@ -385,6 +385,12 @@ Operand CodeChunk::callBuiltInMethod(BuiltInMethod method, Operand self, Common:
 			// just to house these methods. Rather, we just call in the engine.
 			Operand returnValue = g_engine->callMethod(method, args);
 			return returnValue;
+		} else if (self.getAssetId() == 0) {
+			// It seems to be valid to call a method on a null asset ID, in
+			// which case nothing happens. Still issue warning for traceability.
+			warning("CodeChunk::callBuiltInMethod(): Attempt to call method on a null asset ID");
+			return Operand();
+			break;
 		} else {
 			// This is a regular asset that we can process directly.
 			Asset *selfAsset = self.getAsset();


Commit: c2f32ba43c8641b019f464af8b37d874d72aa84f
    https://github.com/scummvm/scummvm/commit/c2f32ba43c8641b019f464af8b37d874d72aa84f
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-19T19:45:59-05:00

Commit Message:
MEDIASTATION: When calling method, get literal self object value first

This resolves any variable references before
we attempt to call the method. So we also don't
need a separate entry for assets in
Variable::callMethod

Changed paths:
    engines/mediastation/mediascript/codechunk.cpp
    engines/mediastation/mediascript/variable.cpp


diff --git a/engines/mediastation/mediascript/codechunk.cpp b/engines/mediastation/mediascript/codechunk.cpp
index 50f26b4fbe7..18393338aec 100644
--- a/engines/mediastation/mediascript/codechunk.cpp
+++ b/engines/mediastation/mediascript/codechunk.cpp
@@ -375,7 +375,9 @@ Operand CodeChunk::callBuiltInFunction(BuiltInFunction id, Common::Array<Operand
 }
 
 Operand CodeChunk::callBuiltInMethod(BuiltInMethod method, Operand self, Common::Array<Operand> &args) {
-	switch (self.getType()) {
+	Operand literalSelf = self.getLiteralValue();
+	OperandType literalType = literalSelf.getType();
+	switch (literalType) {
 	case kOperandTypeAssetId: {
 		if (self.getAssetId() == 1) {
 			// This is a "document" method that we need to handle specially.
@@ -402,16 +404,9 @@ Operand CodeChunk::callBuiltInMethod(BuiltInMethod method, Operand self, Common:
 		}
 	}
 
-	case kOperandTypeVariableDeclaration: {
-		Variable *variable = self.getVariable();
-		Operand returnValue = variable->callMethod(method, args);
-		return returnValue;
-		break;
-	}
-
 	default:
-		error("CodeChunk::callBuiltInMethod(): Attempt to call method on unsupported operand type %s (%d)", operandTypeToStr(self.getType()), static_cast<uint>(self.getType()));
-		break;
+		error("CodeChunk::callBuiltInMethod(): Attempt to call method on unsupported operand type %s (%d)", 
+			operandTypeToStr(literalType), static_cast<uint>(literalType));
 	}
 }
 
diff --git a/engines/mediastation/mediascript/variable.cpp b/engines/mediastation/mediascript/variable.cpp
index a7c1f93c118..c8b161c526f 100644
--- a/engines/mediastation/mediascript/variable.cpp
+++ b/engines/mediastation/mediascript/variable.cpp
@@ -210,11 +210,6 @@ void Variable::putValue(Operand value) {
 
 Operand Variable::callMethod(BuiltInMethod method, Common::Array<Operand> &args) {
 	switch (_type) {
-	case kVariableTypeAssetId: {
-		error("Variable::callMethod(): Calling method on an asset in a variable not implemented yet");
-		break;
-	}
-
 	case kVariableTypeCollection: {
 		// TODO: This is just a warning for now so we can get past the
 		// IBM/Crayola opening screen.


Commit: c94629e78a9ee55d01e570ac42071453bf1d43d7
    https://github.com/scummvm/scummvm/commit/c94629e78a9ee55d01e570ac42071453bf1d43d7
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-19T19:45:59-05:00

Commit Message:
MEDIASTATION: Implement asset ID equality checking

Changed paths:
    engines/mediastation/mediascript/operand.cpp


diff --git a/engines/mediastation/mediascript/operand.cpp b/engines/mediastation/mediascript/operand.cpp
index 838d347c822..fbd684112d0 100644
--- a/engines/mediastation/mediascript/operand.cpp
+++ b/engines/mediastation/mediascript/operand.cpp
@@ -285,6 +285,9 @@ bool Operand::operator==(Operand &other) {
 	case kOperandTypeString:
 		return *lhs.getString() == *rhs.getString();
 
+	case kOperandTypeAssetId:
+		return lhs.getAssetId() == rhs.getAssetId();
+
 	default:
 		error("Operand::operator==(): Unsupported operand types %d and %d", static_cast<uint>(lhs.getType()), static_cast<uint>(rhs.getType()));
 	}


Commit: f5d0fc8b9209411401ebdf7b076eb704ab28f762
    https://github.com/scummvm/scummvm/commit/f5d0fc8b9209411401ebdf7b076eb704ab28f762
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-19T19:45:59-05:00

Commit Message:
MEDIASTATION: Fix typo that led to operand comparisons always being true

Changed paths:
    engines/mediastation/mediascript/operand.cpp


diff --git a/engines/mediastation/mediascript/operand.cpp b/engines/mediastation/mediascript/operand.cpp
index fbd684112d0..7146f5696f3 100644
--- a/engines/mediastation/mediascript/operand.cpp
+++ b/engines/mediastation/mediascript/operand.cpp
@@ -269,7 +269,7 @@ Operand Operand::getLiteralValue() {
 
 bool Operand::operator==(Operand &other) {
 	Operand lhs = getLiteralValue();
-	Operand rhs = getLiteralValue();
+	Operand rhs = other.getLiteralValue();
 	// TODO: Maybe some better type checking here. If the types being compared end up being incompatible, the respective get
 	// method on the rhs will raise the error. But better might be checking
 	// both before we try getting values to report a more descriptive error.
@@ -295,7 +295,7 @@ bool Operand::operator==(Operand &other) {
 
 bool Operand::operator>=(Operand &other) {
 	Operand lhs = getLiteralValue();
-	Operand rhs = getLiteralValue();
+	Operand rhs = other.getLiteralValue();
 	// If the types being compared end up being incompatible, the respective get
 	// method on the rhs will raise the error.
 	switch (lhs.getType()) {


Commit: 571ed158ba579cab5e5f32776cdbe24abeae525a
    https://github.com/scummvm/scummvm/commit/571ed158ba579cab5e5f32776cdbe24abeae525a
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-19T19:45:59-05:00

Commit Message:
MEDIASTATION: Make overloaded operand operators const

Changed paths:
    engines/mediastation/mediascript/operand.cpp
    engines/mediastation/mediascript/operand.h


diff --git a/engines/mediastation/mediascript/operand.cpp b/engines/mediastation/mediascript/operand.cpp
index 7146f5696f3..626cbd42421 100644
--- a/engines/mediastation/mediascript/operand.cpp
+++ b/engines/mediastation/mediascript/operand.cpp
@@ -257,7 +257,7 @@ uint32 Operand::getAssetId() {
 	}
 }
 
-Operand Operand::getLiteralValue() {
+Operand Operand::getLiteralValue() const {
 	// This function dereferences any variable to get the actual
 	// "direct" value (a literal asset ID or otherwise).
 	if (_type == kOperandTypeVariableDeclaration) {
@@ -267,7 +267,7 @@ Operand Operand::getLiteralValue() {
 	}
 }
 
-bool Operand::operator==(Operand &other) {
+bool Operand::operator==(const Operand &other) const {
 	Operand lhs = getLiteralValue();
 	Operand rhs = other.getLiteralValue();
 	// TODO: Maybe some better type checking here. If the types being compared end up being incompatible, the respective get
@@ -293,7 +293,7 @@ bool Operand::operator==(Operand &other) {
 	}
 }
 
-bool Operand::operator>=(Operand &other) {
+bool Operand::operator>=(const Operand &other) const {
 	Operand lhs = getLiteralValue();
 	Operand rhs = other.getLiteralValue();
 	// If the types being compared end up being incompatible, the respective get
@@ -326,7 +326,7 @@ Operand Operand::operator-(const Operand &other) const {
 	return returnValue;
 }
 
-Operand Operand::operator-() {
+Operand Operand::operator-() const {
 	Operand literalValue = getLiteralValue();
 	Operand returnValue(literalValue.getType());
 	// If the types being compared end up being incompatible, the respective get
diff --git a/engines/mediastation/mediascript/operand.h b/engines/mediastation/mediascript/operand.h
index d0276e2fbf5..c3ac8391d4f 100644
--- a/engines/mediastation/mediascript/operand.h
+++ b/engines/mediastation/mediascript/operand.h
@@ -59,13 +59,13 @@ public:
 	Asset *getAsset();
 	uint32 getAssetId();
 
-	Operand getLiteralValue();
+	Operand getLiteralValue() const;
 
-	bool operator==(Operand &other);
-	bool operator>=(Operand &other);
+	bool operator==(const Operand &other) const;
+	bool operator>=(const Operand &other) const;
 
 	Operand operator-(const Operand &other) const;
-	Operand operator-();
+	Operand operator-() const;
 
 private:
 	OperandType _type = kOperandTypeEmpty;


Commit: bfd1815ed081d9f5540fa28e5c7c4ec165d94ca7
    https://github.com/scummvm/scummvm/commit/bfd1815ed081d9f5540fa28e5c7c4ec165d94ca7
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-19T19:45:59-05:00

Commit Message:
MEDIASTATION: Implement image spatialHide method

Changed paths:
    engines/mediastation/assets/image.cpp


diff --git a/engines/mediastation/assets/image.cpp b/engines/mediastation/assets/image.cpp
index 86b232f9d2e..89fe6266b36 100644
--- a/engines/mediastation/assets/image.cpp
+++ b/engines/mediastation/assets/image.cpp
@@ -39,6 +39,13 @@ Operand Image::callMethod(BuiltInMethod methodId, Common::Array<Operand> &args)
 		break;
 	}
 
+	case kSpatialHideMethod: {
+		assert(args.empty());
+		_isActive = false;
+		return Operand();
+		break;
+	}
+
 	default: {
 		error("Image::callMethod(): Got unimplemented method ID %d", methodId);
 	}


Commit: de65d9805e7ecb2a8b939fa431bde4e30a064535
    https://github.com/scummvm/scummvm/commit/de65d9805e7ecb2a8b939fa431bde4e30a064535
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-19T19:45:59-05:00

Commit Message:
MEDIASTATION: Implement Or opcode

Changed paths:
    engines/mediastation/mediascript/codechunk.cpp
    engines/mediastation/mediascript/operand.cpp
    engines/mediastation/mediascript/operand.h


diff --git a/engines/mediastation/mediascript/codechunk.cpp b/engines/mediastation/mediascript/codechunk.cpp
index 18393338aec..38f5382374c 100644
--- a/engines/mediastation/mediascript/codechunk.cpp
+++ b/engines/mediastation/mediascript/codechunk.cpp
@@ -130,6 +130,18 @@ Operand CodeChunk::executeNextStatement() {
 			return Operand();
 		}
 
+		case kOpcodeOr: {
+			debugCN(5, kDebugScript, "\n    lhs: ");
+			Operand value1 = executeNextStatement();
+			debugCN(5, kDebugScript, "    rhs: ");
+			Operand value2 = executeNextStatement();
+
+			Operand returnValue(kOperandTypeLiteral1);
+			bool logicalOr = (value1 || value2);
+			returnValue.putInteger(static_cast<uint>(logicalOr));
+			return returnValue;
+		}
+
 		case kOpcodeSubtract: {
 			debugCN(5, kDebugScript, "\n    lhs: ");
 			Operand value1 = executeNextStatement();
diff --git a/engines/mediastation/mediascript/operand.cpp b/engines/mediastation/mediascript/operand.cpp
index 626cbd42421..367dd36724c 100644
--- a/engines/mediastation/mediascript/operand.cpp
+++ b/engines/mediastation/mediascript/operand.cpp
@@ -312,6 +312,21 @@ bool Operand::operator>=(const Operand &other) const {
 	}
 }
 
+bool Operand::operator||(const Operand &other) const {
+	Operand lhs = getLiteralValue();
+	Operand rhs = other.getLiteralValue();
+	// If the types being compared end up being incompatible, the respective get
+	// method on the rhs will raise the error.
+	switch (lhs.getType()) {
+	case kOperandTypeLiteral1: 
+	case kOperandTypeLiteral2:
+		return lhs.getInteger() || rhs.getInteger();
+
+	default:
+		error("Operand::operator||(): Unsupported operand types %s and %s", operandTypeToStr(lhs.getType()), operandTypeToStr(rhs.getType()));
+	}
+}
+
 Operand Operand::operator-(const Operand &other) const {
 	Operand returnValue;
 	if (this->_type == kOperandTypeLiteral1 && other._type == kOperandTypeLiteral1) {
diff --git a/engines/mediastation/mediascript/operand.h b/engines/mediastation/mediascript/operand.h
index c3ac8391d4f..4c8b1c35135 100644
--- a/engines/mediastation/mediascript/operand.h
+++ b/engines/mediastation/mediascript/operand.h
@@ -63,6 +63,7 @@ public:
 
 	bool operator==(const Operand &other) const;
 	bool operator>=(const Operand &other) const;
+	bool operator||(const Operand &other) const;
 
 	Operand operator-(const Operand &other) const;
 	Operand operator-() const;


Commit: a87633dbd789548d531575ca9bb6ba8a8bf7fe0d
    https://github.com/scummvm/scummvm/commit/a87633dbd789548d531575ca9bb6ba8a8bf7fe0d
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-19T19:45:59-05:00

Commit Message:
MEDIASTATION: Understand keyframe-related fields in frame footers

Also, some debug statements related to these fields are improved.

Changed paths:
    engines/mediastation/assets/movie.cpp
    engines/mediastation/assets/movie.h


diff --git a/engines/mediastation/assets/movie.cpp b/engines/mediastation/assets/movie.cpp
index 7980cb5a2e2..753ac544fd2 100644
--- a/engines/mediastation/assets/movie.cpp
+++ b/engines/mediastation/assets/movie.cpp
@@ -53,13 +53,21 @@ MovieFrameFooter::MovieFrameFooter(Chunk &chunk) {
 		_left = Datum(chunk).u.i;
 		_top = Datum(chunk).u.i;
 		_zIndex = Datum(chunk).u.i;
-		_unk6 = Datum(chunk).u.i;
-		_unk7 = Datum(chunk).u.i;
+		// This represents the difference between the left coordinate of the
+		// keyframe (if applicable) and the left coordinate of this frame. Zero
+		// if there is no keyframe.
+		_diffBetweenKeyframeAndFrameX = Datum(chunk).u.i;
+		// This represents the difference between the top coordinate of the
+		// keyframe (if applicable) and the top coordinate of this frame. Zero
+		// if there is no keyframe.
+		_diffBetweenKeyframeAndFrameY = Datum(chunk).u.i;
 		_index = Datum(chunk).u.i;
-		_unk8 = Datum(chunk).u.i;
+		_keyframeIndex = Datum(chunk).u.i;
 		_unk9 = Datum(chunk).u.i;
-		debugC(5, kDebugLoading, "MovieFrameFooter::MovieFrameFooter(): _startInMilliseconds = 0x%x, _endInMilliseconds = 0x%x, _left = 0x%x, _top = 0x%x, _index = 0x%x (@0x%llx)", _startInMilliseconds, _endInMilliseconds, _left, _top, _index, static_cast<long long int>(chunk.pos()));
-		debugC(5, kDebugLoading, "MovieFrameFooter::MovieFrameFooter(): _unk4 = 0x%x, _unk5 = 0x%x, _unk6 = 0x%x, _unk7 = 0x%x, _unk8 = 0x%x, _unk9 = 0x%x", _unk4, _zIndex, _unk6, _unk7, _unk8, _unk9);
+		debugC(5, kDebugLoading, "MovieFrameFooter::MovieFrameFooter(): _startInMilliseconds = %d, _endInMilliseconds = %d, _left = %d, _top = %d, _index = %d, _keyframeIndex = %d (@0x%llx)", 
+			_startInMilliseconds, _endInMilliseconds, _left, _top, _index, _keyframeIndex, static_cast<long long int>(chunk.pos()));
+		debugC(5, kDebugLoading, "MovieFrameFooter::MovieFrameFooter(): _zIndex = %d, _diffBetweenKeyframeAndFrameX = %d, _diffBetweenKeyframeAndFrameY = %d, _unk4 = %d, _unk9 = %d",
+			_zIndex, _diffBetweenKeyframeAndFrameX, _diffBetweenKeyframeAndFrameY, _unk4,_unk9);
 	}
 }
 
diff --git a/engines/mediastation/assets/movie.h b/engines/mediastation/assets/movie.h
index 0fabcab5ff3..ec57c473ea6 100644
--- a/engines/mediastation/assets/movie.h
+++ b/engines/mediastation/assets/movie.h
@@ -54,9 +54,9 @@ public:
 	uint _unk3 = 0;
 	uint _unk4 = 0;
 	uint _zIndex = 0; // TODO: This is still unconfirmed but seems likely.
-	uint _unk6 = 0;
-	uint _unk7 = 0;
-	uint _unk8 = 0;
+	uint _diffBetweenKeyframeAndFrameX = 0;
+	uint _diffBetweenKeyframeAndFrameY = 0;
+	uint _keyframeIndex = 0;
 	uint _unk9 = 0;
 	uint _index = 0;
 };


Commit: e289b8f18f17aae623ddfc15e8e024cb8972cdd4
    https://github.com/scummvm/scummvm/commit/e289b8f18f17aae623ddfc15e8e024cb8972cdd4
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-19T19:45:59-05:00

Commit Message:
MEDIASTATION: Remedy memory leaks in destructors

Many of these were due to pointer arrays and
hashmaps not being cleared upon destruction.

Changed paths:
    engines/mediastation/assetheader.cpp
    engines/mediastation/assets/font.cpp
    engines/mediastation/assets/movie.cpp
    engines/mediastation/assets/sprite.cpp
    engines/mediastation/boot.cpp
    engines/mediastation/context.cpp
    engines/mediastation/mediascript/variable.cpp


diff --git a/engines/mediastation/assetheader.cpp b/engines/mediastation/assetheader.cpp
index 4c36c20c644..6c7ac8a1b6a 100644
--- a/engines/mediastation/assetheader.cpp
+++ b/engines/mediastation/assetheader.cpp
@@ -45,12 +45,52 @@ AssetHeader::AssetHeader(Chunk &chunk) {
 
 AssetHeader::~AssetHeader() {
 	delete _boundingBox;
+	_boundingBox = nullptr;
+
+	for (Common::Point *point : _mouseActiveArea) {
+		delete point;
+	}
 	_mouseActiveArea.clear();
+
+	for (auto it = _eventHandlers.begin(); it != _eventHandlers.end(); ++it) {
+		delete it->_value;
+	}
+	_eventHandlers.clear();
+
+	for (EventHandler *timeHandler : _timeHandlers) {
+		delete timeHandler;
+	}
+	_timeHandlers.clear();
+
+	for (auto it = _keyDownHandlers.begin(); it != _keyDownHandlers.end(); ++it) {
+		delete it->_value;
+	}
+	_keyDownHandlers.clear();
+
+	for (EventHandler *inputHandler : _inputHandlers) {
+		delete inputHandler;
+	}
+	_inputHandlers.clear();
+
+	for (EventHandler *loadCompleteHandler : _loadCompleteHandlers) {
+		delete loadCompleteHandler;
+	}
+	_loadCompleteHandlers.clear();
+
 	delete _palette;
+	_palette = nullptr;
+
 	delete _name;
+	_name = nullptr;
+	
 	delete _startPoint;
+	_startPoint = nullptr;
+
 	delete _endPoint;
+	_endPoint = nullptr;
+
 	delete _text;
+	_text = nullptr;
 }
 
 void AssetHeader::readSection(AssetHeaderSectionType sectionType, Chunk& chunk) {
diff --git a/engines/mediastation/assets/font.cpp b/engines/mediastation/assets/font.cpp
index 3f753356326..b4ebc531ce2 100644
--- a/engines/mediastation/assets/font.cpp
+++ b/engines/mediastation/assets/font.cpp
@@ -31,6 +31,9 @@ FontGlyph::FontGlyph(Chunk &chunk, uint asciiCode, uint unk1, uint unk2, BitmapH
 }
 
 Font::~Font() {
+    for (auto it = _glyphs.begin(); it != _glyphs.end(); ++it) {
+        delete it->_value;
+    }
     _glyphs.clear();
 }
 
diff --git a/engines/mediastation/assets/movie.cpp b/engines/mediastation/assets/movie.cpp
index 753ac544fd2..4000c3a567b 100644
--- a/engines/mediastation/assets/movie.cpp
+++ b/engines/mediastation/assets/movie.cpp
@@ -161,15 +161,21 @@ MovieFrame::~MovieFrame() {
 }
 
 Movie::~Movie() {
-	for (MovieFrame *frame : _stills) {
-		delete frame;
-	}
-	_stills.clear();
 	for (MovieFrame *frame : _frames) {
 		delete frame;
 	}
 	_frames.clear();
+
+	for (MovieFrame *still : _stills) {
+		delete still;
+	}
+	_stills.clear();
+
+	for (Audio::SeekableAudioStream *stream : _audioStreams) {
+		delete stream;
+	}
 	_audioStreams.clear();
+
 	for (MovieFrameFooter *footer : _footers) {
 		delete footer;
 	}
@@ -218,7 +224,7 @@ void Movie::timePlay() {
 	if (!_audioStreams.empty()) {
 		Audio::QueuingAudioStream *audio = Audio::makeQueuingAudioStream(22050, false);
 		for (Audio::SeekableAudioStream *stream : _audioStreams) {
-			audio->queueAudioStream(stream);
+			audio->queueAudioStream(stream, DisposeAfterUse::NO);
 		}
 		// Then play the audio!
 		Audio::SoundHandle handle;
@@ -409,7 +415,7 @@ void Movie::readSubfile(Subfile &subfile, Chunk &chunk) {
 			Audio::SeekableAudioStream *stream = nullptr;
 			switch (_header->_soundEncoding) {
 			case SoundEncoding::PCM_S16LE_MONO_22050:
-				stream = Audio::makeRawStream(buffer, chunk._length, 22050, Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN, DisposeAfterUse::YES);
+				stream = Audio::makeRawStream(buffer, chunk._length, 22050, Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN, DisposeAfterUse::NO);
 				break;
 
 			case SoundEncoding::IMA_ADPCM_S16LE_MONO_22050:
diff --git a/engines/mediastation/assets/sprite.cpp b/engines/mediastation/assets/sprite.cpp
index 136bd58b3d2..f8f5b246926 100644
--- a/engines/mediastation/assets/sprite.cpp
+++ b/engines/mediastation/assets/sprite.cpp
@@ -67,6 +67,9 @@ uint32 SpriteFrame::index() {
 }
 
 Sprite::~Sprite() {
+	for (SpriteFrame *frame : _frames) {
+		delete frame;
+	}
 	_frames.clear();
 }
 
diff --git a/engines/mediastation/boot.cpp b/engines/mediastation/boot.cpp
index 4427ea86987..1301ba77c7f 100644
--- a/engines/mediastation/boot.cpp
+++ b/engines/mediastation/boot.cpp
@@ -444,10 +444,32 @@ Boot::~Boot() {
 	delete _versionInfo;
 	_versionInfo = nullptr;
 
+	delete _sourceString;
+	_sourceString = nullptr;
+
+	for (auto it = _contextDeclarations.begin(); it != _contextDeclarations.end(); ++it) {
+		delete it->_value;
+	}
 	_contextDeclarations.clear();
+
+	for (auto it = _subfileDeclarations.begin(); it != _subfileDeclarations.end(); ++it) {
+		delete it->_value;
+	}
 	_subfileDeclarations.clear();
+
+	for (auto it = _cursorDeclarations.begin(); it != _cursorDeclarations.end(); ++it) {
+		delete it->_value;
+	}
 	_cursorDeclarations.clear();
+
+	for (auto it = _engineResourceDeclarations.begin(); it != _engineResourceDeclarations.end(); ++it) {
+		delete it->_value;
+	}
 	_engineResourceDeclarations.clear();
+
+	for (auto unknownDeclaration : _unknownDeclarations) {
+		delete unknownDeclaration;
+	}
 	_unknownDeclarations.clear();
 }
 #pragma endregion
diff --git a/engines/mediastation/context.cpp b/engines/mediastation/context.cpp
index a9936995ddd..c36f2e6bc71 100644
--- a/engines/mediastation/context.cpp
+++ b/engines/mediastation/context.cpp
@@ -73,8 +73,21 @@ Context::Context(const Common::Path &path) :
 Context::~Context() {
 	delete _palette;
 	_palette = nullptr;
+
 	delete _parameters;
 	_parameters = nullptr;
+
+	for (auto it = _assets.begin(); it != _assets.end(); ++it) {
+		delete it->_value;
+	}
+	_assets.clear();
+	// The same asset pointers are in here, so don't delete again.
+	_assetsByChunkReference.clear();
+
+	for (auto it = _functions.begin(); it != _functions.end(); ++it) {
+		delete it->_value;
+	}
+	_functions.clear();
 }
 
 Asset *Context::getAssetById(uint assetId) {
diff --git a/engines/mediastation/mediascript/variable.cpp b/engines/mediastation/mediascript/variable.cpp
index c8b161c526f..f1b647464d5 100644
--- a/engines/mediastation/mediascript/variable.cpp
+++ b/engines/mediastation/mediascript/variable.cpp
@@ -96,12 +96,10 @@ Variable::Variable(Chunk &chunk, bool readId) {
 
 Variable::~Variable() {
 	switch (_type) {
-	case kVariableTypeAssetId:
-	case kVariableTypeBoolean: {
-		break;
-	}
-
 	case kVariableTypeCollection: {
+		for (Variable *variable : *(_value.collection)) {
+			delete variable;
+		}
 		delete _value.collection;
 		break;
 	}




More information about the Scummvm-git-logs mailing list