[Scummvm-git-logs] scummvm master -> 3809557b5ab4f95f3691563df6dc47912634f3e5
elasota
noreply at scummvm.org
Tue Jun 13 22:12:58 UTC 2023
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:
3809557b5a MTROPOLIS: Add hack to fix intro animation in secret room not playing. Fix list delete not working correctly (fixes tre
Commit: 3809557b5ab4f95f3691563df6dc47912634f3e5
https://github.com/scummvm/scummvm/commit/3809557b5ab4f95f3691563df6dc47912634f3e5
Author: elasota (ejlasota at gmail.com)
Date: 2023-06-13T18:12:37-04:00
Commit Message:
MTROPOLIS: Add hack to fix intro animation in secret room not playing. Fix list delete not working correctly (fixes treasure drain looping).
Changed paths:
engines/mtropolis/elements.cpp
engines/mtropolis/hacks.cpp
engines/mtropolis/hacks.h
engines/mtropolis/runtime.cpp
engines/mtropolis/runtime.h
diff --git a/engines/mtropolis/elements.cpp b/engines/mtropolis/elements.cpp
index 8a8be4ffa9b..89b9f947444 100644
--- a/engines/mtropolis/elements.cpp
+++ b/engines/mtropolis/elements.cpp
@@ -1356,6 +1356,9 @@ void MToonElement::activate() {
if (_name.empty())
_name = project->getAssetNameByID(_assetID);
+
+ if (_hooks)
+ _hooks->onPostActivate(this);
}
void MToonElement::deactivate() {
diff --git a/engines/mtropolis/hacks.cpp b/engines/mtropolis/hacks.cpp
index ef7609d1a3a..e8e88e74fe4 100644
--- a/engines/mtropolis/hacks.cpp
+++ b/engines/mtropolis/hacks.cpp
@@ -1023,6 +1023,19 @@ void addObsidianSaveMechanism(const MTropolisGameDescription &desc, Hacks &hacks
hacks.addSaveLoadMechanismHooks(mechanism);
}
+class MTIStructuralHooks : public StructuralHooks {
+public:
+ void onPostActivate(Structural *structural) override;
+};
+
+void MTIStructuralHooks::onPostActivate(Structural *structural) {
+ if (structural->getName() == "D15_0003.tun") {
+ // Fix for intro not playing in Piggy's secret room. D15_0003.tun is on layer 7 but treasure layers are on top of it.
+ if (structural->isElement() && static_cast<Element *>(structural)->isVisual())
+ static_cast<VisualElement *>(structural)->setLayer(20);
+ }
+}
+
void addMTIQuirks(const MTropolisGameDescription &desc, Hacks &hacks) {
// MTI uses a lot of "maintain rate" mToons at 10Hz. This means their frame timer resets on every frame advance, and
// is supposed to ensure that the mToon plays back at a smooth rate regardless of clock jitter. Unfortunately, it
@@ -1059,6 +1072,8 @@ void addMTIQuirks(const MTropolisGameDescription &desc, Hacks &hacks) {
// Modifier "Scene Started => helmSteered? => Play Character, else Play Char" has a non-null-terminated name,
// which causes an integrity check failure when disembarking the Hispaniola.
hacks.mtiHispaniolaDamagedStringHack = true;
+
+ hacks.defaultStructuralHooks.reset(new MTIStructuralHooks());
}
} // End of namespace HackSuites
diff --git a/engines/mtropolis/hacks.h b/engines/mtropolis/hacks.h
index 025889f8b20..3c16e9bc69b 100644
--- a/engines/mtropolis/hacks.h
+++ b/engines/mtropolis/hacks.h
@@ -65,6 +65,7 @@ struct Hacks {
Common::HashMap<uint32, Common::SharedPtr<StructuralHooks> > structuralHooks;
Common::HashMap<uint32, Common::SharedPtr<ModifierHooks> > modifierHooks;
+ Common::SharedPtr<StructuralHooks> defaultStructuralHooks;
Common::Array<Common::SharedPtr<SceneTransitionHooks> > sceneTransitionHooks;
Common::Array<Common::SharedPtr<AssetHooks> > assetHooks;
Common::Array<Common::SharedPtr<SaveLoadHooks> > saveLoadHooks;
diff --git a/engines/mtropolis/runtime.cpp b/engines/mtropolis/runtime.cpp
index 67187f91e39..8d85f74ebc0 100644
--- a/engines/mtropolis/runtime.cpp
+++ b/engines/mtropolis/runtime.cpp
@@ -853,7 +853,7 @@ bool DynamicList::setAtIndex(size_t index, const DynamicValue &value) {
void DynamicList::deleteAtIndex(size_t index) {
if (_container != nullptr) {
size_t size = _container->getSize();
- if (size < _container->getSize()) {
+ if (index < _container->getSize()) {
for (size_t i = index + 1; i < size; i++) {
DynamicValue valueToMove;
_container->getAtIndex(i, valueToMove);
@@ -2976,6 +2976,9 @@ MiniscriptInstructionOutcome AssetManagerInterface::writeRefAttribute(Miniscript
void StructuralHooks::onCreate(Structural *structural) {
}
+void StructuralHooks::onPostActivate(Structural *structural) {
+}
+
void StructuralHooks::onSetPosition(Runtime *runtime, Structural *structural, Common::Point &pt) {
}
@@ -7759,7 +7762,13 @@ void Project::loadContextualObject(size_t streamIndex, ChildLoaderStack &stack,
uint32 guid = element->getStaticGUID();
const Common::HashMap<uint32, Common::SharedPtr<StructuralHooks> > &hooksMap = getRuntime()->getHacks().structuralHooks;
Common::HashMap<uint32, Common::SharedPtr<StructuralHooks> >::const_iterator hooksIt = hooksMap.find(guid);
- if (hooksIt != hooksMap.end()) {
+ if (hooksIt == hooksMap.end()) {
+ Common::SharedPtr<StructuralHooks> defaultStructuralHooks = getRuntime()->getHacks().defaultStructuralHooks;
+ if (defaultStructuralHooks) {
+ element->setHooks(defaultStructuralHooks);
+ defaultStructuralHooks->onCreate(element.get());
+ }
+ } else {
element->setHooks(hooksIt->_value);
hooksIt->_value->onCreate(element.get());
}
@@ -8289,6 +8298,9 @@ bool VisualElement::readAttribute(MiniscriptThread *thread, DynamicValue &result
} else if (attrib == "centerposition") {
result.setPoint(getCenterPosition());
return true;
+ } else if (attrib == "size") {
+ result.setPoint(Common::Point(_rect.width(), _rect.height()));
+ return true;
} else if (attrib == "width") {
result.setInt(_rect.right - _rect.left);
return true;
@@ -8316,6 +8328,9 @@ MiniscriptInstructionOutcome VisualElement::writeRefAttribute(MiniscriptThread *
} else if (attrib == "position") {
DynamicValueWriteOrRefAttribFuncHelper<VisualElement, &VisualElement::scriptSetPosition, &VisualElement::scriptWriteRefPositionAttribute>::create(this, writeProxy);
return kMiniscriptInstructionOutcomeContinue;
+ } else if (attrib == "size") {
+ DynamicValueWriteOrRefAttribFuncHelper<VisualElement, &VisualElement::scriptSetSize, &VisualElement::scriptWriteRefSizeAttribute>::create(this, writeProxy);
+ return kMiniscriptInstructionOutcomeContinue;
} else if (attrib == "centerposition") {
DynamicValueWriteOrRefAttribFuncHelper<VisualElement, &VisualElement::scriptSetCenterPosition, &VisualElement::scriptWriteRefCenterPositionAttribute>::create(this, writeProxy);
return kMiniscriptInstructionOutcomeContinue;
@@ -8636,12 +8651,37 @@ MiniscriptInstructionOutcome VisualElement::scriptSetCenterPositionY(MiniscriptT
return kMiniscriptInstructionOutcomeContinue;
}
+MiniscriptInstructionOutcome VisualElement::scriptSetSize(MiniscriptThread *thread, const DynamicValue &value) {
+ int32 asInteger = 0;
+ if (value.getType() == DynamicValueTypes::kPoint) {
+ Common::Point pt = value.getPoint();
+
+ if (_rect.bottom - _rect.top != asInteger || _rect.right - _rect.left != asInteger) {
+ _rect.right = _rect.left + pt.x;
+ _rect.bottom = _rect.top + pt.y;
+
+ thread->getRuntime()->setSceneGraphDirty();
+ }
+ } else {
+#ifdef MTROPOLIS_DEBUG_ENABLE
+ if (Debugger *debugger = thread->getRuntime()->debugGetDebugger())
+ debugger->notify(kDebugSeverityError, "'size' value wasn't a point");
+#endif
+ }
+
+ return kMiniscriptInstructionOutcomeContinue;
+}
+
MiniscriptInstructionOutcome VisualElement::scriptSetWidth(MiniscriptThread *thread, const DynamicValue &value) {
int32 asInteger = 0;
if (!value.roundToInt(asInteger))
return kMiniscriptInstructionOutcomeFailed;
- _rect.right = _rect.left + asInteger;
+ if (_rect.right - _rect.left != asInteger) {
+ _rect.right = _rect.left + asInteger;
+
+ thread->getRuntime()->setSceneGraphDirty();
+ }
return kMiniscriptInstructionOutcomeContinue;
}
@@ -8651,7 +8691,11 @@ MiniscriptInstructionOutcome VisualElement::scriptSetHeight(MiniscriptThread *th
if (!value.roundToInt(asInteger))
return kMiniscriptInstructionOutcomeFailed;
- _rect.bottom = _rect.top + asInteger;
+ if (_rect.bottom - _rect.top != asInteger) {
+ _rect.bottom = _rect.top + asInteger;
+
+ thread->getRuntime()->setSceneGraphDirty();
+ }
return kMiniscriptInstructionOutcomeContinue;
}
@@ -8702,6 +8746,18 @@ MiniscriptInstructionOutcome VisualElement::scriptWriteRefCenterPositionAttribut
return kMiniscriptInstructionOutcomeFailed;
}
+MiniscriptInstructionOutcome VisualElement::scriptWriteRefSizeAttribute(MiniscriptThread *thread, DynamicValueWriteProxy &writeProxy, const Common::String &attrib) {
+ if (attrib == "x") {
+ DynamicValueWriteFuncHelper<VisualElement, &VisualElement::scriptSetWidth, true>::create(this, writeProxy);
+ return kMiniscriptInstructionOutcomeContinue;
+ } else if (attrib == "y") {
+ DynamicValueWriteFuncHelper<VisualElement, &VisualElement::scriptSetHeight, true>::create(this, writeProxy);
+ return kMiniscriptInstructionOutcomeContinue;
+ }
+
+ return kMiniscriptInstructionOutcomeFailed;
+}
+
void VisualElement::offsetTranslate(int32 xDelta, int32 yDelta, bool cachedOriginOnly) {
if (!cachedOriginOnly) {
_rect.left += xDelta;
diff --git a/engines/mtropolis/runtime.h b/engines/mtropolis/runtime.h
index 3a772362456..f391877b957 100644
--- a/engines/mtropolis/runtime.h
+++ b/engines/mtropolis/runtime.h
@@ -2126,6 +2126,7 @@ public:
virtual ~StructuralHooks();
virtual void onCreate(Structural *structural);
+ virtual void onPostActivate(Structural *structural);
virtual void onSetPosition(Runtime *runtime, Structural *structural, Common::Point &pt);
};
@@ -2799,14 +2800,17 @@ protected:
MiniscriptInstructionOutcome scriptSetCenterPositionX(MiniscriptThread *thread, const DynamicValue &dest);
MiniscriptInstructionOutcome scriptSetCenterPositionY(MiniscriptThread *thread, const DynamicValue &dest);
MiniscriptInstructionOutcome scriptSetVisibility(MiniscriptThread *thread, const DynamicValue &result);
+ MiniscriptInstructionOutcome scriptSetSize(MiniscriptThread *thread, const DynamicValue &dest);
MiniscriptInstructionOutcome scriptSetWidth(MiniscriptThread *thread, const DynamicValue &dest);
MiniscriptInstructionOutcome scriptSetHeight(MiniscriptThread *thread, const DynamicValue &dest);
MiniscriptInstructionOutcome scriptSetLayer(MiniscriptThread *thread, const DynamicValue &dest);
MiniscriptInstructionOutcome scriptWriteRefPositionAttribute(MiniscriptThread *thread, DynamicValueWriteProxy &writeProxy, const Common::String &attrib);
+ MiniscriptInstructionOutcome scriptWriteRefSizeAttribute(MiniscriptThread *thread, DynamicValueWriteProxy &writeProxy, const Common::String &attrib);
MiniscriptInstructionOutcome scriptWriteRefCenterPositionAttribute(MiniscriptThread *thread, DynamicValueWriteProxy &writeProxy, const Common::String &attrib);
void offsetTranslate(int32 xDelta, int32 yDelta, bool cachedOriginOnly);
+ void resize(int32 width, int32 height);
Common::Point getCenterPosition() const;
More information about the Scummvm-git-logs
mailing list