[Scummvm-git-logs] scummvm master -> 3e6aa1d7ee0e7c48cf56e6ba704fa1a0ebb2bf2d

elasota noreply at scummvm.org
Sun Jul 14 05:14:42 UTC 2024


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:
3e6aa1d7ee MTROPOLIS: Fix write-disposition "parent" indirections resolving to the wrong object


Commit: 3e6aa1d7ee0e7c48cf56e6ba704fa1a0ebb2bf2d
    https://github.com/scummvm/scummvm/commit/3e6aa1d7ee0e7c48cf56e6ba704fa1a0ebb2bf2d
Author: elasota (1137273+elasota at users.noreply.github.com)
Date: 2024-07-14T01:14:25-04:00

Commit Message:
MTROPOLIS: Fix write-disposition "parent" indirections resolving to the wrong object

Changed paths:
    engines/mtropolis/runtime.cpp
    engines/mtropolis/runtime.h


diff --git a/engines/mtropolis/runtime.cpp b/engines/mtropolis/runtime.cpp
index 2f993e2d36d..11b2d881eef 100644
--- a/engines/mtropolis/runtime.cpp
+++ b/engines/mtropolis/runtime.cpp
@@ -2913,14 +2913,33 @@ MiniscriptInstructionOutcome RuntimeObject::ParentWriteProxyInterface::write(Min
 	return static_cast<RuntimeObject *>(objectRef)->scriptSetParent(thread, dest);
 }
 
+RuntimeObject *RuntimeObject::ParentWriteProxyInterface::resolveObjectParent(RuntimeObject *obj) {
+	if (obj->isStructural())
+		return static_cast<Structural *>(obj)->getParent();
+	else if (obj->isModifier())
+		return static_cast<Modifier *>(obj)->getParent().lock().get();
+
+	return nullptr;
+}
+
 MiniscriptInstructionOutcome RuntimeObject::ParentWriteProxyInterface::refAttrib(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib) {
+	RuntimeObject *parent = resolveObjectParent(static_cast<RuntimeObject *>(objectRef));
+
+	if (!parent)
+		return kMiniscriptInstructionOutcomeFailed;
+
 	DynamicValueWriteProxy tempProxy;
-	DynamicValueWriteObjectHelper::create(static_cast<RuntimeObject *>(objectRef), tempProxy);
+	DynamicValueWriteObjectHelper::create(static_cast<RuntimeObject *>(parent), tempProxy);
 
 	return tempProxy.pod.ifc->refAttrib(thread, proxy, tempProxy.pod.objectRef, tempProxy.pod.ptrOrOffset, attrib);
 }
 
 MiniscriptInstructionOutcome RuntimeObject::ParentWriteProxyInterface::refAttribIndexed(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib, const DynamicValue &index) {
+	RuntimeObject *parent = resolveObjectParent(static_cast<RuntimeObject *>(objectRef));
+
+	if (!parent)
+		return kMiniscriptInstructionOutcomeFailed;
+
 	DynamicValueWriteProxy tempProxy;
 	DynamicValueWriteObjectHelper::create(static_cast<RuntimeObject *>(objectRef), tempProxy);
 
diff --git a/engines/mtropolis/runtime.h b/engines/mtropolis/runtime.h
index 65e1730f5dc..9094c4e8be9 100644
--- a/engines/mtropolis/runtime.h
+++ b/engines/mtropolis/runtime.h
@@ -2085,6 +2085,9 @@ protected:
 		static MiniscriptInstructionOutcome write(MiniscriptThread *thread, const DynamicValue &dest, void *objectRef, uintptr ptrOrOffset);
 		static MiniscriptInstructionOutcome refAttrib(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib);
 		static MiniscriptInstructionOutcome refAttribIndexed(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib, const DynamicValue &index);
+
+	private:
+		static RuntimeObject *resolveObjectParent(RuntimeObject *obj);
 	};
 };
 




More information about the Scummvm-git-logs mailing list