[Scummvm-git-logs] scummvm master -> 9703a497915a79beaca7278e8ab1e81424f1869f

elasota noreply at scummvm.org
Sat Sep 24 21:17:21 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:
a5371bd365 MTROPOLIS: Add MTI print modifier stub
9703a49791 MTROPOLIS: Add path motion modifier V1


Commit: a5371bd3653aa98851652dc60f535b2bebe016d0
    https://github.com/scummvm/scummvm/commit/a5371bd3653aa98851652dc60f535b2bebe016d0
Author: elasota (ejlasota at gmail.com)
Date: 2022-09-24T17:07:20-04:00

Commit Message:
MTROPOLIS: Add MTI print modifier stub

Changed paths:
    engines/mtropolis/plugin/mti.cpp
    engines/mtropolis/plugin/mti.h
    engines/mtropolis/plugin/mti_data.cpp
    engines/mtropolis/plugin/mti_data.h


diff --git a/engines/mtropolis/plugin/mti.cpp b/engines/mtropolis/plugin/mti.cpp
index 3b4c9e4a393..056b16d7411 100644
--- a/engines/mtropolis/plugin/mti.cpp
+++ b/engines/mtropolis/plugin/mti.cpp
@@ -98,13 +98,60 @@ const char *ShanghaiModifier::getDefaultName() const {
 	return "Shanghai Modifier";	// ???
 }
 
+
+PrintModifier::PrintModifier() {
+}
+
+PrintModifier::~PrintModifier() {
+}
+
+bool PrintModifier::respondsToEvent(const Event &evt) const {
+	return _executeWhen.respondsTo(evt);
+}
+
+VThreadState PrintModifier::consumeMessage(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) {
+	warning("Print modifier is not implemented");
+	return kVThreadReturn;
+}
+
+void PrintModifier::disable(Runtime *runtime) {
+}
+
+bool PrintModifier::load(const PlugInModifierLoaderContext &context, const Data::MTI::PrintModifier &data) {
+	if (data.executeWhen.type != Data::PlugInTypeTaggedValue::kEvent)
+		return false;
+
+	if (data.filePath.type != Data::PlugInTypeTaggedValue::kString)
+		return false;
+
+	_filePath = data.executeWhen.str;
+	if (!_executeWhen.load(data.executeWhen.value.asEvent))
+		return false;
+
+	return true;
+}
+
+#ifdef MTROPOLIS_DEBUG_ENABLE
+void PrintModifier::debugInspect(IDebugInspectionReport *report) const {
+}
+#endif
+
+Common::SharedPtr<Modifier> PrintModifier::shallowClone() const {
+	return Common::SharedPtr<Modifier>(new PrintModifier(*this));
+}
+
+const char *PrintModifier::getDefaultName() const {
+	return "Print Modifier";
+}
+
 MTIPlugIn::MTIPlugIn()
-	: _panningModifierFactory(this), _shanghaiModifierFactory(this) {
+	: _panningModifierFactory(this), _shanghaiModifierFactory(this), _printModifierFactory(this) {
 }
 
 void MTIPlugIn::registerModifiers(IPlugInModifierRegistrar *registrar) const {
 	registrar->registerPlugInModifier("panning", &_panningModifierFactory);
 	registrar->registerPlugInModifier("Shanghai", &_shanghaiModifierFactory);
+	registrar->registerPlugInModifier("Print", &_printModifierFactory);
 }
 
 
diff --git a/engines/mtropolis/plugin/mti.h b/engines/mtropolis/plugin/mti.h
index 907a807fef7..bfb8f79f45a 100644
--- a/engines/mtropolis/plugin/mti.h
+++ b/engines/mtropolis/plugin/mti.h
@@ -76,6 +76,30 @@ private:
 	const char *getDefaultName() const override;
 };
 
+class PrintModifier : public Modifier {
+public:
+	PrintModifier();
+	~PrintModifier();
+
+	bool respondsToEvent(const Event &evt) const override;
+	VThreadState consumeMessage(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) override;
+	void disable(Runtime *runtime) override;
+
+	bool load(const PlugInModifierLoaderContext &context, const Data::MTI::PrintModifier &data);
+
+#ifdef MTROPOLIS_DEBUG_ENABLE
+	const char *debugGetTypeName() const override { return "Print Modifier"; }
+	void debugInspect(IDebugInspectionReport *report) const override;
+#endif
+
+private:
+	Common::SharedPtr<Modifier> shallowClone() const override;
+	const char *getDefaultName() const override;
+
+	Event _executeWhen;
+	Common::String _filePath;
+};
+
 
 class MTIPlugIn : public MTropolis::PlugIn {
 public:
@@ -86,6 +110,7 @@ public:
 private:
 	PlugInModifierFactory<PanningModifier, Data::MTI::PanningModifier> _panningModifierFactory;
 	PlugInModifierFactory<ShanghaiModifier, Data::MTI::ShanghaiModifier> _shanghaiModifierFactory;
+	PlugInModifierFactory<PrintModifier, Data::MTI::PrintModifier> _printModifierFactory;
 };
 
 } // End of namespace MTI
diff --git a/engines/mtropolis/plugin/mti_data.cpp b/engines/mtropolis/plugin/mti_data.cpp
index 06cf82039de..4d164aeaa31 100644
--- a/engines/mtropolis/plugin/mti_data.cpp
+++ b/engines/mtropolis/plugin/mti_data.cpp
@@ -48,6 +48,17 @@ DataReadErrorCode ShanghaiModifier::load(PlugIn &plugIn, const PlugInModifier &p
 }
 
 
+DataReadErrorCode PrintModifier::load(PlugIn &plugIn, const PlugInModifier &prefix, DataReader &reader) {
+	if (prefix.plugInRevision != 0)
+		return kDataReadErrorUnsupportedRevision;
+
+	if (!executeWhen.load(reader) || !unknown1Bool.load(reader) || !unknown2Bool.load(reader) ||
+		!unknown3Bool.load(reader) || !filePath.load(reader) || !unknown4Bool.load(reader))
+		return kDataReadErrorReadFailed;
+
+	return kDataReadErrorNone;
+}
+
 } // End of namespace MTI
 
 } // End of namespace Data
diff --git a/engines/mtropolis/plugin/mti_data.h b/engines/mtropolis/plugin/mti_data.h
index 8d3ef59b986..b06cf1c76a7 100644
--- a/engines/mtropolis/plugin/mti_data.h
+++ b/engines/mtropolis/plugin/mti_data.h
@@ -53,6 +53,18 @@ protected:
 	DataReadErrorCode load(PlugIn &plugIn, const PlugInModifier &prefix, DataReader &reader) override;
 };
 
+struct PrintModifier : public PlugInModifierData {
+	PlugInTypeTaggedValue executeWhen;
+	PlugInTypeTaggedValue unknown1Bool;
+	PlugInTypeTaggedValue unknown2Bool;
+	PlugInTypeTaggedValue unknown3Bool;
+	PlugInTypeTaggedValue filePath;
+	PlugInTypeTaggedValue unknown4Bool;
+
+protected:
+	DataReadErrorCode load(PlugIn &plugIn, const PlugInModifier &prefix, DataReader &reader) override;
+};
+
 } // End of namespace MTI
 
 } // End of namespace Data


Commit: 9703a497915a79beaca7278e8ab1e81424f1869f
    https://github.com/scummvm/scummvm/commit/9703a497915a79beaca7278e8ab1e81424f1869f
Author: elasota (ejlasota at gmail.com)
Date: 2022-09-24T17:07:21-04:00

Commit Message:
MTROPOLIS: Add path motion modifier V1

Changed paths:
    engines/mtropolis/data.cpp
    engines/mtropolis/data.h
    engines/mtropolis/modifier_factory.cpp
    engines/mtropolis/modifiers.cpp
    engines/mtropolis/modifiers.h
    engines/mtropolis/runtime.cpp


diff --git a/engines/mtropolis/data.cpp b/engines/mtropolis/data.cpp
index 20ca4257616..a6080bc6e3c 100644
--- a/engines/mtropolis/data.cpp
+++ b/engines/mtropolis/data.cpp
@@ -127,6 +127,7 @@ bool isModifier(DataObjectType type) {
 	case kFloatingPointVariableModifier:
 	case kStringVariableModifier:
 	case kPlugInModifier:
+	case kSoundFadeModifier:
 	case kDebris:
 		return true;
 	default:
@@ -1301,11 +1302,12 @@ DataReadErrorCode SoundEffectModifier::load(DataReader &reader) {
 	return kDataReadErrorNone;
 }
 
-bool PathMotionModifierV2::PointDef::load(DataReader &reader) {
-	if (!point.load(reader)
-		|| !reader.readU32(frame)
-		|| !reader.readU32(frameFlags)
-		|| !reader.readU32(messageFlags)
+PathMotionModifier::PointDefMessageSpec::PointDefMessageSpec() : messageFlags(0), send(Event::createDefault()), unknown11(0),
+	  destination(0), unknown13{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, withSourceLength(0), withStringLength(0) {
+}
+
+bool PathMotionModifier::PointDefMessageSpec::load(DataReader &reader) {
+	if (!reader.readU32(messageFlags)
 		|| !send.load(reader)
 		|| !reader.readU16(unknown11)
 		|| !reader.readU32(destination)
@@ -1320,18 +1322,27 @@ bool PathMotionModifierV2::PointDef::load(DataReader &reader) {
 	return true;
 }
 
+bool PathMotionModifier::PointDef::load(DataReader &reader, bool haveMessageSpec) {
+	if (!point.load(reader) || !reader.readU32(frame) || !reader.readU32(frameFlags))
+		return false;
 
-PathMotionModifierV2::PointDef::PointDef()
-	: point(Point::createDefault()), frame(0), frameFlags(0), messageFlags(0), send(Event::createDefault()), unknown11(0),
-	  destination(0), unknown13{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, withSourceLength(0), withStringLength(0) {
+	if (haveMessageSpec && messageSpec.load(reader))
+		return false;
+
+	return true;
+}
+
+
+PathMotionModifier::PointDef::PointDef()
+	: point(Point::createDefault()), frame(0), frameFlags(0) {
 }
 
-PathMotionModifierV2::PathMotionModifierV2()
+PathMotionModifier::PathMotionModifier(uint version)
 	: flags(0), executeWhen(Event::createDefault()), terminateWhen(Event::createDefault()), unknown2{0, 0}, numPoints(0), unknown3{0, 0, 0, 0},
-	  frameDurationTimes10Million(0), unknown5{0, 0, 0, 0}, unknown6(0) {
+	  frameDurationTimes10Million(0), unknown5{0, 0, 0, 0}, unknown6(0), havePointDefMessageSpecs(version >= 2) {
 }
 
-DataReadErrorCode PathMotionModifierV2::load(DataReader &reader) {
+DataReadErrorCode PathMotionModifier::load(DataReader &reader) {
 	if (_revision != 1001)
 		return kDataReadErrorUnsupportedRevision;
 
@@ -1350,7 +1361,7 @@ DataReadErrorCode PathMotionModifierV2::load(DataReader &reader) {
 	points.resize(numPoints);
 
 	for (size_t i = 0; i < numPoints; i++) {
-		if (!points[i].load(reader))
+		if (!points[i].load(reader, havePointDefMessageSpecs))
 			return kDataReadErrorReadFailed;
 	}
 
@@ -2324,8 +2335,11 @@ DataReadErrorCode loadDataObject(const PlugInModifierRegistry &registry, DataRea
 	case DataObjectTypes::kDragMotionModifier:
 		dataObject = new DragMotionModifier();
 		break;
+	case DataObjectTypes::kPathMotionModifierV1:
+		dataObject = new PathMotionModifier(1);
+		break;
 	case DataObjectTypes::kPathMotionModifierV2:
-		dataObject = new PathMotionModifierV2();
+		dataObject = new PathMotionModifier(2);
 		break;
 	case DataObjectTypes::kVectorMotionModifier:
 		dataObject = new VectorMotionModifier();
diff --git a/engines/mtropolis/data.h b/engines/mtropolis/data.h
index 90b0c261311..19a6d0ebe4f 100644
--- a/engines/mtropolis/data.h
+++ b/engines/mtropolis/data.h
@@ -105,7 +105,7 @@ enum DataObjectType {
 	kReturnModifier							= 0x140,	// NYI
 	kSoundEffectModifier					= 0x1a4,
 	kDragMotionModifier						= 0x208,
-	kPathMotionModifierV1					= 0x21c,	// NYI - Obsolete version
+	kPathMotionModifierV1					= 0x21c,
 	kPathMotionModifierV2					= 0x21b,
 	kVectorMotionModifier					= 0x226,
 	kSceneTransitionModifier				= 0x26c,
@@ -126,6 +126,7 @@ enum DataObjectType {
 	kCursorModifierV1						= 0x3ca,	// NYI - Obsolete version
 	kGradientModifier						= 0x4b0,	// NYI
 	kColorTableModifier						= 0x4c4,
+	kSoundFadeModifier						= 0x4ce,
 	kSaveAndRestoreModifier					= 0x4d8,
 
 	kCompoundVariableModifier				= 0x2c7,
@@ -1087,17 +1088,10 @@ protected:
 	DataReadErrorCode load(DataReader &reader) override;
 };
 
-struct PathMotionModifierV2 : public DataObject {
-	struct PointDef {
-		PointDef();
+struct PathMotionModifier : public DataObject {
+	struct PointDefMessageSpec {
+		PointDefMessageSpec();
 
-		enum FrameFlags {
-			kFrameFlagPlaySequentially = 1,
-		};
-
-		Point point;
-		uint32 frame;
-		uint32 frameFlags;
 		uint32 messageFlags;
 		Event send;
 		uint16 unknown11;
@@ -1113,6 +1107,22 @@ struct PathMotionModifierV2 : public DataObject {
 		bool load(DataReader &reader);
 	};
 
+	struct PointDef {
+		PointDef();
+
+		enum FrameFlags {
+			kFrameFlagPlaySequentially = 1,
+		};
+
+		Point point;
+		uint32 frame;
+		uint32 frameFlags;
+
+		PointDefMessageSpec messageSpec;
+
+		bool load(DataReader &reader, bool haveMessageSpec);
+	};
+
 	enum Flags {
 		kFlagReverse = 0x00100000,
 		kFlagLoop = 0x10000000,
@@ -1120,7 +1130,7 @@ struct PathMotionModifierV2 : public DataObject {
 		kFlagStartAtBeginning = 0x08000000,
 	};
 
-	PathMotionModifierV2();
+	explicit PathMotionModifier(uint version);
 
 	TypicalModifierHeader modHeader;
 	uint32 flags;
@@ -1135,10 +1145,14 @@ struct PathMotionModifierV2 : public DataObject {
 	uint8 unknown5[4];
 	uint32 unknown6;
 
+	bool havePointDefMessageSpecs;
+
 	Common::Array<PointDef> points;
 
 protected:
 	DataReadErrorCode load(DataReader &reader) override;
+
+	uint version;
 };
 
 struct DragMotionModifier : public DataObject {
diff --git a/engines/mtropolis/modifier_factory.cpp b/engines/mtropolis/modifier_factory.cpp
index d825ca9c83b..c8339c3b3d5 100644
--- a/engines/mtropolis/modifier_factory.cpp
+++ b/engines/mtropolis/modifier_factory.cpp
@@ -83,8 +83,9 @@ SIModifierFactory *getModifierFactoryForDataObjectType(const Data::DataObjectTyp
 		return ModifierFactory<ChangeSceneModifier, Data::ChangeSceneModifier>::getInstance();
 	case Data::DataObjectTypes::kSoundEffectModifier:
 		return ModifierFactory<SoundEffectModifier, Data::SoundEffectModifier>::getInstance();
+	case Data::DataObjectTypes::kPathMotionModifierV1:
 	case Data::DataObjectTypes::kPathMotionModifierV2:
-		return ModifierFactory<PathMotionModifierV2, Data::PathMotionModifierV2>::getInstance();
+		return ModifierFactory<PathMotionModifier, Data::PathMotionModifier>::getInstance();
 	case Data::DataObjectTypes::kDragMotionModifier:
 		return ModifierFactory<DragMotionModifier, Data::DragMotionModifier>::getInstance();
 	case Data::DataObjectTypes::kVectorMotionModifier:
diff --git a/engines/mtropolis/modifiers.cpp b/engines/mtropolis/modifiers.cpp
index dcbe927b50d..5f0669432a9 100644
--- a/engines/mtropolis/modifiers.cpp
+++ b/engines/mtropolis/modifiers.cpp
@@ -667,48 +667,56 @@ const char *SoundEffectModifier::getDefaultName() const {
 	return "Sound Effect Modifier";
 }
 
-PathMotionModifierV2::PointDef::PointDef() : frame(0), useFrame(false) {
+PathMotionModifier::PointDef::PointDef() : frame(0), useFrame(false) {
 }
 
-PathMotionModifierV2::PathMotionModifierV2()
+PathMotionModifier::PathMotionModifier()
 	: _reverse(false), _loop(false), _alternate(false),
 	  _startAtBeginning(false), _frameDurationTimes10Million(0) {
 }
 
-bool PathMotionModifierV2::load(ModifierLoaderContext &context, const Data::PathMotionModifierV2 &data) {
+bool PathMotionModifier::load(ModifierLoaderContext &context, const Data::PathMotionModifier &data) {
 	if (!loadTypicalHeader(data.modHeader))
 		return false;
 
 	if (!_executeWhen.load(data.executeWhen) || !_terminateWhen.load(data.terminateWhen))
 		return false;
 
-	_reverse = ((data.flags & Data::PathMotionModifierV2::kFlagReverse) != 0);
-	_loop = ((data.flags & Data::PathMotionModifierV2::kFlagLoop) != 0);
-	_alternate = ((data.flags & Data::PathMotionModifierV2::kFlagAlternate) != 0);
-	_startAtBeginning = ((data.flags & Data::PathMotionModifierV2::kFlagStartAtBeginning) != 0);
+	_reverse = ((data.flags & Data::PathMotionModifier::kFlagReverse) != 0);
+	_loop = ((data.flags & Data::PathMotionModifier::kFlagLoop) != 0);
+	_alternate = ((data.flags & Data::PathMotionModifier::kFlagAlternate) != 0);
+	_startAtBeginning = ((data.flags & Data::PathMotionModifier::kFlagStartAtBeginning) != 0);
 
 	_frameDurationTimes10Million = data.frameDurationTimes10Million;
 
 	_points.resize(data.numPoints);
 
 	for (size_t i = 0; i < _points.size(); i++) {
-		const Data::PathMotionModifierV2::PointDef &inPoint = data.points[i];
+		const Data::PathMotionModifier::PointDef &inPoint = data.points[i];
 		PointDef &outPoint = _points[i];
 
 		outPoint.frame = inPoint.frame;
-		outPoint.useFrame = ((inPoint.frameFlags & Data::PathMotionModifierV2::PointDef::kFrameFlagPlaySequentially) != 0);
-		if (!inPoint.point.toScummVMPoint(outPoint.point) || !outPoint.sendSpec.load(inPoint.send, inPoint.messageFlags, inPoint.with, inPoint.withSource, inPoint.withString, inPoint.destination))
+		outPoint.useFrame = ((inPoint.frameFlags & Data::PathMotionModifier::PointDef::kFrameFlagPlaySequentially) != 0);
+		if (!inPoint.point.toScummVMPoint(outPoint.point))
 			return false;
+
+		if (data.havePointDefMessageSpecs) {
+			const Data::PathMotionModifier::PointDefMessageSpec &messageSpec = inPoint.messageSpec;
+			if (!outPoint.sendSpec.load(messageSpec.send, messageSpec.messageFlags, messageSpec.with, messageSpec.withSource, messageSpec.withString, messageSpec.destination))
+				return false;
+		} else {
+			outPoint.sendSpec.destination = kMessageDestNone;
+		}
 	}
 
 	return true;
 }
 
-bool PathMotionModifierV2::respondsToEvent(const Event &evt) const {
+bool PathMotionModifier::respondsToEvent(const Event &evt) const {
 	return _executeWhen.respondsTo(evt) || _terminateWhen.respondsTo(evt);
 }
 
-VThreadState PathMotionModifierV2::consumeMessage(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) {
+VThreadState PathMotionModifier::consumeMessage(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) {
 	if (_executeWhen.respondsTo(msg->getEvent())) {
 #ifdef MTROPOLIS_DEBUG_ENABLE
 		if (Debugger *debugger = runtime->debugGetDebugger())
@@ -726,20 +734,20 @@ VThreadState PathMotionModifierV2::consumeMessage(Runtime *runtime, const Common
 	return kVThreadReturn;
 }
 
-void PathMotionModifierV2::disable(Runtime *runtime) {
+void PathMotionModifier::disable(Runtime *runtime) {
 #ifdef MTROPOLIS_DEBUG_ENABLE
 	if (Debugger *debugger = runtime->debugGetDebugger())
 		debugger->notify(kDebugSeverityWarning, "Path motion modifier was supposed to terminate, but this isn't implemented yet");
 #endif
 }
 
-Common::SharedPtr<Modifier> PathMotionModifierV2::shallowClone() const {
-	Common::SharedPtr<PathMotionModifierV2> clone(new PathMotionModifierV2(*this));
+Common::SharedPtr<Modifier> PathMotionModifier::shallowClone() const {
+	Common::SharedPtr<PathMotionModifier> clone(new PathMotionModifier(*this));
 	clone->_incomingData = DynamicValue();
 	return clone;
 }
 
-const char *PathMotionModifierV2::getDefaultName() const {
+const char *PathMotionModifier::getDefaultName() const {
 	return "Path Motion Modifier";
 }
 
diff --git a/engines/mtropolis/modifiers.h b/engines/mtropolis/modifiers.h
index 005f29d6913..126be254a59 100644
--- a/engines/mtropolis/modifiers.h
+++ b/engines/mtropolis/modifiers.h
@@ -310,11 +310,11 @@ private:
 	Common::SharedPtr<AudioPlayer> _player;
 };
 
-class PathMotionModifierV2 : public Modifier {
+class PathMotionModifier : public Modifier {
 public:
-	PathMotionModifierV2();
+	PathMotionModifier();
 
-	bool load(ModifierLoaderContext &context, const Data::PathMotionModifierV2 &data);
+	bool load(ModifierLoaderContext &context, const Data::PathMotionModifier &data);
 
 	bool respondsToEvent(const Event &evt) const override;
 	VThreadState consumeMessage(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) override;
diff --git a/engines/mtropolis/runtime.cpp b/engines/mtropolis/runtime.cpp
index 7537a92a32e..026aab84955 100644
--- a/engines/mtropolis/runtime.cpp
+++ b/engines/mtropolis/runtime.cpp
@@ -1824,7 +1824,7 @@ void DynamicValueWriteObjectHelper::create(RuntimeObject *obj, DynamicValueWrite
 	proxy.pod.ptrOrOffset = 0;
 }
 
-MessengerSendSpec::MessengerSendSpec() : destination(0), _linkType(kLinkTypeNotYetLinked) {
+MessengerSendSpec::MessengerSendSpec() : destination(kMessageDestNone), _linkType(kLinkTypeNotYetLinked) {
 }
 
 bool MessengerSendSpec::load(const Data::Event &dataEvent, uint32 dataMessageFlags, const Data::InternalTypeTaggedValue &dataLocator, const Common::String &dataWithSource, const Common::String &dataWithString, uint32 dataDestination) {




More information about the Scummvm-git-logs mailing list