[Scummvm-git-logs] scummvm master -> c6139d298cedf50dd5f7bfdd44b995116cf9502d
elasota
noreply at scummvm.org
Mon Oct 31 08:02:14 UTC 2022
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:
9a93ef2ff2 MTROPOLIS: Add more debug inspectors for mToon elements.
c6139d298c MTROPOLIS: Fix messengers resolving source-relative targets relative to themselves instead of relative to the sender of
Commit: 9a93ef2ff2ac347dcba97e464aa6023b0b8beb54
https://github.com/scummvm/scummvm/commit/9a93ef2ff2ac347dcba97e464aa6023b0b8beb54
Author: elasota (ejlasota at gmail.com)
Date: 2022-10-31T03:53:59-04:00
Commit Message:
MTROPOLIS: Add more debug inspectors for mToon elements.
Changed paths:
engines/mtropolis/elements.cpp
engines/mtropolis/elements.h
diff --git a/engines/mtropolis/elements.cpp b/engines/mtropolis/elements.cpp
index 277853a1ebe..8d3d3e64abe 100644
--- a/engines/mtropolis/elements.cpp
+++ b/engines/mtropolis/elements.cpp
@@ -1347,6 +1347,17 @@ Common::Rect MToonElement::getRelativeCollisionRect() const {
colRect.translate(_rect.left, _rect.top);
return colRect;
}
+#ifdef MTROPOLIS_DEBUG_ENABLE
+void MToonElement::debugInspect(IDebugInspectionReport *report) const {
+ VisualElement::debugInspect(report);
+
+ report->declareDynamic("cel", Common::String::format("%i", static_cast<int>(_cel)));
+ report->declareDynamic("assetID", Common::String::format("%i", static_cast<int>(_assetID)));
+ report->declareDynamic("isPlaying", Common::String::format("%s", _isPlaying ? "true" : "false"));
+ report->declareDynamic("renderedFrame", Common::String::format("%i", static_cast<int>(_renderedFrame)));
+ report->declareDynamic("playRange", Common::String::format("%i", static_cast<int>(_playRange.min), static_cast<int>(_playRange.max)));
+}
+#endif
VThreadState MToonElement::startPlayingTask(const StartPlayingTaskData &taskData) {
if (_rateTimes100000 < 0)
diff --git a/engines/mtropolis/elements.h b/engines/mtropolis/elements.h
index 0a7245bc765..7cfc7a7d8e2 100644
--- a/engines/mtropolis/elements.h
+++ b/engines/mtropolis/elements.h
@@ -234,6 +234,7 @@ public:
#ifdef MTROPOLIS_DEBUG_ENABLE
const char *debugGetTypeName() const override { return "mToon Element"; }
SupportStatus debugGetSupportStatus() const override { return kSupportStatusDone; }
+ void debugInspect(IDebugInspectionReport *report) const override;
#endif
private:
Commit: c6139d298cedf50dd5f7bfdd44b995116cf9502d
https://github.com/scummvm/scummvm/commit/c6139d298cedf50dd5f7bfdd44b995116cf9502d
Author: elasota (ejlasota at gmail.com)
Date: 2022-10-31T03:54:00-04:00
Commit Message:
MTROPOLIS: Fix messengers resolving source-relative targets relative to themselves instead of relative to the sender of the message that activated the messenger.
Changed paths:
engines/mtropolis/modifiers.cpp
engines/mtropolis/modifiers.h
engines/mtropolis/plugin/standard.cpp
engines/mtropolis/plugin/standard.h
engines/mtropolis/runtime.cpp
engines/mtropolis/runtime.h
diff --git a/engines/mtropolis/modifiers.cpp b/engines/mtropolis/modifiers.cpp
index 384f972c9da..7578c7073ed 100644
--- a/engines/mtropolis/modifiers.cpp
+++ b/engines/mtropolis/modifiers.cpp
@@ -465,7 +465,7 @@ bool MessengerModifier::respondsToEvent(const Event &evt) const {
VThreadState MessengerModifier::consumeMessage(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) {
if (_when.respondsTo(msg->getEvent())) {
- _sendSpec.sendFromMessenger(runtime, this, msg->getValue(), nullptr);
+ _sendSpec.sendFromMessenger(runtime, this, msg->getSource().lock().get(), msg->getValue(), nullptr);
}
return kVThreadReturn;
@@ -1439,6 +1439,7 @@ VThreadState IfMessengerModifier::consumeMessage(Runtime *runtime, const Common:
evalAndSendData->thread = thread;
evalAndSendData->runtime = runtime;
evalAndSendData->incomingData = msg->getValue();
+ evalAndSendData->triggerSource = msg->getSource();
MiniscriptThread::runOnVThread(runtime->getVThread(), thread);
}
@@ -1479,7 +1480,7 @@ VThreadState IfMessengerModifier::evaluateAndSendTask(const EvaluateAndSendTaskD
return kVThreadError;
if (isTrue)
- _sendSpec.sendFromMessenger(taskData.runtime, this, taskData.incomingData, nullptr);
+ _sendSpec.sendFromMessenger(taskData.runtime, this, taskData.triggerSource.lock().get(), taskData.incomingData, nullptr);
return kVThreadReturn;
}
@@ -1524,6 +1525,8 @@ VThreadState TimerMessengerModifier::consumeMessage(Runtime *runtime, const Comm
if (realMilliseconds == 0)
realMilliseconds = 1;
+ _triggerSource = msg->getSource();
+
debug(3, "Timer %x '%s' scheduled to execute in %i milliseconds", getStaticGUID(), getName().c_str(), realMilliseconds);
if (_scheduledEvent) {
@@ -1578,7 +1581,7 @@ void TimerMessengerModifier::trigger(Runtime *runtime) {
} else
_scheduledEvent.reset();
- _sendSpec.sendFromMessenger(runtime, this, _incomingData, nullptr);
+ _sendSpec.sendFromMessenger(runtime, this, _triggerSource.lock().get(), _incomingData, nullptr);
}
BoundaryDetectionMessengerModifier::BoundaryDetectionMessengerModifier()
@@ -1627,6 +1630,7 @@ VThreadState BoundaryDetectionMessengerModifier::consumeMessage(Runtime *runtime
_incomingData = msg->getValue();
if (_incomingData.getType() == DynamicValueTypes::kList)
_incomingData.setList(_incomingData.getList()->clone());
+ _triggerSource = msg->getSource();
}
if (_disableWhen.respondsTo(msg->getEvent())) {
disable(runtime);
@@ -1670,7 +1674,7 @@ void BoundaryDetectionMessengerModifier::getCollisionProperties(Modifier *&modif
}
void BoundaryDetectionMessengerModifier::triggerCollision(Runtime *runtime) {
- _send.sendFromMessenger(runtime, this, _incomingData, nullptr);
+ _send.sendFromMessenger(runtime, this, _triggerSource.lock().get(), _incomingData, nullptr);
}
Common::SharedPtr<Modifier> BoundaryDetectionMessengerModifier::shallowClone() const {
@@ -1734,12 +1738,13 @@ VThreadState CollisionDetectionMessengerModifier::consumeMessage(Runtime *runtim
if (!_isActive) {
_isActive = true;
_runtime = runtime;
- _incomingData = msg->getValue();
- if (_incomingData.getType() == DynamicValueTypes::kList)
- _incomingData.setList(_incomingData.getList()->clone());
runtime->addCollider(this);
}
+ _incomingData = msg->getValue();
+ if (_incomingData.getType() == DynamicValueTypes::kList)
+ _incomingData.setList(_incomingData.getList()->clone());
+ _triggerSource = msg->getSource();
}
if (_disableWhen.respondsTo(msg->getEvent())) {
disable(runtime);
@@ -1809,7 +1814,7 @@ void CollisionDetectionMessengerModifier::triggerCollision(Runtime *runtime, Str
customDestination = collidingElement;
}
- _sendSpec.sendFromMessenger(runtime, this, _incomingData, customDestination);
+ _sendSpec.sendFromMessenger(runtime, this, _triggerSource.lock().get(), _incomingData, customDestination);
}
KeyboardMessengerModifier::~KeyboardMessengerModifier() {
@@ -2020,7 +2025,7 @@ void KeyboardMessengerModifier::dispatchMessage(Runtime *runtime, const Common::
DynamicValue charStrValue;
charStrValue.setString(charStr);
- _sendSpec.sendFromMessenger(runtime, this, charStrValue, nullptr);
+ _sendSpec.sendFromMessenger(runtime, this, nullptr, charStrValue, nullptr);
}
void KeyboardMessengerModifier::visitInternalReferences(IStructuralReferenceVisitor *visitor) {
diff --git a/engines/mtropolis/modifiers.h b/engines/mtropolis/modifiers.h
index 6ad7416287a..ffe1c98118f 100644
--- a/engines/mtropolis/modifiers.h
+++ b/engines/mtropolis/modifiers.h
@@ -575,6 +575,7 @@ private:
EvaluateAndSendTaskData() : runtime(nullptr) {}
Common::SharedPtr<MiniscriptThread> thread;
+ Common::WeakPtr<RuntimeObject> triggerSource;
Runtime *runtime;
DynamicValue incomingData;
};
@@ -626,6 +627,7 @@ private:
DynamicValue _incomingData;
Common::SharedPtr<ScheduledEvent> _scheduledEvent;
+ Common::WeakPtr<RuntimeObject> _triggerSource;
};
class BoundaryDetectionMessengerModifier : public Modifier, public IBoundaryDetector {
@@ -676,6 +678,7 @@ private:
Runtime *_runtime;
bool _isActive;
DynamicValue _incomingData;
+ Common::WeakPtr<RuntimeObject> _triggerSource;
};
class CollisionDetectionMessengerModifier : public Modifier, public ICollider {
@@ -725,6 +728,7 @@ private:
bool _isActive;
DynamicValue _incomingData;
+ Common::WeakPtr<RuntimeObject> _triggerSource;
};
class KeyboardMessengerModifier : public Modifier {
diff --git a/engines/mtropolis/plugin/standard.cpp b/engines/mtropolis/plugin/standard.cpp
index bdf3867c32a..e06c557ffdc 100644
--- a/engines/mtropolis/plugin/standard.cpp
+++ b/engines/mtropolis/plugin/standard.cpp
@@ -1924,6 +1924,14 @@ void MediaCueMessengerModifier::disable(Runtime *runtime) {
}
}
+Modifier *MediaCueMessengerModifier::getMediaCueModifier() {
+ return this;
+}
+
+Common::WeakPtr<Modifier> MediaCueMessengerModifier::getMediaCueTriggerSource() const {
+ return _cueSourceModifier;
+}
+
Common::SharedPtr<Modifier> MediaCueMessengerModifier::shallowClone() const {
Common::SharedPtr<MediaCueMessengerModifier> clone(new MediaCueMessengerModifier(*this));
clone->_isActive = false;
diff --git a/engines/mtropolis/plugin/standard.h b/engines/mtropolis/plugin/standard.h
index b0c5cd38fd8..c6f60dee2ef 100644
--- a/engines/mtropolis/plugin/standard.h
+++ b/engines/mtropolis/plugin/standard.h
@@ -105,7 +105,7 @@ private:
bool _fullScreen;
};
-class MediaCueMessengerModifier : public Modifier {
+class MediaCueMessengerModifier : public Modifier, public IMediaCueModifier {
public:
MediaCueMessengerModifier();
~MediaCueMessengerModifier();
@@ -116,6 +116,9 @@ public:
VThreadState consumeMessage(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) override;
void disable(Runtime *runtime) override;
+ Modifier *getMediaCueModifier() override;
+ Common::WeakPtr<Modifier> getMediaCueTriggerSource() const override;
+
#ifdef MTROPOLIS_DEBUG_ENABLE
const char *debugGetTypeName() const override { return "Media Cue Modifier"; }
SupportStatus debugGetSupportStatus() const override { return kSupportStatusDone; }
diff --git a/engines/mtropolis/runtime.cpp b/engines/mtropolis/runtime.cpp
index 89c9c4d63c6..1266ba4350e 100644
--- a/engines/mtropolis/runtime.cpp
+++ b/engines/mtropolis/runtime.cpp
@@ -2005,7 +2005,7 @@ void MessengerSendSpec::visitInternalReferences(IStructuralReferenceVisitor *vis
visitor->visitWeakModifierRef(_resolvedVarSource);
}
-void MessengerSendSpec::resolveDestination(Runtime *runtime, Modifier *sender, Common::WeakPtr<Structural> &outStructuralDest, Common::WeakPtr<Modifier> &outModifierDest, RuntimeObject *customDestination) const {
+void MessengerSendSpec::resolveDestination(Runtime *runtime, Modifier *sender, RuntimeObject *triggerSource, Common::WeakPtr<Structural> &outStructuralDest, Common::WeakPtr<Modifier> &outModifierDest, RuntimeObject *customDestination) const {
outStructuralDest.reset();
outModifierDest.reset();
@@ -2085,9 +2085,14 @@ void MessengerSendSpec::resolveDestination(Runtime *runtime, Modifier *sender, C
outStructuralDest = sibling;
} break;
case kMessageDestSourcesParent: {
- // This sends to the exact parent, e.g. if the sender is inside of a behavior, then it sends it to the behavior.
- if (sender) {
- Common::SharedPtr<RuntimeObject> parentObj = sender->getParent().lock();
+ // This sends to the exact parent, e.g. if the source is inside of a behavior, then it sends it to the behavior.
+ if (triggerSource) {
+ RuntimeObject *parentObj = nullptr;
+ if (triggerSource->isModifier())
+ parentObj = static_cast<Modifier *>(triggerSource)->getParent().lock().get();
+ else if (triggerSource->isStructural())
+ parentObj = static_cast<Structural *>(triggerSource)->getParent();
+
if (parentObj) {
if (parentObj->isModifier())
outModifierDest = parentObj->getSelfReference().staticCast<Modifier>();
@@ -2126,17 +2131,17 @@ void MessengerSendSpec::resolveVariableObjectType(RuntimeObject *obj, Common::We
}
}
-void MessengerSendSpec::sendFromMessenger(Runtime *runtime, Modifier *sender, const DynamicValue &incomingData, RuntimeObject *customDestination) const {
- sendFromMessengerWithCustomData(runtime, sender, this->with.produceValue(incomingData), customDestination);
+void MessengerSendSpec::sendFromMessenger(Runtime *runtime, Modifier *sender, RuntimeObject *triggerSource, const DynamicValue &incomingData, RuntimeObject *customDestination) const {
+ sendFromMessengerWithCustomData(runtime, sender, triggerSource, this->with.produceValue(incomingData), customDestination);
}
-void MessengerSendSpec::sendFromMessengerWithCustomData(Runtime *runtime, Modifier *sender, const DynamicValue &data, RuntimeObject *customDestination) const {
+void MessengerSendSpec::sendFromMessengerWithCustomData(Runtime *runtime, Modifier *sender, RuntimeObject *triggerSource, const DynamicValue &data, RuntimeObject *customDestination) const {
Common::SharedPtr<MessageProperties> props(new MessageProperties(this->send, data, sender->getSelfReference()));
Common::WeakPtr<Modifier> modifierDestRef;
Common::WeakPtr<Structural> structuralDestRef;
- resolveDestination(runtime, sender, structuralDestRef, modifierDestRef, customDestination);
+ resolveDestination(runtime, sender, triggerSource, structuralDestRef, modifierDestRef, customDestination);
Common::SharedPtr<Modifier> modifierDest = modifierDestRef.lock();
Common::SharedPtr<Structural> structuralDest = structuralDestRef.lock();
@@ -6475,7 +6480,7 @@ void MediaCueState::checkTimestampChange(Runtime *runtime, uint32 oldTS, uint32
// Given the positioning of this, there's not really a way for the immediate flag to have any effect?
if (shouldTrigger)
- send.sendFromMessenger(runtime, sourceModifier, incomingData, nullptr);
+ send.sendFromMessenger(runtime, sourceModifier->getMediaCueModifier(), sourceModifier->getMediaCueTriggerSource().lock().get(), incomingData, nullptr);
}
@@ -6861,8 +6866,6 @@ void Project::loadBootStream(size_t streamIndex, const Hacks &hacks) {
size_t numObjectsLoaded = 0;
while (stream.pos() != streamDesc.size) {
- uint64 streamPos = stream.pos();
-
Common::SharedPtr<Data::DataObject> dataObject;
Data::loadDataObject(plugInDataLoaderRegistry, reader, dataObject);
diff --git a/engines/mtropolis/runtime.h b/engines/mtropolis/runtime.h
index 351ebb6d5eb..37a31a5c599 100644
--- a/engines/mtropolis/runtime.h
+++ b/engines/mtropolis/runtime.h
@@ -1092,12 +1092,13 @@ struct MessengerSendSpec {
void linkInternalReferences(ObjectLinkingScope *outerScope);
void visitInternalReferences(IStructuralReferenceVisitor *visitor);
- void resolveDestination(Runtime *runtime, Modifier *sender, Common::WeakPtr<Structural> &outStructuralDest, Common::WeakPtr<Modifier> &outModifierDest, RuntimeObject *customDestination) const;
+
+ void resolveDestination(Runtime *runtime, Modifier *sender, RuntimeObject *triggerSource, Common::WeakPtr<Structural> &outStructuralDest, Common::WeakPtr<Modifier> &outModifierDest, RuntimeObject *customDestination) const;
static void resolveVariableObjectType(RuntimeObject *obj, Common::WeakPtr<Structural> &outStructuralDest, Common::WeakPtr<Modifier> &outModifierDest);
- void sendFromMessenger(Runtime *runtime, Modifier *sender, const DynamicValue &incomingData, RuntimeObject *customDestination) const;
- void sendFromMessengerWithCustomData(Runtime *runtime, Modifier *sender, const DynamicValue &data, RuntimeObject *customDestination) const;
+ void sendFromMessenger(Runtime *runtime, Modifier *sender, RuntimeObject *triggerSource, const DynamicValue &incomingData, RuntimeObject *customDestination) const;
+ void sendFromMessengerWithCustomData(Runtime *runtime, Modifier *sender, RuntimeObject *triggerSource, const DynamicValue &data, RuntimeObject *customDestination) const;
enum LinkType {
kLinkTypeNotYetLinked,
@@ -2272,6 +2273,11 @@ struct IPostEffect : public IInterfaceBase {
virtual void renderPostEffect(Graphics::ManagedSurface &surface) const = 0;
};
+struct IMediaCueModifier : public IInterfaceBase {
+ virtual Modifier *getMediaCueModifier() = 0;
+ virtual Common::WeakPtr<Modifier> getMediaCueTriggerSource() const = 0;
+};
+
struct MediaCueState {
enum TriggerTiming {
kTriggerTimingStart = 0,
@@ -2282,7 +2288,7 @@ struct MediaCueState {
int32 minTime;
int32 maxTime;
- Modifier *sourceModifier;
+ IMediaCueModifier *sourceModifier;
TriggerTiming triggerTiming;
MessengerSendSpec send;
DynamicValue incomingData;
More information about the Scummvm-git-logs
mailing list