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

csnover csnover at users.noreply.github.com
Fri Sep 8 23:16:41 CEST 2017


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

Summary:
d97f192f45 SCI: Improve array bounds safety check
b5e801379f DEBUGGER: Flush stdout after debugger writes with USE_TEXT_CONSOLE_FOR_DEBUGGER
5bc4b46aa5 COMMON: Add comparator for sorting ArchiveMemberList
4771c41c35 SCI: Add method to get resource patch file extensions
29b338fff7 SCI: Add resource integrity dump command to debugger
17ff41b740 SCI: Use SCI32 naming convention for Audio36/Sync36 patch files in SCI32
3ce5276b9c SCI32: Remove unnecessary calls to hide the virtual hardware cursor
6571111efc SCI32: Detect KQ7 2.00b using platform-specific files
f11b0a4ff5 SCI32: Toggle Phant2 content censoring from game options


Commit: d97f192f45f553a0900b3f6e35af7dc4fb982dfe
    https://github.com/scummvm/scummvm/commit/d97f192f45f553a0900b3f6e35af7dc4fb982dfe
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-09-08T16:02:32-05:00

Commit Message:
SCI: Improve array bounds safety check

There is no practical risk now since the enum and array sizes are
the same, but there is no reason to rely on a separate data
structure to avoid potential out-of-bounds index use here instead
of just checking the array size directly, which is always safe.

Changed paths:
    engines/sci/resource.cpp


diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp
index ee0f389..f64d3ac 100644
--- a/engines/sci/resource.cpp
+++ b/engines/sci/resource.cpp
@@ -141,7 +141,7 @@ static const char *const s_resourceTypeSuffixes[] = {
 };
 
 const char *getResourceTypeName(ResourceType restype) {
-	if (restype != kResourceTypeInvalid)
+	if (restype < ARRAYSIZE(s_resourceTypeNames))
 		return s_resourceTypeNames[restype];
 	else
 		return "invalid";


Commit: b5e801379f5123dfd8195ac3c4b7a8ba4168a458
    https://github.com/scummvm/scummvm/commit/b5e801379f5123dfd8195ac3c4b7a8ba4168a458
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-09-08T16:02:32-05:00

Commit Message:
DEBUGGER: Flush stdout after debugger writes with USE_TEXT_CONSOLE_FOR_DEBUGGER

stdout may be buffered, in which case debugger messages are
delayed until a newline is written. The same kinds of calls to
OSystem::logMessage are flushed, so this just seems to be a simple
omission on this non-default code branch.

Changed paths:
    gui/debugger.cpp


diff --git a/gui/debugger.cpp b/gui/debugger.cpp
index 7595efc..a570d86 100644
--- a/gui/debugger.cpp
+++ b/gui/debugger.cpp
@@ -110,6 +110,7 @@ int Debugger::debugPrintf(const char *format, ...) {
 	count = _debuggerDialog->vprintFormat(1, format, argptr);
 #else
 	count = ::vprintf(format, argptr);
+	::fflush(stdout);
 #endif
 	va_end (argptr);
 	return count;


Commit: 5bc4b46aa56a37fd1539a5f74a06792d803284b1
    https://github.com/scummvm/scummvm/commit/5bc4b46aa56a37fd1539a5f74a06792d803284b1
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-09-08T16:02:32-05:00

Commit Message:
COMMON: Add comparator for sorting ArchiveMemberList

Changed paths:
    common/archive.h


diff --git a/common/archive.h b/common/archive.h
index 9293b93..d76d0c4 100644
--- a/common/archive.h
+++ b/common/archive.h
@@ -53,6 +53,12 @@ public:
 typedef SharedPtr<ArchiveMember> ArchiveMemberPtr;
 typedef List<ArchiveMemberPtr> ArchiveMemberList;
 
+struct ArchiveMemberListComparator {
+	bool operator()(const ArchiveMemberPtr &a, const ArchiveMemberPtr &b) {
+		return a->getName() < b->getName();
+	}
+};
+
 class Archive;
 
 /**


Commit: 4771c41c35979178994bf8f3ad644cfbdcdab331
    https://github.com/scummvm/scummvm/commit/4771c41c35979178994bf8f3ad644cfbdcdab331
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-09-08T16:02:32-05:00

Commit Message:
SCI: Add method to get resource patch file extensions

Changed paths:
    engines/sci/resource.cpp
    engines/sci/resource.h


diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp
index f64d3ac..5448469 100644
--- a/engines/sci/resource.cpp
+++ b/engines/sci/resource.cpp
@@ -147,6 +147,13 @@ const char *getResourceTypeName(ResourceType restype) {
 		return "invalid";
 }
 
+const char *getResourceTypeExtension(ResourceType restype) {
+	if (restype < ARRAYSIZE(s_resourceTypeSuffixes))
+		return s_resourceTypeSuffixes[restype];
+	else
+		return "";
+}
+
 static const ResourceType s_resTypeMapSci0[] = {
 	kResourceTypeView, kResourceTypePic, kResourceTypeScript, kResourceTypeText,          // 0x00-0x03
 	kResourceTypeSound, kResourceTypeMemory, kResourceTypeVocab, kResourceTypeFont,       // 0x04-0x07
diff --git a/engines/sci/resource.h b/engines/sci/resource.h
index 830fe99..e9eaa67 100644
--- a/engines/sci/resource.h
+++ b/engines/sci/resource.h
@@ -129,6 +129,7 @@ enum ResourceType {
 };
 
 const char *getResourceTypeName(ResourceType restype);
+const char *getResourceTypeExtension(ResourceType restype);
 
 enum ResVersion {
 	kResVersionUnknown,


Commit: 29b338fff76ae72457056fc90d99b80dd6bf99a5
    https://github.com/scummvm/scummvm/commit/29b338fff76ae72457056fc90d99b80dd6bf99a5
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-09-08T16:02:32-05:00

Commit Message:
SCI: Add resource integrity dump command to debugger

Changed paths:
    engines/sci/console.cpp
    engines/sci/console.h


diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index a2b065a..4d8ff17 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -117,6 +117,7 @@ Console::Console(SciEngine *engine) : GUI::Debugger(),
 	registerCmd("alloc_list",				WRAP_METHOD(Console, cmdAllocList));
 	registerCmd("hexgrep",			WRAP_METHOD(Console, cmdHexgrep));
 	registerCmd("verify_scripts",		WRAP_METHOD(Console, cmdVerifyScripts));
+	registerCmd("integrity_dump",	WRAP_METHOD(Console, cmdResourceIntegrityDump));
 	// Game
 	registerCmd("save_game",			WRAP_METHOD(Console, cmdSaveGame));
 	registerCmd("restore_game",		WRAP_METHOD(Console, cmdRestoreGame));
@@ -373,6 +374,7 @@ bool Console::cmdHelp(int argc, const char **argv) {
 	debugPrintf(" alloc_list - Lists all allocated resources\n");
 	debugPrintf(" hexgrep - Searches some resources for a particular sequence of bytes, represented as hexadecimal numbers\n");
 	debugPrintf(" verify_scripts - Performs sanity checks on SCI1.1-SCI2.1 game scripts (e.g. if they're up to 64KB in total)\n");
+	debugPrintf(" integrity_dump - Dumps integrity data about resources in the current game to disk\n");
 	debugPrintf("\n");
 	debugPrintf("Game:\n");
 	debugPrintf(" save_game - Saves the current game state to the hard disk\n");
@@ -919,6 +921,113 @@ bool Console::cmdList(int argc, const char **argv) {
 	return true;
 }
 
+bool Console::cmdResourceIntegrityDump(int argc, const char **argv) {
+	if (argc < 2) {
+		debugPrintf("Dumps integrity data about resources in the current game to disk.\n");
+		debugPrintf("Usage: %s <filename> [<skip video file hashing>] [<skip video files altogether>]\n", argv[0]);
+		return true;
+	}
+
+	Common::DumpFile outFile;
+	if (!outFile.open(argv[1])) {
+		debugPrintf("Failed to open output file %s.\n", argv[1]);
+		return true;
+	}
+
+	const bool hashVideoFiles = argc < 3;
+	const bool videoFiles = argc < 4;
+
+	for (int i = 0; i < kResourceTypeInvalid; ++i) {
+		const ResourceType resType = (ResourceType)i;
+
+		// This will list video resources inside of resource bundles even if
+		// video files are skipped, but this seems fine since those files are
+		// small because they were intended to load into memory. (This happens
+		// with VMDs in GK2.)
+		Common::List<ResourceId> resources = _engine->getResMan()->listResources(resType);
+
+		const char *extension;
+		if (videoFiles) {
+			switch (resType) {
+			case kResourceTypeRobot:
+			case kResourceTypeVMD:
+			case kResourceTypeDuck:
+			case kResourceTypeClut: {
+				extension = getResourceTypeExtension(resType);
+				assert(*extension != '\0');
+
+				const Common::String filesGlob = Common::String::format("*.%s", extension).c_str();
+				Common::ArchiveMemberList files;
+				const int numMatches = SearchMan.listMatchingMembers(files, filesGlob);
+				if (numMatches > 0) {
+					Common::ArchiveMemberList::const_iterator it;
+					for (it = files.begin(); it != files.end(); ++it) {
+						const uint resNo = atoi((*it)->getName().c_str());
+						resources.push_back(ResourceId(resType, resNo));
+					}
+				}
+
+				break;
+			}
+			default:
+				extension = "";
+			}
+		}
+
+		if (resources.size()) {
+			Common::sort(resources.begin(), resources.end());
+			Common::List<ResourceId>::const_iterator it;
+			debugPrintf("%s: ", getResourceTypeName(resType));
+			for (it = resources.begin(); it != resources.end(); ++it) {
+				Common::String statusName;
+				if (resType == kResourceTypeAudio36 || resType == kResourceTypeSync36) {
+					statusName = it->toPatchNameBase36();
+				} else {
+					statusName = Common::String::format("%d", it->getNumber());
+				}
+
+				const Common::String resourceName = it->toString();
+
+				Resource *resource = _engine->getResMan()->findResource(*it, false);
+				if (resource) {
+					Common::MemoryReadStream stream = resource->toStream();
+					writeIntegrityDumpLine(statusName, resourceName, outFile, &stream, resource->size(), true);
+				} else if (videoFiles && *extension != '\0') {
+					const Common::String fileName = Common::String::format("%u.%s", it->getNumber(), extension);
+					Common::File file;
+					Common::ReadStream *stream = nullptr;
+					if (file.open(fileName)) {
+						stream = &file;
+					}
+					writeIntegrityDumpLine(statusName, resourceName, outFile, stream, file.size(), hashVideoFiles);
+				}
+			}
+
+			debugPrintf("\n");
+		}
+	}
+
+	const char *otherVideoFiles[] = { "avi", "seq" };
+	for (uint i = 0; i < ARRAYSIZE(otherVideoFiles); ++i) {
+		const char *extension = otherVideoFiles[i];
+
+		Common::ArchiveMemberList files;
+		if (SearchMan.listMatchingMembers(files, Common::String::format("*.%s", extension).c_str()) > 0) {
+			debugPrintf("%s: ", extension);
+			Common::sort(files.begin(), files.end(), Common::ArchiveMemberListComparator());
+			Common::ArchiveMemberList::const_iterator it;
+			for (it = files.begin(); it != files.end(); ++it) {
+				const Common::ArchiveMember &file = **it;
+				Common::ScopedPtr<Common::SeekableReadStream> stream(file.createReadStream());
+				writeIntegrityDumpLine(file.getName(), file.getName(), outFile, stream.get(), stream->size(), hashVideoFiles);
+			}
+			debugPrintf("\n");
+		}
+	}
+
+	return true;
+}
+
 bool Console::cmdAllocList(int argc, const char **argv) {
 	ResourceManager *resMan = _engine->getResMan();
 
@@ -4907,6 +5016,25 @@ void Console::printBitmap(reg_t reg) {
 
 #endif
 
+void Console::writeIntegrityDumpLine(const Common::String &statusName, const Common::String &resourceName, Common::WriteStream &out, Common::ReadStream *const data, const int size, const bool writeHash) {
+	debugPrintf("%s", statusName.c_str());
+
+	out.writeString(resourceName);
+	if (!data) {
+		out.writeString(" ERROR\n");
+		debugPrintf("[ERR] ");
+	} else {
+		out.writeString(Common::String::format(" %d ", size));
+		if (writeHash) {
+			out.writeString(Common::computeStreamMD5AsString(*data));
+		} else {
+			out.writeString("disabled");
+		}
+		out.writeString("\n");
+		debugPrintf("[OK] ");
+	}
+}
+
 static void printChar(byte c) {
 	if (c < 32 || c >= 127)
 		c = '.';
diff --git a/engines/sci/console.h b/engines/sci/console.h
index c467b86..3cc19ad 100644
--- a/engines/sci/console.h
+++ b/engines/sci/console.h
@@ -71,6 +71,7 @@ private:
 	bool cmdResourceInfo(int argc, const char **argv);
 	bool cmdResourceTypes(int argc, const char **argv);
 	bool cmdList(int argc, const char **argv);
+	bool cmdResourceIntegrityDump(int argc, const char **argv);
 	bool cmdAllocList(int argc, const char **argv);
 	bool cmdHexgrep(int argc, const char **argv);
 	bool cmdVerifyScripts(int argc, const char **argv);
@@ -192,6 +193,8 @@ private:
 	void printBitmap(reg_t reg);
 #endif
 
+	void writeIntegrityDumpLine(const Common::String &statusName, const Common::String &resourceName, Common::WriteStream &out, Common::ReadStream *const data, const int size, const bool writeHash);
+
 	SciEngine *_engine;
 	DebugState &_debugState;
 	Common::String _videoFile;


Commit: 17ff41b7400d5983daf899ead0c2657166d3c84a
    https://github.com/scummvm/scummvm/commit/17ff41b7400d5983daf899ead0c2657166d3c84a
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-09-08T16:02:32-05:00

Commit Message:
SCI: Use SCI32 naming convention for Audio36/Sync36 patch files in SCI32

Changed paths:
    engines/sci/resource.h


diff --git a/engines/sci/resource.h b/engines/sci/resource.h
index e9eaa67..9fc9708 100644
--- a/engines/sci/resource.h
+++ b/engines/sci/resource.h
@@ -198,7 +198,11 @@ public:
 	Common::String toPatchNameBase36() const {
 		Common::String output;
 
-		output += (getType() == kResourceTypeAudio36) ? '@' : '#'; // Identifier
+		if (getSciVersion() >= SCI_VERSION_2) {
+			output += (getType() == kResourceTypeAudio36) ? 'A' : 'S'; // Identifier
+		} else {
+			output += (getType() == kResourceTypeAudio36) ? '@' : '#'; // Identifier
+		}
 		output += intToBase36(getNumber(), 3);                     // Map
 		output += intToBase36(getTuple() >> 24, 2);                // Noun
 		output += intToBase36((getTuple() >> 16) & 0xff, 2);       // Verb


Commit: 3ce5276b9cfe776fde752216b26b149e96543c1f
    https://github.com/scummvm/scummvm/commit/3ce5276b9cfe776fde752216b26b149e96543c1f
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-09-08T16:02:32-05:00

Commit Message:
SCI32: Remove unnecessary calls to hide the virtual hardware cursor

Changed paths:
    engines/sci/graphics/cursor32.cpp


diff --git a/engines/sci/graphics/cursor32.cpp b/engines/sci/graphics/cursor32.cpp
index b374e9d..1db7402 100644
--- a/engines/sci/graphics/cursor32.cpp
+++ b/engines/sci/graphics/cursor32.cpp
@@ -35,7 +35,6 @@ GfxCursor32::GfxCursor32() :
 	_hideCount(0),
 	_position(0, 0),
 	_writeToVMAP(false) {
-	CursorMan.showMouse(false);
 }
 
 void GfxCursor32::init(const Buffer &vmap) {
@@ -46,7 +45,6 @@ void GfxCursor32::init(const Buffer &vmap) {
 }
 
 GfxCursor32::~GfxCursor32() {
-	CursorMan.showMouse(true);
 	free(_cursor.data);
 	free(_cursorBack.data);
 	free(_drawBuff1.data);


Commit: 6571111efca8ade4e958b31318ebb5026d30c1f5
    https://github.com/scummvm/scummvm/commit/6571111efca8ade4e958b31318ebb5026d30c1f5
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-09-08T16:02:32-05:00

Commit Message:
SCI32: Detect KQ7 2.00b using platform-specific files

The GOG.com release is missing the AVIs used for the intro &
ending animations in Windows. I'm unaware of any substantive
differences between the DOS and Windows versions otherwise, so
just not allowing Windows to be selected as a platform when the
video files are missing seems like it should be fine. (Same thing
in the opposite direction for a case where the DOS Robot files
are missing, though I don't know of a specific case where that is
a thing with KQ7 2.00b.)

Changed paths:
    engines/sci/detection.cpp
    engines/sci/detection_tables.h


diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp
index 17a1ece..1707f13 100644
--- a/engines/sci/detection.cpp
+++ b/engines/sci/detection.cpp
@@ -519,6 +519,7 @@ static ADGameDescription s_fallbackDesc = {
 static char s_fallbackGameIdBuf[256];
 
 static const char *directoryGlobs[] = {
+	"avi",
 	"english",
 	"french",
 	"german",
diff --git a/engines/sci/detection_tables.h b/engines/sci/detection_tables.h
index 3ee4459..6f539a9 100644
--- a/engines/sci/detection_tables.h
+++ b/engines/sci/detection_tables.h
@@ -1890,6 +1890,14 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 	{"kq7", "", {
 		{"resource.map", 0, "8676b0fbbd7362989a029fe72fea14c6", 18709},
 		{"resource.000", 0, "51c1ead1163e19a2de8f121c39df7a76", 200764100},
+		// Having the same number of files in the detection entries is needed
+		// for the DOS version to have equal priority to the Windows version
+		// that is detected with additional files, and we might as well check
+		// for the DOS-specific files here too since there are at least some
+		// Windows-only releases of this game too
+		{"avi/91.rbt",   0, NULL,                               -1},
+		{"avi/911.rbt",  0, NULL,                               -1},
+		{"avi/912.rbt",  0, NULL,                               -1},
 		AD_LISTEND},
 		Common::EN_ANY, Common::kPlatformDOS, ADGF_TESTING | ADGF_CD, GUIO_KQ7 },
 
@@ -1898,6 +1906,14 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 	{"kq7", "", {
 		{"resource.map", 0, "8676b0fbbd7362989a029fe72fea14c6", 18709},
 		{"resource.000", 0, "51c1ead1163e19a2de8f121c39df7a76", 200764100},
+		// We need to look for these AVIs before enabling the Windows version
+		// because GOG.com releases are missing them. Their contents do not
+		// matter (some users replace them with higher quality versions created
+		// from the rare 1.65c release, which should not cause a detection
+		// failure)
+		{"avi/e108x11.avi",  0, NULL,                           -1},
+		{"avi/e208x11.avi",  0, NULL,                           -1},
+		{"avi/int08x11.avi", 0, NULL,                           -1},
 		AD_LISTEND},
 		Common::EN_ANY, Common::kPlatformWindows, ADGF_TESTING | ADGF_CD, GUIO_KQ7 },
 


Commit: f11b0a4ff53db917dd0d93969540952175923528
    https://github.com/scummvm/scummvm/commit/f11b0a4ff53db917dd0d93969540952175923528
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-09-08T16:03:24-05:00

Commit Message:
SCI32: Toggle Phant2 content censoring from game options

To enable the optional content censoring mode, Phant2 looks
for a RESDUK.PAT file, which is normally placed by the game's
installer if the user chose to enable censorship. If the file
exists, the game reads an unlock password out of the file and
asks the user to enter the password when starting a new game to
create an uncensored game, or to click a "less intense" button
to start the game with censoring. The censorship state of the
game is then persisted in the save game file, and installations
with the RESDUK.PAT file need to enter the password again in
order to restore any of the uncensored saves.

Since we do not have an installer that can enable this feature,
add a game option toggle to enable/disable censoring (for the
releases that have the optional censorship mode) instead so the
censored content feature is available for anyone that wants to use
it. This flag is restored from ScummVM whenever a save game is
loaded, so it can be toggled on or off at any point without
needing a separate save game, unlike in the original interpreter.

Changed paths:
    common/gui_options.cpp
    common/gui_options.h
    engines/sci/detection.cpp
    engines/sci/detection_tables.h
    engines/sci/engine/guest_additions.cpp
    engines/sci/engine/guest_additions.h
    engines/sci/engine/kfile.cpp
    engines/sci/engine/savegame.cpp
    engines/sci/engine/vm.h
    engines/sci/sci.cpp
    engines/sci/sci.h


diff --git a/common/gui_options.cpp b/common/gui_options.cpp
index 500830a..18e02c1 100644
--- a/common/gui_options.cpp
+++ b/common/gui_options.cpp
@@ -83,6 +83,7 @@ const struct GameOpt {
 	// Option strings must not contain substrings of any other options, so
 	// "gameOption10" would be invalid here because it contains "gameOption1"
 	{ GUIO_GAMEOPTIONS10, "gameOptionA" },
+	{ GUIO_GAMEOPTIONS11, "gameOptionB" },
 
 	{ GUIO_NONE, 0 }
 };
diff --git a/common/gui_options.h b/common/gui_options.h
index 6c1aa2f..0813ff1 100644
--- a/common/gui_options.h
+++ b/common/gui_options.h
@@ -75,6 +75,7 @@
 #define GUIO_GAMEOPTIONS8    "\057"
 #define GUIO_GAMEOPTIONS9    "\060"
 #define GUIO_GAMEOPTIONS10   "\061"
+#define GUIO_GAMEOPTIONS11   "\062"
 
 #define GUIO0() (GUIO_NONE)
 #define GUIO1(a) (a)
@@ -85,6 +86,7 @@
 #define GUIO6(a,b,c,d,e,f) (a b c d e f)
 #define GUIO7(a,b,c,d,e,f,g) (a b c d e f g)
 #define GUIO8(a,b,c,d,e,f,g,h) (a b c d e f g h)
+#define GUIO9(a,b,c,d,e,f,g,h,i) (a b c d e f g h i)
 
 namespace Common {
 
diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp
index 1707f13..9ebdfa9 100644
--- a/engines/sci/detection.cpp
+++ b/engines/sci/detection.cpp
@@ -499,6 +499,17 @@ static const ADExtraGuiOptionsMap optionsList[] = {
 		}
 	},
 
+	// Phantasmagoria 2 - content censoring option
+	{
+		GAMEOPTION_ENABLE_CENSORING,
+		{
+			_s("Enable content censoring"),
+			_s("Enable the game's built-in optional content censoring"),
+			"enable_censoring",
+			false
+		}
+	},
+
 	AD_EXTRA_GUI_OPTIONS_TERMINATOR
 };
 
diff --git a/engines/sci/detection_tables.h b/engines/sci/detection_tables.h
index 6f539a9..1f387d5 100644
--- a/engines/sci/detection_tables.h
+++ b/engines/sci/detection_tables.h
@@ -3143,14 +3143,25 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 #undef GUIO_PHANTASMAGORIA
 #undef GUIO_PHANTASMAGORIA_MAC
 
-#define GUIO_PHANTASMAGORIA2 GUIO8(GUIO_NOSUBTITLES, \
+#define GUIO_PHANTASMAGORIA2 GUIO9(GUIO_NOSUBTITLES, \
                                    GUIO_LINKMUSICTOSFX, \
                                    GUIO_LINKSPEECHTOSFX, \
                                    GUIO_NOMIDI, \
                                    GUIO_NOASPECT, \
                                    GAMEOPTION_ORIGINAL_SAVELOAD, \
                                    GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \
-                                   GAMEOPTION_HQ_VIDEO)
+                                   GAMEOPTION_HQ_VIDEO, \
+                                   GAMEOPTION_ENABLE_CENSORING)
+// TODO: Learn which are the censored game editions and give them this GUIO
+// instead
+#define GUIO_PHANTASMAGORIA2_CENSORED GUIO8(GUIO_NOSUBTITLES, \
+                                            GUIO_LINKMUSICTOSFX, \
+                                            GUIO_LINKSPEECHTOSFX, \
+                                            GUIO_NOMIDI, \
+                                            GUIO_NOASPECT, \
+                                            GAMEOPTION_ORIGINAL_SAVELOAD, \
+                                            GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \
+                                            GAMEOPTION_HQ_VIDEO)
 
 	// Some versions of Phantasmagoria 2 were heavily censored.
 	// Censored versions (data files are currently unknown to us): UK, Australia, first English release in Germany
@@ -3249,6 +3260,9 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		AD_LISTEND},
 		Common::JA_JPN, Common::kPlatformWindows, ADGF_CD | ADGF_TESTING, GUIO_PHANTASMAGORIA2 },
 
+#undef GUIO_PHANTASMAGORIA2
+#undef GUIO_PHANTASMAGORIA2_CENSORED
+
 #endif // ENABLE_SCI32
 
 	// Pepper's Adventure In Time 1.000 English
diff --git a/engines/sci/engine/guest_additions.cpp b/engines/sci/engine/guest_additions.cpp
index 792605c..b184887 100644
--- a/engines/sci/engine/guest_additions.cpp
+++ b/engines/sci/engine/guest_additions.cpp
@@ -189,6 +189,12 @@ bool GuestAdditions::kDoSoundMasterVolumeHook(const int volume) const {
 }
 
 #ifdef ENABLE_SCI32
+void GuestAdditions::sciEngineInitGameHook() {
+	if (g_sci->getGameId() == GID_PHANTASMAGORIA2 && Common::checkGameGUIOption(GAMEOPTION_ENABLE_CENSORING, ConfMan.get("guioptions"))) {
+		_state->variables[VAR_GLOBAL][kGlobalVarPhant2CensorshipFlag] = make_reg(0, ConfMan.getBool("enable_censoring"));
+	}
+}
+
 void GuestAdditions::sendSelectorHook(const reg_t sendObj, Selector &selector, reg_t *argp) {
 	if (_features->getMessageTypeSyncStrategy() == kMessageTypeSyncStrategyLSL6Hires) {
 		syncMessageTypeToScummVMUsingLSL6HiresStrategy(sendObj, selector, argp);
diff --git a/engines/sci/engine/guest_additions.h b/engines/sci/engine/guest_additions.h
index 36264b9..7c80c29 100644
--- a/engines/sci/engine/guest_additions.h
+++ b/engines/sci/engine/guest_additions.h
@@ -109,6 +109,11 @@ public:
 
 #ifdef ENABLE_SCI32
 	/**
+	 * Guest additions hook for SciEngine::initGame.
+	 */
+	void sciEngineInitGameHook();
+
+	/**
 	 * Guest additions hook for send_selector.
 	 */
 	void sendSelectorHook(const reg_t sendObj, Selector &selector, reg_t *argp);
diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp
index eb6cacb..79e1894 100644
--- a/engines/sci/engine/kfile.cpp
+++ b/engines/sci/engine/kfile.cpp
@@ -446,6 +446,9 @@ reg_t kFileIOOpen(EngineState *s, int argc, reg_t *argv) {
 				*it = '_';
 			}
 		}
+	} else if (g_sci->getGameId() == GID_PHANTASMAGORIA2 && name == "RESDUK.PAT") {
+		// Ignore the censorship password file in lieu of our game option
+		return SIGNAL_REG;
 	}
 
 	// See kMakeSaveCatName
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index 4ff27ba..d6fab62 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -49,6 +49,7 @@
 #include "sci/sound/music.h"
 
 #ifdef ENABLE_SCI32
+#include "common/gui_options.h"
 #include "sci/engine/guest_additions.h"
 #include "sci/graphics/cursor32.h"
 #include "sci/graphics/frameout.h"
@@ -1282,6 +1283,13 @@ void gamestate_afterRestoreFixUp(EngineState *s, int savegameId) {
 		// It gets disabled in the game's death screen.
 		g_sci->_gfxMenu->kernelSetAttribute(2, 1, SCI_MENU_ATTRIBUTE_ENABLED, TRUE_REG);	// Game -> Save Game
 		break;
+#ifdef ENABLE_SCI32
+	case GID_PHANTASMAGORIA2:
+		if (Common::checkGameGUIOption(GAMEOPTION_ENABLE_CENSORING, ConfMan.get("guioptions"))) {
+			s->variables[VAR_GLOBAL][kGlobalVarPhant2CensorshipFlag] = make_reg(0, ConfMan.getBool("enable_censoring"));
+		}
+		break;
+#endif
 	default:
 		break;
 	}
diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h
index a8ac7b1..67729bf 100644
--- a/engines/sci/engine/vm.h
+++ b/engines/sci/engine/vm.h
@@ -160,6 +160,7 @@ enum GlobalVar {
 	kGlobalVarPhant1DACVolume      = 188, // 0 to 127
 	kGlobalVarLSL6HiresMusicVolume = 194, // 0 to 13
 	kGlobalVarGK1DAC1              = 207, // 0 to 127
+	kGlobalVarPhant2CensorshipFlag = 207,
 	kGlobalVarGK1DAC2              = 208, // 0 to 127
 	kGlobalVarLSL6HiresRestoreTextWindow = 210,
 	kGlobalVarGK1DAC3              = 211, // 0 to 127
diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp
index f5e327c..6ed7411 100644
--- a/engines/sci/sci.cpp
+++ b/engines/sci/sci.cpp
@@ -569,6 +569,10 @@ bool SciEngine::initGame() {
 	// Load game language into printLang property of game object
 	setSciLanguage();
 
+#ifdef ENABLE_SCI32
+	_guestAdditions->sciEngineInitGameHook();
+#endif
+
 	return true;
 }
 
diff --git a/engines/sci/sci.h b/engines/sci/sci.h
index ff3b515..faa1532 100644
--- a/engines/sci/sci.h
+++ b/engines/sci/sci.h
@@ -57,6 +57,7 @@ namespace Sci {
 #define GAMEOPTION_HIGH_RESOLUTION_GRAPHICS GUIO_GAMEOPTIONS8
 #define GAMEOPTION_ENABLE_BLACK_LINED_VIDEO GUIO_GAMEOPTIONS9
 #define GAMEOPTION_HQ_VIDEO                 GUIO_GAMEOPTIONS10
+#define GAMEOPTION_ENABLE_CENSORING         GUIO_GAMEOPTIONS11
 
 struct EngineState;
 class Vocabulary;





More information about the Scummvm-git-logs mailing list