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

elasota noreply at scummvm.org
Tue Aug 13 03:48:46 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:
c2317068aa MTROPOLIS: Add scene unloading


Commit: c2317068aa79183b5eb3519c5e70034f07c833a0
    https://github.com/scummvm/scummvm/commit/c2317068aa79183b5eb3519c5e70034f07c833a0
Author: elasota (1137273+elasota at users.noreply.github.com)
Date: 2024-08-12T23:48:30-04:00

Commit Message:
MTROPOLIS: Add scene unloading

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


diff --git a/engines/mtropolis/runtime.cpp b/engines/mtropolis/runtime.cpp
index 46f5c0ee7b3..1e4fd566bba 100644
--- a/engines/mtropolis/runtime.cpp
+++ b/engines/mtropolis/runtime.cpp
@@ -3578,7 +3578,7 @@ MiniscriptInstructionOutcome Structural::writeRefAttribute(MiniscriptThread *thr
 		DynamicValueWriteIntegerHelper<int32>::create(&_flushPriority, result);
 		return kMiniscriptInstructionOutcomeContinue;
 	} else if (attrib == "unload") {
-		DynamicValueWriteDiscardHelper::create(result);
+		DynamicValueWriteFuncHelper<Structural, &Structural::scriptSetUnload, false>::create(this, result);
 		return kMiniscriptInstructionOutcomeContinue;
 	}
 
@@ -4004,6 +4004,14 @@ MiniscriptInstructionOutcome Structural::scriptSetDebug(MiniscriptThread *thread
 	return kMiniscriptInstructionOutcomeContinue;
 }
 
+MiniscriptInstructionOutcome Structural::scriptSetUnload(MiniscriptThread *thread, const DynamicValue &value) {
+	// Doesn't matter what value this is set to, it always tries to unload.
+	if (_sceneLoadState != SceneLoadState::kNotAScene)
+		thread->getRuntime()->addSceneStateTransition(HighLevelSceneTransition(getSelfReference().lock().staticCast<Structural>(), HighLevelSceneTransition::kTypeRequestUnloadScene, false, false));
+
+	return kMiniscriptInstructionOutcomeContinue;
+}
+
 VolumeState::VolumeState() : volumeID(0), isMounted(false) {
 }
 
@@ -5811,6 +5819,18 @@ void Runtime::executeHighLevelSceneTransition(const HighLevelSceneTransition &tr
 			queueEventAsLowLevelSceneStateTransitionAction(Event(EventIDs::kParentEnabled, 0), transition.scene.get(), true, true);
 			queueEventAsLowLevelSceneStateTransitionAction(Event(EventIDs::kSceneStarted, 0), transition.scene.get(), true, true);
 		} break;
+	case HighLevelSceneTransition::kTypeRequestUnloadScene: {
+			bool isActiveScene = false;
+			for (const SceneStackEntry &stackEntry : _sceneStack) {
+				if (stackEntry.scene == transition.scene) {
+					isActiveScene = true;
+					break;
+				}
+			}
+
+			if (!isActiveScene)
+				_pendingLowLevelTransitions.push_back(LowLevelSceneStateTransitionAction(transition.scene, LowLevelSceneStateTransitionAction::kUnload));
+		} break;
 	default:
 		error("Unknown high-level scene transition type");
 		break;
diff --git a/engines/mtropolis/runtime.h b/engines/mtropolis/runtime.h
index 9079d65d7f8..14a0ae3a5b4 100644
--- a/engines/mtropolis/runtime.h
+++ b/engines/mtropolis/runtime.h
@@ -1366,6 +1366,7 @@ struct HighLevelSceneTransition {
 		kTypeChangeToScene,
 		kTypeChangeSharedScene,
 		kTypeForceLoadScene,
+		kTypeRequestUnloadScene,
 	};
 
 	HighLevelSceneTransition(const Common::SharedPtr<Structural> &hlst_scene, Type hlst_type, bool hlst_addToDestinationScene, bool hlst_addToReturnList);
@@ -2268,6 +2269,7 @@ protected:
 	MiniscriptInstructionOutcome scriptSetPaused(MiniscriptThread *thread, const DynamicValue &value);
 	MiniscriptInstructionOutcome scriptSetLoop(MiniscriptThread *thread, const DynamicValue &value);
 	MiniscriptInstructionOutcome scriptSetDebug(MiniscriptThread *thread, const DynamicValue &value);
+	MiniscriptInstructionOutcome scriptSetUnload(MiniscriptThread *thread, const DynamicValue &value);
 
 	// If you override this, you must override visitInternalReferences too.
 	virtual void linkInternalReferences(ObjectLinkingScope *outerScope);




More information about the Scummvm-git-logs mailing list