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

elasota noreply at scummvm.org
Sat Jun 17 01:22:50 UTC 2023


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

Summary:
9603a69f5b MTROPOLIS: Force lists to be the correct type.  Fixes lists becoming object reference lists if the first value inserted 
a5296d340e MTROPOLIS: Improve comments
e7bbee6036 MTROPOLIS: Add warnings for no MPEG support, try to support MTI DVD "Sample" modifier.


Commit: 9603a69f5b428b9f4ecb9d4f6a8da2892baa0e11
    https://github.com/scummvm/scummvm/commit/9603a69f5b428b9f4ecb9d4f6a8da2892baa0e11
Author: elasota (ejlasota at gmail.com)
Date: 2023-06-16T19:45:02-04:00

Commit Message:
MTROPOLIS: Force lists to be the correct type.  Fixes lists becoming object reference lists if the first value inserted was a variable reference.

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


diff --git a/engines/mtropolis/plugin/standard.cpp b/engines/mtropolis/plugin/standard.cpp
index 4389a306035..c089f25b88d 100644
--- a/engines/mtropolis/plugin/standard.cpp
+++ b/engines/mtropolis/plugin/standard.cpp
@@ -2757,6 +2757,8 @@ ListVariableModifier::ListVariableModifier() : VariableModifier(Common::SharedPt
 bool ListVariableModifier::load(const PlugInModifierLoaderContext &context, const Data::Standard::ListVariableModifier &data) {
 	ListVariableStorage *storage = static_cast<ListVariableStorage *>(_storage.get());
 
+	bool loadData = true;
+
 	storage->_preferredContentType = DynamicValueTypes::kInvalid;
 	switch (data.contentsType) {
 	case Data::Standard::ListVariableModifier::kContentsTypeInteger:
@@ -2778,11 +2780,10 @@ bool ListVariableModifier::load(const PlugInModifierLoaderContext &context, cons
 		storage->_preferredContentType = DynamicValueTypes::kObject;
 		if (data.persistentValuesGarbled) {
 			// Ignore and let the game fix it
-			return true;
 		} else {
 			warning("Loading object reference lists from data is not implemented");
-			return true;
 		}
+		loadData = false;
 		break;
 	case Data::Standard::ListVariableModifier::kContentsTypeVector:
 		storage->_preferredContentType = DynamicValueTypes::kVector;
@@ -2795,22 +2796,26 @@ bool ListVariableModifier::load(const PlugInModifierLoaderContext &context, cons
 		return false;
 	}
 
-	if (!data.havePersistentData || data.numValues == 0)
-		return true;
+	storage->_list->forceType(storage->_preferredContentType);
 
-	for (size_t i = 0; i < data.numValues; i++) {
-		DynamicValue dynValue;
-		if (!dynValue.loadConstant(data.values[i]))
-			return false;
+	if (loadData) {
+		if (!data.havePersistentData || data.numValues == 0)
+			return true;
 
-		if (dynValue.getType() != storage->_preferredContentType) {
-			warning("List mod initialization element had the wrong type");
-			return false;
-		}
+		for (size_t i = 0; i < data.numValues; i++) {
+			DynamicValue dynValue;
+			if (!dynValue.loadConstant(data.values[i]))
+				return false;
 
-		if (!storage->_list->setAtIndex(i, dynValue)) {
-			warning("Failed to initialize list modifier, value was rejected");
-			return false;
+			if (dynValue.getType() != storage->_preferredContentType) {
+				warning("List mod initialization element had the wrong type");
+				return false;
+			}
+
+			if (!storage->_list->setAtIndex(i, dynValue)) {
+				warning("Failed to initialize list modifier, value was rejected");
+				return false;
+			}
 		}
 	}
 
@@ -3164,6 +3169,8 @@ Common::SharedPtr<DynamicList> ListVariableStorage::SaveLoad::recursiveReadList(
 	if (stream->err())
 		return nullptr;
 
+	list->forceType(static_cast<DynamicValueTypes::DynamicValueType>(typeCode));
+
 	for (size_t i = 0; i < size; i++) {
 		DynamicValue val;
 
diff --git a/engines/mtropolis/runtime.cpp b/engines/mtropolis/runtime.cpp
index b4b66a55c47..d3dd4a4c1e5 100644
--- a/engines/mtropolis/runtime.cpp
+++ b/engines/mtropolis/runtime.cpp
@@ -705,15 +705,15 @@ bool DynamicListContainer<void>::compareEqual(const DynamicListContainerBase &ot
 DynamicListContainerBase *DynamicListContainer<void>::clone() const {
 	return new DynamicListContainer<void>(*this);
 }
-DynamicList::DynamicList() : _type(DynamicValueTypes::kEmpty), _container(nullptr) {
+DynamicList::DynamicList() : _type(DynamicValueTypes::kUnspecified), _container(nullptr) {
 }
 
-DynamicList::DynamicList(const DynamicList &other) : _type(DynamicValueTypes::kEmpty), _container(nullptr) {
+DynamicList::DynamicList(const DynamicList &other) : _type(DynamicValueTypes::kUnspecified), _container(nullptr) {
 	initFromOther(other);
 }
 
 DynamicList::~DynamicList() {
-	clear();
+	destroyContainer();
 }
 
 DynamicValueTypes::DynamicValueType DynamicList::getType() const {
@@ -832,17 +832,13 @@ Common::Array<ObjectReference> &DynamicList::getObjectReference() {
 
 bool DynamicList::setAtIndex(size_t index, const DynamicValue &value) {
 	if (_type != value.getType()) {
-		if (_container != nullptr && _container->getSize() != 0) {
+		if (_container) {
 			DynamicValue converted;
 			if (!value.convertToType(_type, converted))
 				return false;
 			return setAtIndex(index, converted);
 		} else {
-			clear();
-			changeToType(value.getType());
-
-			assert(_container);
-
+			createContainerAndSetType(value.getType());
 			return _container->setAtIndex(index, value);
 		}
 	} else {
@@ -866,9 +862,7 @@ void DynamicList::deleteAtIndex(size_t index) {
 }
 
 void DynamicList::truncateToSize(size_t sz) {
-	if (sz == 0)
-		clear();
-	else if (_container)
+	if (_container)
 		_container->truncateToSize(sz);
 }
 
@@ -891,6 +885,13 @@ size_t DynamicList::getSize() const {
 		return _container->getSize();
 }
 
+void DynamicList::forceType(DynamicValueTypes::DynamicValueType type) {
+	if (_type != type) {
+		destroyContainer();
+		createContainerAndSetType(type);
+	}
+}
+
 bool DynamicList::dynamicValueToIndex(size_t &outIndex, const DynamicValue &value) {
 	if (value.getType() == DynamicValueTypes::kFloat) {
 		double rounded = floor(value.getFloat() + 0.5);
@@ -909,7 +910,7 @@ bool DynamicList::dynamicValueToIndex(size_t &outIndex, const DynamicValue &valu
 
 DynamicList &DynamicList::operator=(const DynamicList &other) {
 	if (this != &other) {
-		clear();
+		destroyContainer();
 		initFromOther(other);
 	}
 
@@ -961,7 +962,7 @@ void DynamicList::createWriteProxyForIndex(size_t index, DynamicValueWriteProxy
 	proxy.pod.ptrOrOffset = index;
 }
 
-bool DynamicList::changeToType(DynamicValueTypes::DynamicValueType type) {
+bool DynamicList::createContainerAndSetType(DynamicValueTypes::DynamicValueType type) {
 	switch (type) {
 	case DynamicValueTypes::kInvalid:
 		// FIXME: Set _container as per kNull case?
@@ -1005,9 +1006,11 @@ bool DynamicList::changeToType(DynamicValueTypes::DynamicValueType type) {
 	case DynamicValueTypes::kWriteProxy:
 		// FIXME
 		break;
-	case DynamicValueTypes::kEmpty:
+	case DynamicValueTypes::kUnspecified:
 		// FIXME: Set _container as per kNull case?
 		break;
+	default:
+		error("List was set to an invalid type");
 	}
 
 	_type = type;
@@ -1015,19 +1018,19 @@ bool DynamicList::changeToType(DynamicValueTypes::DynamicValueType type) {
 	return true;
 }
 
-void DynamicList::clear() {
-	_type = DynamicValueTypes::kEmpty;
+void DynamicList::destroyContainer() {
 	if (_container)
 		delete _container;
 	_container = nullptr;
+	_type = DynamicValueTypes::kUnspecified;
 }
 
 void DynamicList::initFromOther(const DynamicList &other) {
 	assert(_container == nullptr);
-	assert(_type == DynamicValueTypes::kEmpty);
+	assert(_type == DynamicValueTypes::kUnspecified);
 
-	if (other._type != DynamicValueTypes::kEmpty) {
-		changeToType(other._type);
+	if (other._type != DynamicValueTypes::kUnspecified) {
+		createContainerAndSetType(other._type);
 		_container->setFrom(*other._container);
 	}
 }
@@ -1530,7 +1533,7 @@ bool DynamicValue::operator==(const DynamicValue &other) const {
 void DynamicValue::clear() {
 	switch (_type) {
 	case DynamicValueTypes::kNull:
-	case DynamicValueTypes::kEmpty:
+	case DynamicValueTypes::kUnspecified:
 		_value.destruct<uint64, &ValueUnion::asUnset>();
 		break;
 	case DynamicValueTypes::kInteger:
@@ -1674,7 +1677,7 @@ void DynamicValue::setFromOther(const DynamicValue &other) {
 
 	switch (other._type) {
 	case DynamicValueTypes::kNull:
-	case DynamicValueTypes::kEmpty:
+	case DynamicValueTypes::kUnspecified:
 		clear();
 		_type = other._type;
 		break;
diff --git a/engines/mtropolis/runtime.h b/engines/mtropolis/runtime.h
index 6129694b9e3..c29a7929755 100644
--- a/engines/mtropolis/runtime.h
+++ b/engines/mtropolis/runtime.h
@@ -210,7 +210,7 @@ enum DynamicValueType {
 	kObject = 14,
 	kWriteProxy = 15,
 
-	kEmpty = 16,
+	kUnspecified = 16,
 };
 
 } // End of namespace DynamicValuesTypes
@@ -792,6 +792,8 @@ struct DynamicList {
 	void expandToMinimumSize(size_t sz);
 	size_t getSize() const;
 
+	void forceType(DynamicValueTypes::DynamicValueType type);
+
 	static bool dynamicValueToIndex(size_t &outIndex, const DynamicValue &value);
 
 	DynamicList &operator=(const DynamicList &other);
@@ -814,9 +816,9 @@ private:
 		static MiniscriptInstructionOutcome refAttribIndexed(MiniscriptThread *thread, DynamicValueWriteProxy &proxy, void *objectRef, uintptr ptrOrOffset, const Common::String &attrib, const DynamicValue &index);
 	};
 
-	void clear();
 	void initFromOther(const DynamicList &other);
-	bool changeToType(DynamicValueTypes::DynamicValueType type);
+	void destroyContainer();
+	bool createContainerAndSetType(DynamicValueTypes::DynamicValueType type);
 
 	DynamicValueTypes::DynamicValueType _type;
 	DynamicListContainerBase *_container;


Commit: a5296d340ea3df1aefe383ed9021d317c4b8c340
    https://github.com/scummvm/scummvm/commit/a5296d340ea3df1aefe383ed9021d317c4b8c340
Author: elasota (ejlasota at gmail.com)
Date: 2023-06-16T21:20:18-04:00

Commit Message:
MTROPOLIS: Improve comments

Changed paths:
    engines/mtropolis/mtropolis.h


diff --git a/engines/mtropolis/mtropolis.h b/engines/mtropolis/mtropolis.h
index 6dbf6c3db6f..ecdaa64fdb8 100644
--- a/engines/mtropolis/mtropolis.h
+++ b/engines/mtropolis/mtropolis.h
@@ -32,10 +32,15 @@
 /**
  * This is the namespace of the mTropolis engine.
  *
- * Status of this engine: ???
+ * Status of this engine:
+ *
+ * Supports some games, tends to be buggy outside of those.
+ * Requires a boot list to start a game due to complex installer
+ * configurations.
  *
  * Games using this engine:
  * - Obsidian
+ * - Muppet Treasure Island
  */
 namespace MTropolis {
 


Commit: e7bbee6036d3c77489ca31a7f9518790ed19309d
    https://github.com/scummvm/scummvm/commit/e7bbee6036d3c77489ca31a7f9518790ed19309d
Author: elasota (ejlasota at gmail.com)
Date: 2023-06-16T21:21:18-04:00

Commit Message:
MTROPOLIS: Add warnings for no MPEG support, try to support MTI DVD "Sample" modifier.

Changed paths:
    engines/mtropolis/POTFILES
    engines/mtropolis/detection.h
    engines/mtropolis/detection_tables.h
    engines/mtropolis/mtropolis.cpp
    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/POTFILES b/engines/mtropolis/POTFILES
index 80f412d769e..3c7669e2149 100644
--- a/engines/mtropolis/POTFILES
+++ b/engines/mtropolis/POTFILES
@@ -1,2 +1,3 @@
 engines/mtropolis/metaengine.cpp
 engines/mtropolis/saveload.cpp
+engines/mtropolis/mtropolis.cpp
diff --git a/engines/mtropolis/detection.h b/engines/mtropolis/detection.h
index c0bcdd59b4b..507c8e6743e 100644
--- a/engines/mtropolis/detection.h
+++ b/engines/mtropolis/detection.h
@@ -70,6 +70,11 @@ enum MTropolisGameBootID {
 	MTBOOT_STTGS_DEMO_WIN,
 };
 
+enum MTGameFlag {
+	MTGF_WANT_MPEG_VIDEO = (1 << 0),
+	MTGF_WANT_MPEG_AUDIO = (1 << 1),
+};
+
 struct MTropolisGameDescription {
 	ADGameDescription desc;
 
diff --git a/engines/mtropolis/detection_tables.h b/engines/mtropolis/detection_tables.h
index 8407d8c9fb1..e31ec9460f7 100644
--- a/engines/mtropolis/detection_tables.h
+++ b/engines/mtropolis/detection_tables.h
@@ -450,7 +450,7 @@ static const MTropolisGameDescription gameDescriptions[] = {
 			},
 			Common::EN_ANY,
 			Common::kPlatformWindows,
-			ADGF_UNSTABLE | ADGF_DVD,
+			ADGF_TESTING | ADGF_DVD | MTGF_WANT_MPEG_VIDEO | MTGF_WANT_MPEG_AUDIO,
 			GUIO0()
 		},
 		GID_MTI,
diff --git a/engines/mtropolis/mtropolis.cpp b/engines/mtropolis/mtropolis.cpp
index 8d16472caaf..494584397df 100644
--- a/engines/mtropolis/mtropolis.cpp
+++ b/engines/mtropolis/mtropolis.cpp
@@ -27,10 +27,13 @@
 #include "common/ptr.h"
 #include "common/compression/stuffit.h"
 #include "common/system.h"
+#include "common/translation.h"
 #include "common/formats/winexe.h"
 
 #include "engines/util.h"
 
+#include "gui/message.h"
+
 #include "graphics/cursorman.h"
 #include "graphics/maccursor.h"
 #include "graphics/palette.h"
@@ -103,6 +106,27 @@ void MTropolisEngine::handleEvents() {
 }
 
 Common::Error MTropolisEngine::run() {
+#if !defined(USE_MPEG2)
+	if (_gameDescription->desc.flags & MTGF_WANT_MPEG_VIDEO) {
+		GUI::MessageDialog dialog(
+			_("This game requires MPEG video support for some\n"
+			  "content but MPEG video support was not compiled in.\n"
+			  "The game will still play, but MPEG videos will not work."),
+			_("OK"));
+		dialog.runModal();
+	}
+#endif
+#if !defined(USE_MAD)
+	if (_gameDescription->desc.flags & MTGF_WANT_MPEG_AUDIO) {
+		GUI::MessageDialog dialog(
+			_("This game requires MPEG audio support for some\n"
+			  "content but MPEG audio support was not compiled in.\n"
+			  "The game will still play, but some audio will not work."),
+			_("OK"));
+		dialog.runModal();
+	}
+#endif
+
 	int preferredWidth = 1024;
 	int preferredHeight = 768;
 
diff --git a/engines/mtropolis/plugin/mti.cpp b/engines/mtropolis/plugin/mti.cpp
index 6033f47ca15..b5ef3dbe15d 100644
--- a/engines/mtropolis/plugin/mti.cpp
+++ b/engines/mtropolis/plugin/mti.cpp
@@ -446,13 +446,63 @@ const char *PrintModifier::getDefaultName() const {
 	return "Print Modifier";
 }
 
+SampleModifier::SampleModifier() : _videoNumber(0) {
+}
+
+SampleModifier::~SampleModifier() {
+}
+
+bool SampleModifier::respondsToEvent(const Event &evt) const {
+	return _executeWhen.respondsTo(evt);
+}
+
+VThreadState SampleModifier::consumeMessage(Runtime *runtime, const Common::SharedPtr<MessageProperties> &msg) {
+	if (_executeWhen.respondsTo(msg->getEvent())) {
+		warning("Sample modifier (MPEG video playback) is not implemented.  This would normally play video %i.", static_cast<int>(_videoNumber));
+		return kVThreadReturn;
+	}
+	return kVThreadReturn;
+}
+
+void SampleModifier::disable(Runtime *runtime) {
+}
+
+bool SampleModifier::load(const PlugInModifierLoaderContext &context, const Data::MTI::SampleModifier &data) {
+	if (data.executeWhen.type != Data::PlugInTypeTaggedValue::kEvent)
+		return false;
+
+	if (data.videoNumber.type != Data::PlugInTypeTaggedValue::kInteger)
+		return false;
+
+	_videoNumber = data.videoNumber.value.asInt;
+
+	if (!_executeWhen.load(data.executeWhen.value.asEvent))
+		return false;
+
+	return true;
+}
+
+#ifdef MTROPOLIS_DEBUG_ENABLE
+void SampleModifier::debugInspect(IDebugInspectionReport *report) const {
+}
+#endif
+
+Common::SharedPtr<Modifier> SampleModifier::shallowClone() const {
+	return Common::SharedPtr<Modifier>(new SampleModifier(*this));
+}
+
+const char *SampleModifier::getDefaultName() const {
+	return "Sample Modifier";
+}
+
 MTIPlugIn::MTIPlugIn()
-	: _shanghaiModifierFactory(this), _printModifierFactory(this) {
+	: _shanghaiModifierFactory(this), _printModifierFactory(this), _sampleModifierFactory(this) {
 }
 
 void MTIPlugIn::registerModifiers(IPlugInModifierRegistrar *registrar) const {
 	registrar->registerPlugInModifier("Shanghai", &_shanghaiModifierFactory);
 	registrar->registerPlugInModifier("Print", &_printModifierFactory);
+	registrar->registerPlugInModifier("Sample", &_sampleModifierFactory);
 }
 
 
diff --git a/engines/mtropolis/plugin/mti.h b/engines/mtropolis/plugin/mti.h
index aaf625bd531..aa27da12d56 100644
--- a/engines/mtropolis/plugin/mti.h
+++ b/engines/mtropolis/plugin/mti.h
@@ -118,6 +118,30 @@ private:
 	Common::String _filePath;
 };
 
+class SampleModifier : public Modifier {
+public:
+	SampleModifier();
+	~SampleModifier();
+
+	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::SampleModifier &data);
+
+#ifdef MTROPOLIS_DEBUG_ENABLE
+	const char *debugGetTypeName() const override { return "Sample Modifier"; }
+	void debugInspect(IDebugInspectionReport *report) const override;
+#endif
+
+private:
+	Common::SharedPtr<Modifier> shallowClone() const override;
+	const char *getDefaultName() const override;
+
+	Event _executeWhen;
+	int32 _videoNumber;
+};
+
 
 class MTIPlugIn : public MTropolis::PlugIn {
 public:
@@ -128,6 +152,7 @@ public:
 private:
 	PlugInModifierFactory<ShanghaiModifier, Data::MTI::ShanghaiModifier> _shanghaiModifierFactory;
 	PlugInModifierFactory<PrintModifier, Data::MTI::PrintModifier> _printModifierFactory;
+	PlugInModifierFactory<SampleModifier, Data::MTI::SampleModifier> _sampleModifierFactory;
 };
 
 } // End of namespace MTI
diff --git a/engines/mtropolis/plugin/mti_data.cpp b/engines/mtropolis/plugin/mti_data.cpp
index 2c2f9bf0751..9c7fef4830a 100644
--- a/engines/mtropolis/plugin/mti_data.cpp
+++ b/engines/mtropolis/plugin/mti_data.cpp
@@ -37,7 +37,6 @@ DataReadErrorCode ShanghaiModifier::load(PlugIn &plugIn, const PlugInModifier &p
 	return kDataReadErrorNone;
 }
 
-
 DataReadErrorCode PrintModifier::load(PlugIn &plugIn, const PlugInModifier &prefix, DataReader &reader) {
 	if (prefix.plugInRevision != 0)
 		return kDataReadErrorUnsupportedRevision;
@@ -49,6 +48,16 @@ DataReadErrorCode PrintModifier::load(PlugIn &plugIn, const PlugInModifier &pref
 	return kDataReadErrorNone;
 }
 
+DataReadErrorCode SampleModifier::load(PlugIn &plugIn, const PlugInModifier &prefix, DataReader &reader) {
+	if (prefix.plugInRevision != 0)
+		return kDataReadErrorUnsupportedRevision;
+
+	if (!executeWhen.load(reader) || !videoNumber.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 854e42c507e..dbd34bb7c62 100644
--- a/engines/mtropolis/plugin/mti_data.h
+++ b/engines/mtropolis/plugin/mti_data.h
@@ -53,6 +53,14 @@ protected:
 	DataReadErrorCode load(PlugIn &plugIn, const PlugInModifier &prefix, DataReader &reader) override;
 };
 
+struct SampleModifier : public PlugInModifierData {
+	PlugInTypeTaggedValue executeWhen;
+	PlugInTypeTaggedValue videoNumber;
+
+protected:
+	DataReadErrorCode load(PlugIn &plugIn, const PlugInModifier &prefix, DataReader &reader) override;
+};
+
 } // End of namespace MTI
 
 } // End of namespace Data




More information about the Scummvm-git-logs mailing list