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

dreammaster paulfgilbert at gmail.com
Mon Jun 22 03:35:26 UTC 2020


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:
a63c614f4a GLK: Adding testing/unstable flagging for sub-engines


Commit: a63c614f4a4a6d792838fc52ea54704e7345cf92
    https://github.com/scummvm/scummvm/commit/a63c614f4a4a6d792838fc52ea54704e7345cf92
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-06-21T20:35:07-07:00

Commit Message:
GLK: Adding testing/unstable flagging for sub-engines

Changed paths:
    engines/glk/comprehend/detection.cpp
    engines/glk/detection.cpp
    engines/glk/detection.h
    engines/glk/frotz/detection.cpp
    engines/glk/tads/detection.cpp


diff --git a/engines/glk/comprehend/detection.cpp b/engines/glk/comprehend/detection.cpp
index 5621f581f1..83931bebf3 100644
--- a/engines/glk/comprehend/detection.cpp
+++ b/engines/glk/comprehend/detection.cpp
@@ -37,8 +37,11 @@ void ComprehendMetaEngine::getSupportedGames(PlainGameList &games) {
 
 GameDescriptor ComprehendMetaEngine::findGame(const char *gameId) {
 	for (const PlainGameDescriptor *pd = COMPREHEND_GAME_LIST; pd->gameId; ++pd) {
-		if (!strcmp(gameId, pd->gameId))
-			return *pd;
+		if (!strcmp(gameId, pd->gameId)) {
+			GameDescriptor gd = *pd;
+			gd._supportLevel = kUnstableGame;
+			return gd;
+		}
 	}
 
 	return GameDescriptor::empty();
diff --git a/engines/glk/detection.cpp b/engines/glk/detection.cpp
index 53919f2e0a..0f10e4463a 100644
--- a/engines/glk/detection.cpp
+++ b/engines/glk/detection.cpp
@@ -69,29 +69,35 @@
 
 namespace Glk {
 
-GlkDetectedGame::GlkDetectedGame(const char *id, const char *desc, const Common::String &filename) :
+GlkDetectedGame::GlkDetectedGame(const char *id, const char *desc, const Common::String &filename,
+		GameSupportLevel supportLevel) :
 		DetectedGame("glk", id, desc, Common::EN_ANY, Common::kPlatformUnknown) {
 	setGUIOptions(GUIO3(GUIO_NOSPEECH, GUIO_NOMUSIC, GUIO_NOSUBTITLES));
+	gameSupportLevel = supportLevel;
 	addExtraEntry("filename", filename);
 }
 
 GlkDetectedGame::GlkDetectedGame(const char *id, const char *desc, const Common::String &filename,
-		Common::Language lang) : DetectedGame("glk", id, desc, lang, Common::kPlatformUnknown) {
+		Common::Language lang, GameSupportLevel supportLevel) : DetectedGame("glk", id, desc, lang, Common::kPlatformUnknown) {
 	setGUIOptions(GUIO3(GUIO_NOSPEECH, GUIO_NOMUSIC, GUIO_NOSUBTITLES));
+	gameSupportLevel = supportLevel;
 	addExtraEntry("filename", filename);
 }
 
 GlkDetectedGame::GlkDetectedGame(const char *id, const char *desc, const char *xtra,
-		const Common::String &filename, Common::Language lang) :
+		const Common::String &filename, Common::Language lang,
+		GameSupportLevel supportLevel) :
 		DetectedGame("glk", id, desc, lang, Common::kPlatformUnknown, xtra) {
 	setGUIOptions(GUIO3(GUIO_NOSPEECH, GUIO_NOMUSIC, GUIO_NOSUBTITLES));
+	gameSupportLevel = supportLevel;
 	addExtraEntry("filename", filename);
 }
 
 GlkDetectedGame::GlkDetectedGame(const char *id, const char *desc, const Common::String &filename,
-		const Common::String &md5, size_t filesize) :
+		const Common::String &md5, size_t filesize, GameSupportLevel supportLevel) :
 		DetectedGame("glk", id, desc, Common::UNK_LANG, Common::kPlatformUnknown) {
 	setGUIOptions(GUIO3(GUIO_NOSPEECH, GUIO_NOMUSIC, GUIO_NOSUBTITLES));
+	gameSupportLevel = supportLevel;
 	addExtraEntry("filename", filename);
 
 	canBeAdded = true;
@@ -123,13 +129,33 @@ bool Glk::GlkEngine::hasFeature(EngineFeature f) const {
 	    (f == kSupportsSavingDuringRuntime);
 }
 
-template<class META, class ENG>Engine *create(OSystem *syst, Glk::GlkGameDescription &gameDesc) {
+bool isGameAllowed(GameSupportLevel supportLevel) {
+	bool showTestingWarning = false;
+#ifdef RELEASE_BUILD
+	showTestingWarning = true;
+#endif
+
+	if (((supportLevel == kUnstableGame
+		|| (supportLevel == kTestingGame && showTestingWarning)))
+		&& !Engine::warnUserAboutUnsupportedGame())
+		return false;
+
+	return true;
+}
+
+template<class META, class ENG>bool create(OSystem *syst,
+		Glk::GlkGameDescription &gameDesc, Engine *&engine) {
+
 	Glk::GameDescriptor gd = META::findGame(gameDesc._gameId.c_str());
 	if (gd._description) {
+		if (!isGameAllowed(gd._supportLevel))
+			return true;
+
 		gameDesc._options = gd._options;
-		return new ENG(syst, gameDesc);
+		engine = new ENG(syst, gameDesc);
+		return true;
 	} else {
-		return nullptr;
+		return false;
 	}
 }
 
@@ -167,31 +193,33 @@ Common::Error GlkMetaEngine::createInstance(OSystem *syst, Engine **engine) cons
 
 	// Create the correct engine
 	*engine = nullptr;
-	if ((*engine = create<Glk::Adrift::AdriftMetaEngine, Glk::Adrift::Adrift>(syst, gameDesc)) != nullptr) {}
-	else if ((*engine = create<Glk::AdvSys::AdvSysMetaEngine, Glk::AdvSys::AdvSys>(syst, gameDesc)) != nullptr) {}
-	else if ((*engine = create<Glk::AGT::AGTMetaEngine, Glk::AGT::AGT>(syst, gameDesc)) != nullptr) {}
-	else if ((*engine = create<Glk::Alan2::Alan2MetaEngine, Glk::Alan2::Alan2>(syst, gameDesc)) != nullptr) {}
-	else if ((*engine = create<Glk::Alan3::Alan3MetaEngine, Glk::Alan3::Alan3>(syst, gameDesc)) != nullptr) {}
-	else if ((*engine = create<Glk::Archetype::ArchetypeMetaEngine, Glk::Archetype::Archetype>(syst, gameDesc)) != nullptr) {}
-	else if ((*engine = create<Glk::Comprehend::ComprehendMetaEngine, Glk::Comprehend::Comprehend>(syst, gameDesc)) != nullptr) {}
-	else if ((*engine = create<Glk::Frotz::FrotzMetaEngine, Glk::Frotz::Frotz>(syst, gameDesc)) != nullptr) {}
-	else if ((*engine = create<Glk::Glulxe::GlulxeMetaEngine, Glk::Glulxe::Glulxe>(syst, gameDesc)) != nullptr) {}
-	else if ((*engine = create<Glk::Hugo::HugoMetaEngine, Glk::Hugo::Hugo>(syst, gameDesc)) != nullptr) {}
-	else if ((*engine = create<Glk::JACL::JACLMetaEngine, Glk::JACL::JACL>(syst, gameDesc)) != nullptr) {}
-	else if ((*engine = create<Glk::Level9::Level9MetaEngine, Glk::Level9::Level9>(syst, gameDesc)) != nullptr) {}
-	else if ((*engine = create<Glk::Magnetic::MagneticMetaEngine, Glk::Magnetic::Magnetic>(syst, gameDesc)) != nullptr) {}
-	else if ((*engine = create<Glk::Quest::QuestMetaEngine, Glk::Quest::Quest>(syst, gameDesc)) != nullptr) {}
-	else if ((*engine = create<Glk::Scott::ScottMetaEngine, Glk::Scott::Scott>(syst, gameDesc)) != nullptr) {}
+	if ((create<Glk::Adrift::AdriftMetaEngine, Glk::Adrift::Adrift>(syst, gameDesc, *engine))) {}
+	else if ((create<Glk::AdvSys::AdvSysMetaEngine, Glk::AdvSys::AdvSys>(syst, gameDesc, *engine))) {}
+	else if ((create<Glk::AGT::AGTMetaEngine, Glk::AGT::AGT>(syst, gameDesc, *engine))) {}
+	else if ((create<Glk::Alan2::Alan2MetaEngine, Glk::Alan2::Alan2>(syst, gameDesc, *engine))) {}
+	else if ((create<Glk::Alan3::Alan3MetaEngine, Glk::Alan3::Alan3>(syst, gameDesc, *engine))) {}
+	else if ((create<Glk::Archetype::ArchetypeMetaEngine, Glk::Archetype::Archetype>(syst, gameDesc, *engine))) {}
+	else if ((create<Glk::Comprehend::ComprehendMetaEngine, Glk::Comprehend::Comprehend>(syst, gameDesc, *engine))) {}
+	else if ((create<Glk::Frotz::FrotzMetaEngine, Glk::Frotz::Frotz>(syst, gameDesc, *engine))) {}
+	else if ((create<Glk::Glulxe::GlulxeMetaEngine, Glk::Glulxe::Glulxe>(syst, gameDesc, *engine))) {}
+	else if ((create<Glk::Hugo::HugoMetaEngine, Glk::Hugo::Hugo>(syst, gameDesc, *engine))) {}
+	else if ((create<Glk::JACL::JACLMetaEngine, Glk::JACL::JACL>(syst, gameDesc, *engine))) {}
+	else if ((create<Glk::Level9::Level9MetaEngine, Glk::Level9::Level9>(syst, gameDesc, *engine))) {}
+	else if ((create<Glk::Magnetic::MagneticMetaEngine, Glk::Magnetic::Magnetic>(syst, gameDesc, *engine))) {}
+	else if ((create<Glk::Quest::QuestMetaEngine, Glk::Quest::Quest>(syst, gameDesc, *engine))) {}
+	else if ((create<Glk::Scott::ScottMetaEngine, Glk::Scott::Scott>(syst, gameDesc, *engine))) {}
 	else if ((td = Glk::TADS::TADSMetaEngine::findGame(gameDesc._gameId.c_str()))._description) {
-		if (td._options & Glk::TADS::OPTION_TADS3)
-			*engine = new Glk::TADS::TADS3::TADS3(syst, gameDesc);
+		if (!isGameAllowed(td._supportLevel))
+			return Common::kUserCanceled;
+		else if (td._options & Glk::TADS::OPTION_TADS3)
+			new Glk::TADS::TADS3::TADS3(syst, gameDesc);
 		else
-			*engine = new Glk::TADS::TADS2::TADS2(syst, gameDesc);
+			new Glk::TADS::TADS2::TADS2(syst, gameDesc);
 	} else {
 		return Common::kNoGameDataFoundError;
 	}
 
-	return Common::kNoError;
+	return *engine ? Common::kNoError : Common::kUserCanceled;
 }
 
 Common::String GlkMetaEngine::findFileByGameId(const Common::String &gameId) const {
diff --git a/engines/glk/detection.h b/engines/glk/detection.h
index 4575b27595..d61b1a6639 100644
--- a/engines/glk/detection.h
+++ b/engines/glk/detection.h
@@ -88,11 +88,13 @@ struct GameDescriptor {
 	const char *_gameId;
 	const char *_description;
 	uint _options;
+	GameSupportLevel _supportLevel;
 
 	GameDescriptor(const char *gameId, const char *description, uint options) :
-		_gameId(gameId), _description(description), _options(options) {}
-	GameDescriptor(const PlainGameDescriptor &gd) : _gameId(gd.gameId), _description(gd.description),
-		_options(0) {}
+		_gameId(gameId), _description(description), _options(options),
+		_supportLevel(kTestingGame) {}
+	GameDescriptor(const PlainGameDescriptor &gd) : _gameId(gd.gameId),
+		_description(gd.description), _options(0), _supportLevel(kTestingGame) {}
 
 	static PlainGameDescriptor empty() {
 		return GameDescriptor(nullptr, nullptr, 0);
@@ -111,13 +113,15 @@ struct GameDescriptor {
  */
 class GlkDetectedGame : public DetectedGame {
 public:
-	GlkDetectedGame(const char *id, const char *desc, const Common::String &filename);
 	GlkDetectedGame(const char *id, const char *desc, const Common::String &filename,
-		Common::Language lang);
+		GameSupportLevel supportLevel = kTestingGame);
 	GlkDetectedGame(const char *id, const char *desc, const Common::String &filename,
-		const Common::String &md5, size_t filesize);
-	GlkDetectedGame(const char *id, const char *desc, const char *extra, const Common::String &filename,
-		Common::Language lang);
+		Common::Language lang, GameSupportLevel supportLevel = kTestingGame);
+	GlkDetectedGame(const char *id, const char *desc, const Common::String &filename,
+		const Common::String &md5, size_t filesize, GameSupportLevel supportLevel = kTestingGame);
+	GlkDetectedGame(const char *id, const char *desc, const char *extra,
+		const Common::String &filename, Common::Language lang,
+		GameSupportLevel supportLevel = kTestingGame);
 };
 
 /**
diff --git a/engines/glk/frotz/detection.cpp b/engines/glk/frotz/detection.cpp
index f699c832a9..a3b70ed305 100644
--- a/engines/glk/frotz/detection.cpp
+++ b/engines/glk/frotz/detection.cpp
@@ -44,6 +44,13 @@ GameDescriptor FrotzMetaEngine::findGame(const char *gameId) {
 		if (!strcmp(gameId, pd->gameId)) {
 			GameDescriptor gd(*pd);
 			gd._options |= OPTION_INFOCOM;
+
+			if (!strcmp(gameId, "questforexcalibur") ||
+				!strcmp(gameId, "journey") ||
+				!strcmp(gameId, "shogun") ||
+				!strcmp(gameId, "zork0"))
+				gd._supportLevel = kUnstableGame;
+
 			return gd;
 		}
 	}
diff --git a/engines/glk/tads/detection.cpp b/engines/glk/tads/detection.cpp
index 9c0c5eb6bf..fdda43362f 100644
--- a/engines/glk/tads/detection.cpp
+++ b/engines/glk/tads/detection.cpp
@@ -43,6 +43,7 @@ GameDescriptor TADSMetaEngine::findGame(const char *gameId) {
 		if (!strcmp(gameId, pd->gameId)) {
 			GameDescriptor gd = *pd;
 			gd._options = OPTION_TADS2;
+			gd._supportLevel = kUnstableGame;
 			return gd;
 		}
 	}
@@ -51,6 +52,7 @@ GameDescriptor TADSMetaEngine::findGame(const char *gameId) {
 		if (!strcmp(gameId, pd->gameId)) {
 			GameDescriptor gd = *pd;
 			gd._options = OPTION_TADS3;
+			gd._supportLevel = kUnstableGame;
 			return gd;
 		}
 	}




More information about the Scummvm-git-logs mailing list