[Scummvm-git-logs] scummvm master -> 592626ee4df5586a51423472791193cb067c4833

elasota noreply at scummvm.org
Tue Aug 13 03:18:03 UTC 2024


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

Summary:
e1860a2088 MTROPOLIS: Add some scene hot loading support
07d303a38b MTROPOLIS: Add name auto-set for elements, always activate hot-loaded objects
f719c001ee MTROPOLIS: Remove SPQR hacks
2ffacef65f MTROPOLIS: Add scene hot loading during message propagation
592626ee4d MTROPOLIS: Fix modifiers not being hot loaded.  Fix double-activation.


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

Commit Message:
MTROPOLIS: Add some scene hot loading support

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


diff --git a/engines/mtropolis/plugin/standard.cpp b/engines/mtropolis/plugin/standard.cpp
index abe6f300f9c..2fa5a21f8e0 100644
--- a/engines/mtropolis/plugin/standard.cpp
+++ b/engines/mtropolis/plugin/standard.cpp
@@ -637,7 +637,7 @@ void ObjectReferenceVariableModifier::resolve(Runtime *runtime) {
 	if (storage->_objectPath[0] == '/')
 		resolveAbsolutePath(runtime);
 	else if (storage->_objectPath[0] == '.')
-		resolveRelativePath(this, storage->_objectPath, 0);
+		resolveRelativePath(runtime, this, storage->_objectPath, 0);
 	else
 		warning("Object reference variable had an unknown path format");
 
@@ -648,7 +648,7 @@ void ObjectReferenceVariableModifier::resolve(Runtime *runtime) {
 	}
 }
 
-void ObjectReferenceVariableModifier::resolveRelativePath(RuntimeObject *obj, const Common::String &path, size_t startPos) {
+void ObjectReferenceVariableModifier::resolveRelativePath(Runtime *runtime, RuntimeObject *obj, const Common::String &path, size_t startPos) {
 	ObjectReferenceVariableStorage *storage = static_cast<ObjectReferenceVariableStorage *>(_storage.get());
 
 	bool haveNextLevel = true;
@@ -681,6 +681,10 @@ void ObjectReferenceVariableModifier::resolveRelativePath(RuntimeObject *obj, co
 
 		if (obj->isStructural()) {
 			Structural *structural = static_cast<Structural *>(obj);
+
+			if (structural->getSceneLoadState() == Structural::SceneLoadState::kSceneNotLoaded)
+				runtime->hotLoadScene(structural);
+
 			modifierChildren = &structural->getModifiers();
 			structuralChildren = &structural->getChildren();
 		} else if (obj->isModifier()) {
@@ -769,7 +773,7 @@ void ObjectReferenceVariableModifier::resolveAbsolutePath(Runtime *runtime) {
 	if (storage->_objectPath[prefixEnd] != '/')
 		return;
 
-	return resolveRelativePath(project, storage->_objectPath, prefixEnd + 1);
+	return resolveRelativePath(runtime, project, storage->_objectPath, prefixEnd + 1);
 }
 
 bool ObjectReferenceVariableModifier::computeObjectPath(RuntimeObject *obj, Common::String &outPath) {
diff --git a/engines/mtropolis/plugin/standard.h b/engines/mtropolis/plugin/standard.h
index ab45b6c3d55..128b891d051 100644
--- a/engines/mtropolis/plugin/standard.h
+++ b/engines/mtropolis/plugin/standard.h
@@ -201,7 +201,7 @@ private:
 	MiniscriptInstructionOutcome scriptObjectRefAttribIndexed(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, const Common::String &attrib, const DynamicValue &index);
 
 	void resolve(Runtime *runtime);
-	void resolveRelativePath(RuntimeObject *obj, const Common::String &path, size_t startPos);
+	void resolveRelativePath(Runtime *runtime, RuntimeObject *obj, const Common::String &path, size_t startPos);
 	void resolveAbsolutePath(Runtime *runtime);
 
 	static bool computeObjectPath(RuntimeObject *obj, Common::String &outPath);
diff --git a/engines/mtropolis/runtime.cpp b/engines/mtropolis/runtime.cpp
index 7e95247aff9..0865ef121ac 100644
--- a/engines/mtropolis/runtime.cpp
+++ b/engines/mtropolis/runtime.cpp
@@ -3301,12 +3301,19 @@ ProjectPresentationSettings::ProjectPresentationSettings() : width(640), height(
 Structural::Structural() : Structural(nullptr) {
 }
 
-Structural::Structural(Runtime *runtime) : _parent(nullptr), _paused(false), _loop(false), _flushPriority(0), _runtime(runtime) {
+Structural::Structural(Runtime *runtime)
+	: _parent(nullptr)
+	, _paused(false)
+	, _loop(false)
+	, _flushPriority(0)
+	, _runtime(runtime)
+	, _sceneLoadState(SceneLoadState::kNotAScene) {
 }
 
 Structural::Structural(const Structural &other)
 	: RuntimeObject(other), Debuggable(other), _parent(other._parent), _children(other._children), _modifiers(other._modifiers), _name(other._name), _assets(other._assets)
-	, _paused(other._paused), _loop(other._loop), _flushPriority(other._flushPriority)/*, _hooks(other._hooks)*/, _runtime(other._runtime) {
+	, _paused(other._paused), _loop(other._loop), _flushPriority(other._flushPriority)/*, _hooks(other._hooks)*/, _runtime(other._runtime)
+	, _sceneLoadState(SceneLoadState::kNotAScene) {
 }
 
 Structural::~Structural() {
@@ -3332,6 +3339,15 @@ bool Structural::isStructural() const {
 	return true;
 }
 
+Structural::SceneLoadState Structural::getSceneLoadState() const {
+	return _sceneLoadState;
+}
+
+void Structural::setSceneLoadState(SceneLoadState sceneLoadState) {
+	_sceneLoadState = sceneLoadState;
+}
+
+
 bool Structural::readAttribute(MiniscriptThread *thread, DynamicValue &result, const Common::String &attrib) {
 	if (attrib == "name") {
 		result.setString(_name);
@@ -3488,6 +3504,16 @@ bool Structural::readAttribute(MiniscriptThread *thread, DynamicValue &result, c
 		return true;
 	}
 
+	if (RuntimeObject::readAttribute(thread, result, attrib))
+		return true;
+
+	if (_sceneLoadState == Structural::SceneLoadState::kSceneNotLoaded) {
+#ifdef MTROPOLIS_DEBUG_ENABLE
+		if (Debugger *debugger = thread->getRuntime()->debugGetDebugger())
+			debugger->notify(kDebugSeverityError, "Hot-loading scenes is not yet implemented (readAttribute)");
+#endif
+	}
+
 	// Traverse children (modifiers must be first)
 	for (const Common::SharedPtr<Modifier> &modifier : _modifiers) {
 		if (caseInsensitiveEqual(modifier->getName(), attrib)) {
@@ -3503,7 +3529,7 @@ bool Structural::readAttribute(MiniscriptThread *thread, DynamicValue &result, c
 		}
 	}
 
-	return RuntimeObject::readAttribute(thread, result, attrib);
+	return false;
 }
 
 MiniscriptInstructionOutcome Structural::writeRefAttribute(MiniscriptThread *thread, DynamicValueWriteProxy &result, const Common::String &attrib) {
@@ -3551,6 +3577,9 @@ MiniscriptInstructionOutcome Structural::writeRefAttribute(MiniscriptThread *thr
 	} else if (attrib == "flushpriority") {
 		DynamicValueWriteIntegerHelper<int32>::create(&_flushPriority, result);
 		return kMiniscriptInstructionOutcomeContinue;
+	} else if (attrib == "unload") {
+		DynamicValueWriteDiscardHelper::create(result);
+		return kMiniscriptInstructionOutcomeContinue;
 	}
 
 	// Attempt to resolve as a child object
@@ -3574,6 +3603,13 @@ MiniscriptInstructionOutcome Structural::writeRefAttribute(MiniscriptThread *thr
 
 bool Structural::readAttributeIndexed(MiniscriptThread *thread, DynamicValue &result, const Common::String &attrib, const DynamicValue &index) {
 	if (attrib == "nthelement") {
+		if (_sceneLoadState == Structural::SceneLoadState::kSceneNotLoaded) {
+#ifdef MTROPOLIS_DEBUG_ENABLE
+			if (Debugger *debugger = thread->getRuntime()->debugGetDebugger())
+				debugger->notify(kDebugSeverityError, "Hot-loading scenes is not yet implemented (readAttributeIndexed)");
+#endif
+		}
+
 		DynamicValue indexConverted;
 		if (!index.convertToType(DynamicValueTypes::kInteger, indexConverted)) {
 			thread->error("Invalid index for 'nthelement'");
@@ -4217,6 +4253,14 @@ VThreadState MessageDispatch::continuePropagating(Runtime *runtime) {
 		case PropagationStack::kStageSendToStructuralChildren: {
 				Structural *structural = stackTop.ptr.structural;
 				const Common::Array<Common::SharedPtr<Structural> > &children = structural->getChildren();
+
+				if (structural->getSceneLoadState() == Structural::SceneLoadState::kSceneNotLoaded) {
+#ifdef MTROPOLIS_DEBUG_ENABLE
+					if (Debugger *debugger = runtime->debugGetDebugger())
+						debugger->notify(kDebugSeverityError, "Hot-loading scenes is not yet implemented (continuePropagating)");
+#endif
+				}
+
 				if (stackTop.index >= children.size()) {
 					_propagationStack.pop_back();
 				} else {
@@ -4840,6 +4884,13 @@ bool Runtime::runFrame() {
 			debug(1, "Materializing project...");
 			_project->materializeSelfAndDescendents(this, &_rootLinkingScope);
 
+			for (const Common::SharedPtr<Structural> &section : _project->getChildren()) {
+				for (const Common::SharedPtr<Structural> &subsection : section->getChildren()) {
+					for (const Common::SharedPtr<Structural> &scene : subsection->getChildren())
+						scene->setSceneLoadState(Structural::SceneLoadState::kSceneNotLoaded);
+				}
+			}
+
 			debug(1, "Project is fully loaded!  Starting up...");
 
 			if (_project->getChildren().size() == 0) {
@@ -5249,6 +5300,9 @@ void Runtime::executeTeardown(const Teardown &teardown) {
 			structural->removeAllChildren();
 			structural->removeAllModifiers();
 			structural->removeAllAssets();
+
+			assert(structural->getSceneLoadState() == Structural::SceneLoadState::kSceneLoaded);
+			structural->setSceneLoadState(Structural::SceneLoadState::kSceneNotLoaded);
 		} else {
 			Structural *parent = structural->getParent();
 
@@ -5287,7 +5341,7 @@ void Runtime::executeLowLevelSceneStateTransition(const LowLevelSceneStateTransi
 		sendMessageOnVThread(action.getMessage());
 		break;
 	case LowLevelSceneStateTransitionAction::kLoad:
-		loadScene(action.getScene());
+		loadScene(action.getScene(), true);
 		break;
 	case LowLevelSceneStateTransitionAction::kUnload: {
 			Teardown teardown;
@@ -5923,33 +5977,41 @@ void Runtime::queueEventAsLowLevelSceneStateTransitionAction(const Event &evt, S
 	_pendingLowLevelTransitions.push_back(LowLevelSceneStateTransitionAction(msg));
 }
 
-void Runtime::loadScene(const Common::SharedPtr<Structural>& scene) {
-	debug(1, "Loading scene '%s'", scene->getName().c_str());
-	Element *element = static_cast<Element *>(scene.get());
-	uint32 streamID = element->getStreamLocator() & 0xffff; // Not actually sure how many bits are legal here
+void Runtime::loadScene(const Common::SharedPtr<Structural> &scene, bool activateScene) {
+	assert(scene->getSceneLoadState() != Structural::SceneLoadState::kNotAScene);
 
-	Subsection *subsection = static_cast<Subsection *>(scene->getParent());
+	if (scene->getSceneLoadState() == Structural::SceneLoadState::kSceneNotLoaded) {
+		scene->setSceneLoadState(Structural::SceneLoadState::kSceneLoaded);
 
-	if (streamID == 0) {
-		debug(1, "Scene is empty");
-	} else {
-		_project->loadSceneFromStream(scene, streamID, getHacks());
-		debug(1, "Scene loaded OK, materializing objects...");
-		scene->materializeDescendents(this, subsection->getSceneLoadMaterializeScope());
-		debug(1, "Scene materialized OK");
+		debug(1, "Loading scene '%s'", scene->getName().c_str());
+		Element *element = static_cast<Element *>(scene.get());
+		uint32 streamID = element->getStreamLocator() & 0xffff; // Not actually sure how many bits are legal here
+
+		Subsection *subsection = static_cast<Subsection *>(scene->getParent());
+
+		if (streamID == 0) {
+			debug(1, "Scene is empty");
+		} else {
+			_project->loadSceneFromStream(scene, streamID, getHacks());
+			debug(1, "Scene loaded OK, materializing objects...");
+			scene->materializeDescendents(this, subsection->getSceneLoadMaterializeScope());
+			debug(1, "Scene materialized OK");
+		}
 	}
 
-	recursiveActivateStructural(scene.get());
-	debug(1, "Structural elements activated OK");
+	if (activateScene) {
+		recursiveActivateStructural(scene.get());
+		debug(1, "Structural elements activated OK");
 
 #ifdef MTROPOLIS_DEBUG_ENABLE
-	if (_debugger) {
-		_debugger->complainAboutUnfinished(scene.get());
-		_debugger->refreshSceneStatus();
-	}
+		if (_debugger) {
+			_debugger->complainAboutUnfinished(scene.get());
+			_debugger->refreshSceneStatus();
+		}
 #endif
 
-	refreshPlayTime();
+		refreshPlayTime();
+	}
 }
 
 void Runtime::sendMessageOnVThread(const Common::SharedPtr<MessageDispatch> &dispatch) {
@@ -7225,6 +7287,11 @@ void Runtime::queueChangeObjectParent(const Common::WeakPtr<RuntimeObject> &obj,
 	_pendingParentChanges.push_back(ObjectParentChange(obj, newParent));
 }
 
+void Runtime::hotLoadScene(Structural *structural) {
+	assert(structural->getSceneLoadState() != Structural::SceneLoadState::kNotAScene);
+	loadScene(structural->getSelfReference().lock().staticCast<Structural>(), false);
+}
+
 void Runtime::ensureMainWindowExists() {
 	// Maybe there's a better spot for this
 	if (_mainWindow.expired() && _project) {
@@ -9248,12 +9315,6 @@ MiniscriptInstructionOutcome VisualElement::writeRefAttribute(MiniscriptThread *
 		// Not sure what this does, MTI uses it frequently
 		DynamicValueWriteDiscardHelper::create(writeProxy);
 		return kMiniscriptInstructionOutcomeContinue;
-	} else if (attrib == "unload") {
-		if (getRuntime()->getHacks().ignoreSceneUnloads) {
-			DynamicValueWriteDiscardHelper::create(writeProxy);
-			return kMiniscriptInstructionOutcomeContinue;
-		} else
-			return kMiniscriptInstructionOutcomeFailed;
 	}
 
 	return Element::writeRefAttribute(thread, writeProxy, attrib);
diff --git a/engines/mtropolis/runtime.h b/engines/mtropolis/runtime.h
index ce38e7b73bd..7c7ea2f00e5 100644
--- a/engines/mtropolis/runtime.h
+++ b/engines/mtropolis/runtime.h
@@ -1738,6 +1738,8 @@ public:
 	void queueKillObject(const Common::WeakPtr<RuntimeObject> &obj);
 	void queueChangeObjectParent(const Common::WeakPtr<RuntimeObject> &obj, const Common::WeakPtr<RuntimeObject> &newParent);
 
+	void hotLoadScene(Structural *structural);
+
 #ifdef MTROPOLIS_DEBUG_ENABLE
 	void debugSetEnabled(bool enabled);
 	void debugBreak();
@@ -1869,7 +1871,7 @@ private:
 
 	void queueEventAsLowLevelSceneStateTransitionAction(const Event &evt, Structural *root, bool cascade, bool relay);
 
-	void loadScene(const Common::SharedPtr<Structural> &scene);
+	void loadScene(const Common::SharedPtr<Structural> &scene, bool activateScene);
 
 	void ensureMainWindowExists();
 
@@ -2187,11 +2189,19 @@ public:
 
 class Structural : public RuntimeObject, public IModifierContainer, public IMessageConsumer, public Debuggable {
 public:
+	enum class SceneLoadState {
+		kNotAScene,
+		kSceneNotLoaded,
+		kSceneLoaded,
+	};
+
 	Structural();
 	explicit Structural(Runtime *runtime);
 	virtual ~Structural();
 
 	bool isStructural() const override;
+	SceneLoadState getSceneLoadState() const;
+	void setSceneLoadState(SceneLoadState sceneLoadState);
 
 	bool readAttribute(MiniscriptThread *thread, DynamicValue &result, const Common::String &attrib) override;
 	bool readAttributeIndexed(MiniscriptThread *thread, DynamicValue &result, const Common::String &attrib, const DynamicValue &index) override;
@@ -2283,6 +2293,7 @@ protected:
 	bool _loop;
 
 	int32 _flushPriority;
+	SceneLoadState _sceneLoadState;
 
 	Common::SharedPtr<StructuralHooks> _hooks;
 


Commit: 07d303a38be00405a0598bc03ead0f95af93b091
    https://github.com/scummvm/scummvm/commit/07d303a38be00405a0598bc03ead0f95af93b091
Author: elasota (1137273+elasota at users.noreply.github.com)
Date: 2024-08-12T23:17:06-04:00

Commit Message:
MTROPOLIS: Add name auto-set for elements, always activate hot-loaded objects

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


diff --git a/engines/mtropolis/element_factory.cpp b/engines/mtropolis/element_factory.cpp
index 09341b9e593..70bff955770 100644
--- a/engines/mtropolis/element_factory.cpp
+++ b/engines/mtropolis/element_factory.cpp
@@ -25,7 +25,8 @@
 
 namespace MTropolis {
 
-ElementLoaderContext::ElementLoaderContext(Runtime *elc_runtime, size_t elc_streamIndex) : runtime(elc_runtime), streamIndex(elc_streamIndex) {
+ElementLoaderContext::ElementLoaderContext(Runtime *pRuntime, Project *pProject, size_t pStreamIndex)
+	: runtime(pRuntime), project(pProject), streamIndex(pStreamIndex) {
 }
 
 template<typename TElement, typename TElementData>
@@ -40,12 +41,17 @@ private:
 
 template<typename TElement, typename TElementData>
 Common::SharedPtr<Element> ElementFactory<TElement, TElementData>::createElement(ElementLoaderContext &context, const Data::DataObject &dataObject) {
-	Common::SharedPtr<TElement> element(new TElement());
+	TElement *tElementPtr = new TElement();
+	Common::SharedPtr<TElement> element(tElementPtr);
+	Element *elementPtr = tElementPtr;
 
-	if (!element->load(context, static_cast<const TElementData &>(dataObject)))
+	if (!element->load(context, static_cast<const TElementData &>(dataObject))) {
 		element.reset();
-	else
-		element->setSelfReference(element);
+	} else {
+		elementPtr->setSelfReference(element);
+		if (elementPtr->getName().empty())
+			elementPtr->tryAutoSetName(context.runtime, context.project);
+	}
 
 	return Common::SharedPtr<Element>(element);
 }
diff --git a/engines/mtropolis/element_factory.h b/engines/mtropolis/element_factory.h
index 20be6800aab..477681aa3f7 100644
--- a/engines/mtropolis/element_factory.h
+++ b/engines/mtropolis/element_factory.h
@@ -28,8 +28,9 @@
 namespace MTropolis {
 
 struct ElementLoaderContext {
-	ElementLoaderContext(Runtime *elc_runtime, size_t elc_streamIndex);
+	ElementLoaderContext(Runtime *pRuntime, Project *pProject, size_t pStreamIndex);
 
+	Project *project;
 	Runtime *runtime;
 	size_t streamIndex;
 };
diff --git a/engines/mtropolis/elements.cpp b/engines/mtropolis/elements.cpp
index 69032e99d65..9098000450f 100644
--- a/engines/mtropolis/elements.cpp
+++ b/engines/mtropolis/elements.cpp
@@ -948,6 +948,10 @@ void MovieElement::playMedia(Runtime *runtime, Project *project) {
 	}
 }
 
+void MovieElement::tryAutoSetName(Runtime *runtime, Project *project) {
+	_name = project->getAssetNameByID(_assetID);
+}
+
 void MovieElement::setResizeFilter(const Common::SharedPtr<MovieResizeFilter> &filter) {
 	_resizeFilter = filter;
 }
@@ -1235,6 +1239,10 @@ void ImageElement::deactivate() {
 	_cachedImage.reset();
 }
 
+void ImageElement::tryAutoSetName(Runtime *runtime, Project *project) {
+	_name = project->getAssetNameByID(_assetID);
+}
+
 void ImageElement::render(Window *window) {
 	if (_cachedImage) {
 		VisualElementRenderProperties::InkMode inkMode = _renderProps.getInkMode();
@@ -1476,6 +1484,10 @@ void MToonElement::deactivate() {
 	_renderSurface.reset();
 }
 
+void MToonElement::tryAutoSetName(Runtime *runtime, Project *project) {
+	_name = project->getAssetNameByID(_assetID);
+}
+
 bool MToonElement::canAutoPlay() const {
 	return _visible && !_paused;
 }
@@ -2568,6 +2580,10 @@ void SoundElement::playMedia(Runtime *runtime, Project *project) {
 	}
 }
 
+void SoundElement::tryAutoSetName(Runtime *runtime, Project *project) {
+	_name = project->getAssetNameByID(_assetID);
+}
+
 bool SoundElement::resolveMediaMarkerLabel(const Label &label, int32 &outResolution) const {
 	if (_metadata) {
 		for (const AudioMetadata::CuePoint &cuePoint : _metadata->cuePoints) {
diff --git a/engines/mtropolis/elements.h b/engines/mtropolis/elements.h
index 1bcb9e44d42..7699af0f3d4 100644
--- a/engines/mtropolis/elements.h
+++ b/engines/mtropolis/elements.h
@@ -107,6 +107,7 @@ public:
 
 	void render(Window *window) override;
 	void playMedia(Runtime *runtime, Project *project) override;
+	void tryAutoSetName(Runtime *runtime, Project *project) override;
 
 	void setResizeFilter(const Common::SharedPtr<MovieResizeFilter> &filter);
 
@@ -201,6 +202,8 @@ public:
 	void activate() override;
 	void deactivate() override;
 
+	void tryAutoSetName(Runtime *runtime, Project *project) override;
+
 	void render(Window *window) override;
 
 	Common::SharedPtr<Structural> shallowClone() const override;
@@ -238,6 +241,8 @@ public:
 	void activate() override;
 	void deactivate() override;
 
+	void tryAutoSetName(Runtime *runtime, Project *project) override;
+
 	bool canAutoPlay() const override;
 
 	void render(Window *window) override;
@@ -414,6 +419,7 @@ public:
 	bool canAutoPlay() const override;
 
 	void playMedia(Runtime *runtime, Project *project) override;
+	void tryAutoSetName(Runtime *runtime, Project *project) override;
 
 	bool resolveMediaMarkerLabel(const Label &label, int32 &outResolution) const override;
 
diff --git a/engines/mtropolis/runtime.cpp b/engines/mtropolis/runtime.cpp
index 0865ef121ac..268bd133fc2 100644
--- a/engines/mtropolis/runtime.cpp
+++ b/engines/mtropolis/runtime.cpp
@@ -5341,7 +5341,10 @@ void Runtime::executeLowLevelSceneStateTransition(const LowLevelSceneStateTransi
 		sendMessageOnVThread(action.getMessage());
 		break;
 	case LowLevelSceneStateTransitionAction::kLoad:
-		loadScene(action.getScene(), true);
+		loadScene(action.getScene());
+
+		// Refresh play time so anything time-based doesn't skip ahead
+		refreshPlayTime();
 		break;
 	case LowLevelSceneStateTransitionAction::kUnload: {
 			Teardown teardown;
@@ -5977,7 +5980,7 @@ void Runtime::queueEventAsLowLevelSceneStateTransitionAction(const Event &evt, S
 	_pendingLowLevelTransitions.push_back(LowLevelSceneStateTransitionAction(msg));
 }
 
-void Runtime::loadScene(const Common::SharedPtr<Structural> &scene, bool activateScene) {
+void Runtime::loadScene(const Common::SharedPtr<Structural> &scene) {
 	assert(scene->getSceneLoadState() != Structural::SceneLoadState::kNotAScene);
 
 	if (scene->getSceneLoadState() == Structural::SceneLoadState::kSceneNotLoaded) {
@@ -5999,19 +6002,15 @@ void Runtime::loadScene(const Common::SharedPtr<Structural> &scene, bool activat
 		}
 	}
 
-	if (activateScene) {
-		recursiveActivateStructural(scene.get());
-		debug(1, "Structural elements activated OK");
+	recursiveActivateStructural(scene.get());
+	debug(1, "Structural elements activated OK");
 
 #ifdef MTROPOLIS_DEBUG_ENABLE
-		if (_debugger) {
-			_debugger->complainAboutUnfinished(scene.get());
-			_debugger->refreshSceneStatus();
-		}
-#endif
-
-		refreshPlayTime();
+	if (_debugger) {
+		_debugger->complainAboutUnfinished(scene.get());
+		_debugger->refreshSceneStatus();
 	}
+#endif
 }
 
 void Runtime::sendMessageOnVThread(const Common::SharedPtr<MessageDispatch> &dispatch) {
@@ -7289,7 +7288,7 @@ void Runtime::queueChangeObjectParent(const Common::WeakPtr<RuntimeObject> &obj,
 
 void Runtime::hotLoadScene(Structural *structural) {
 	assert(structural->getSceneLoadState() != Structural::SceneLoadState::kNotAScene);
-	loadScene(structural->getSelfReference().lock().staticCast<Structural>(), false);
+	loadScene(structural->getSelfReference().lock().staticCast<Structural>());
 }
 
 void Runtime::ensureMainWindowExists() {
@@ -8684,7 +8683,7 @@ void Project::loadContextualObject(size_t streamIndex, ChildLoaderStack &stack,
 					error("No element factory defined for structural object");
 				}
 
-				ElementLoaderContext elementLoaderContext(getRuntime(), streamIndex);
+				ElementLoaderContext elementLoaderContext(getRuntime(), this, streamIndex);
 				Common::SharedPtr<Element> element = elementFactory->createElement(elementLoaderContext, dataObject);
 
 				uint32 guid = element->getStaticGUID();
@@ -8871,6 +8870,9 @@ void Element::triggerAutoPlay(Runtime *runtime) {
 	queueAutoPlayEvents(runtime, canAutoPlay());
 }
 
+void Element::tryAutoSetName(Runtime *runtime, Project *project) {
+}
+
 bool Element::resolveMediaMarkerLabel(const Label& label, int32 &outResolution) const {
 	return false;
 }
diff --git a/engines/mtropolis/runtime.h b/engines/mtropolis/runtime.h
index 7c7ea2f00e5..9079d65d7f8 100644
--- a/engines/mtropolis/runtime.h
+++ b/engines/mtropolis/runtime.h
@@ -1871,7 +1871,7 @@ private:
 
 	void queueEventAsLowLevelSceneStateTransitionAction(const Event &evt, Structural *root, bool cascade, bool relay);
 
-	void loadScene(const Common::SharedPtr<Structural> &scene, bool activateScene);
+	void loadScene(const Common::SharedPtr<Structural> &scene);
 
 	void ensureMainWindowExists();
 
@@ -2695,6 +2695,7 @@ public:
 	void removeMediaCue(const MediaCueState *mediaCue);
 
 	void triggerAutoPlay(Runtime *runtime);
+	virtual void tryAutoSetName(Runtime *runtime, Project *project);
 
 	virtual bool resolveMediaMarkerLabel(const Label &label, int32 &outResolution) const;
 


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

Commit Message:
MTROPOLIS: Remove SPQR hacks

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


diff --git a/engines/mtropolis/hacks.cpp b/engines/mtropolis/hacks.cpp
index 3b52204a134..faadb0e49a4 100644
--- a/engines/mtropolis/hacks.cpp
+++ b/engines/mtropolis/hacks.cpp
@@ -1138,44 +1138,6 @@ void addMTIQuirks(const MTropolisGameDescription &desc, Hacks &hacks) {
 	hacks.addSceneTransitionHooks(Common::SharedPtr<SceneTransitionHooks>(new MTIMolassesSceneTransitionHooks(molassesHandler)));
 }
 
-class SPQRSoundPreloadHooks : public SceneTransitionHooks {
-public:
-	void onProjectStarted(Runtime *runtime) override;
-};
-
-void SPQRSoundPreloadHooks::onProjectStarted(Runtime *runtime) {
-	Project *project = runtime->getProject();
-
-	Structural *worldSection = nullptr;
-	Structural *soundSubsection = nullptr;
-
-	for (const Common::SharedPtr<Structural> &child : project->getChildren()) {
-		if (child->getName() == "World") {
-			worldSection = child.get();
-			break;
-		}
-	}
-
-	if (worldSection) {
-		for (const Common::SharedPtr<Structural> &child : worldSection->getChildren()) {
-			if (child->getName() == "Sound") {
-				soundSubsection = child.get();
-				break;
-			}
-		}
-	}
-
-	if (soundSubsection) {
-		for (const Common::SharedPtr<Structural> &child : soundSubsection->getChildren())
-			runtime->addSceneStateTransition(HighLevelSceneTransition(child, HighLevelSceneTransition::kTypeForceLoadScene, false, false));
-	}
-}
-
-void addSPQRQuirks(const MTropolisGameDescription &desc, Hacks &hacks) {
-	hacks.addSceneTransitionHooks(Common::SharedPtr<SceneTransitionHooks>(new SPQRSoundPreloadHooks()));
-	hacks.ignoreSceneUnloads = true;
-}
-
 } // End of namespace HackSuites
 
 } // End of namespace MTropolis
diff --git a/engines/mtropolis/hacks.h b/engines/mtropolis/hacks.h
index 96a05c73683..79b620042a7 100644
--- a/engines/mtropolis/hacks.h
+++ b/engines/mtropolis/hacks.h
@@ -83,7 +83,6 @@ void addObsidianSaveMechanism(const MTropolisGameDescription &desc, Hacks &hacks
 void addObsidianImprovedWidescreen(const MTropolisGameDescription &desc, Hacks &hacks);
 
 void addMTIQuirks(const MTropolisGameDescription &desc, Hacks &hacks);
-void addSPQRQuirks(const MTropolisGameDescription &desc, Hacks &hacks);
 
 } // End of namespace HackSuites
 
diff --git a/engines/mtropolis/mtropolis.cpp b/engines/mtropolis/mtropolis.cpp
index f42cded8eba..d15fd15f385 100644
--- a/engines/mtropolis/mtropolis.cpp
+++ b/engines/mtropolis/mtropolis.cpp
@@ -332,8 +332,6 @@ Common::Error MTropolisEngine::run() {
 		Palette pal;
 		pal.initDefaultPalette(2);
 		_runtime->setGlobalPalette(pal);
-	} else if (_gameDescription->gameID == GID_SPQR) {
-		HackSuites::addSPQRQuirks(*_gameDescription, _runtime->getHacks());
 	}
 
 


Commit: 2ffacef65fd5af987d388d3dda7663bde3df36da
    https://github.com/scummvm/scummvm/commit/2ffacef65fd5af987d388d3dda7663bde3df36da
Author: elasota (1137273+elasota at users.noreply.github.com)
Date: 2024-08-12T23:17:06-04:00

Commit Message:
MTROPOLIS: Add scene hot loading during message propagation

Changed paths:
    engines/mtropolis/runtime.cpp


diff --git a/engines/mtropolis/runtime.cpp b/engines/mtropolis/runtime.cpp
index 268bd133fc2..48aa6d3ab9e 100644
--- a/engines/mtropolis/runtime.cpp
+++ b/engines/mtropolis/runtime.cpp
@@ -4252,14 +4252,11 @@ VThreadState MessageDispatch::continuePropagating(Runtime *runtime) {
 			} break;
 		case PropagationStack::kStageSendToStructuralChildren: {
 				Structural *structural = stackTop.ptr.structural;
-				const Common::Array<Common::SharedPtr<Structural> > &children = structural->getChildren();
 
-				if (structural->getSceneLoadState() == Structural::SceneLoadState::kSceneNotLoaded) {
-#ifdef MTROPOLIS_DEBUG_ENABLE
-					if (Debugger *debugger = runtime->debugGetDebugger())
-						debugger->notify(kDebugSeverityError, "Hot-loading scenes is not yet implemented (continuePropagating)");
-#endif
-				}
+				if (structural->getSceneLoadState() == Structural::SceneLoadState::kSceneNotLoaded)
+					runtime->hotLoadScene(structural);
+
+				const Common::Array<Common::SharedPtr<Structural> > &children = structural->getChildren();
 
 				if (stackTop.index >= children.size()) {
 					_propagationStack.pop_back();


Commit: 592626ee4df5586a51423472791193cb067c4833
    https://github.com/scummvm/scummvm/commit/592626ee4df5586a51423472791193cb067c4833
Author: elasota (1137273+elasota at users.noreply.github.com)
Date: 2024-08-12T23:17:06-04:00

Commit Message:
MTROPOLIS: Fix modifiers not being hot loaded.  Fix double-activation.

Changed paths:
    engines/mtropolis/runtime.cpp


diff --git a/engines/mtropolis/runtime.cpp b/engines/mtropolis/runtime.cpp
index 48aa6d3ab9e..46f5c0ee7b3 100644
--- a/engines/mtropolis/runtime.cpp
+++ b/engines/mtropolis/runtime.cpp
@@ -4253,9 +4253,6 @@ VThreadState MessageDispatch::continuePropagating(Runtime *runtime) {
 		case PropagationStack::kStageSendToStructuralChildren: {
 				Structural *structural = stackTop.ptr.structural;
 
-				if (structural->getSceneLoadState() == Structural::SceneLoadState::kSceneNotLoaded)
-					runtime->hotLoadScene(structural);
-
 				const Common::Array<Common::SharedPtr<Structural> > &children = structural->getChildren();
 
 				if (stackTop.index >= children.size()) {
@@ -4297,6 +4294,9 @@ VThreadState MessageDispatch::continuePropagating(Runtime *runtime) {
 		case PropagationStack::kStageSendToStructuralModifiers: {
 				Structural *structural = stackTop.ptr.structural;
 
+				if (structural->getSceneLoadState() == Structural::SceneLoadState::kSceneNotLoaded)
+					runtime->hotLoadScene(structural);
+
 				// Once done with modifiers, propagate to children if set to cascade
 				if (_cascade) {
 					stackTop.propagationStage = PropagationStack::kStageSendToStructuralChildren;
@@ -5997,17 +5997,17 @@ void Runtime::loadScene(const Common::SharedPtr<Structural> &scene) {
 			scene->materializeDescendents(this, subsection->getSceneLoadMaterializeScope());
 			debug(1, "Scene materialized OK");
 		}
-	}
 
-	recursiveActivateStructural(scene.get());
-	debug(1, "Structural elements activated OK");
+		recursiveActivateStructural(scene.get());
+		debug(1, "Structural elements activated OK");
 
 #ifdef MTROPOLIS_DEBUG_ENABLE
-	if (_debugger) {
-		_debugger->complainAboutUnfinished(scene.get());
-		_debugger->refreshSceneStatus();
-	}
+		if (_debugger) {
+			_debugger->complainAboutUnfinished(scene.get());
+			_debugger->refreshSceneStatus();
+		}
 #endif
+	}
 }
 
 void Runtime::sendMessageOnVThread(const Common::SharedPtr<MessageDispatch> &dispatch) {




More information about the Scummvm-git-logs mailing list