[Scummvm-cvs-logs] SF.net SVN: scummvm:[52430] scummvm/trunk/engines/sci

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Sun Aug 29 02:17:56 CEST 2010


Revision: 52430
          http://scummvm.svn.sourceforge.net/scummvm/?rev=52430&view=rev
Author:   thebluegr
Date:     2010-08-29 00:17:56 +0000 (Sun, 29 Aug 2010)

Log Message:
-----------
SCI: Added proper handling of QFG exported character files.

Now, QFG2, 3 and 4 may read exported characters from all
other QFG games, like the originals did. Fixes bug
#3054692 - "QFG2/QFG3 Import issues".

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kfile.cpp
    scummvm/trunk/engines/sci/sci.cpp
    scummvm/trunk/engines/sci/sci.h

Modified: scummvm/trunk/engines/sci/engine/kfile.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kfile.cpp	2010-08-28 21:49:20 UTC (rev 52429)
+++ scummvm/trunk/engines/sci/engine/kfile.cpp	2010-08-29 00:17:56 UTC (rev 52430)
@@ -812,6 +812,20 @@
 		return SIGNAL_REG;
 	}
 	debugC(2, kDebugLevelFile, "kFileIO(open): %s, 0x%x", name.c_str(), mode);
+
+	// Since we're not wrapping/unwrapping save files for QFG import screens,
+	// the name of the save file will almost certainly be over 12 characters in
+	// length. Compensate for that fact here, by cutting off the last character
+	// and searching for the file via the first 11 characters
+	if (g_sci->isQFGImportScreen()) {
+		name.deleteLastChar();
+		Common::String pattern = name + "*";
+
+		Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
+		Common::StringArray saveNames = saveFileMan->listSavefiles(pattern);
+		name = saveNames.size() > 0 ? saveNames[0] : name;
+	}
+
 	return file_open(s, name.c_str(), mode);
 }
 
@@ -945,6 +959,12 @@
 	int attr = argv[2].toUint16(); // We won't use this, Win32 might, though...
 	debugC(2, kDebugLevelFile, "kFileIO(findFirst): %s, 0x%x", mask.c_str(), attr);
 
+	// Change the file mask in QFG character import screens. The game
+	// is looking for *.*, but that may well include other files as well,
+	// thus limit the file mask to only include exported characters.
+	if (g_sci->isQFGImportScreen())
+		mask = "qfg*.sav";
+
 	// QfG3 uses "/\*.*" for the character import, QfG4 uses "/\*"
 	if (mask.hasPrefix("/\\")) {
 		mask.deleteChar(0);

Modified: scummvm/trunk/engines/sci/sci.cpp
===================================================================
--- scummvm/trunk/engines/sci/sci.cpp	2010-08-28 21:49:20 UTC (rev 52429)
+++ scummvm/trunk/engines/sci/sci.cpp	2010-08-29 00:17:56 UTC (rev 52430)
@@ -637,36 +637,40 @@
 }
 
 Common::String SciEngine::getFilePrefix() const {
-	if (_gameId == GID_QFG2) {
-		// Quest for Glory 2 wants to read files from Quest for Glory 1 (EGA/VGA) to import character data
-		if (_gamestate->currentRoomNumber() == 805) {
-			// Check if there are any QFG1VGA games - bug #3054613
-			Common::StringArray saveNames = g_engine->getSaveFileManager()->listSavefiles("qfg1vga-*.sav");
-			return (saveNames.size() > 0) ? "qfg1vga" : "qfg1";
-		}
-	} else if (_gameId == GID_QFG3) {
-		// Quest for Glory 3 wants to read files from Quest for Glory 2 to import character data
-		if (_gamestate->currentRoomNumber() == 54)
-			return "qfg2";
-	} else if (_gameId == GID_QFG4) {
-		// Quest for Glory 4 wants to read files from Quest for Glory 3 to import character data
-		if (_gamestate->currentRoomNumber() == 54)
-			return "qfg3";
-	}
 	return _targetName;
 }
 
 Common::String SciEngine::wrapFilename(const Common::String &name) const {
-	return getFilePrefix() + "-" + name;
+	// Do not wrap the game prefix when reading files in QFG import screens.
+	// That way, we can read exported characters from all QFG games, as
+	// intended.
+	return !isQFGImportScreen() ? getFilePrefix() + "-" + name : name;
 }
 
 Common::String SciEngine::unwrapFilename(const Common::String &name) const {
 	Common::String prefix = getFilePrefix() + "-";
-	if (name.hasPrefix(prefix.c_str()))
+	// Do not unwrap the file name when reading files in QFG import screens.
+	// We don't wrap the game ID prefix in these screens in order to read
+	// save states from all QFG games.
+	if (name.hasPrefix(prefix.c_str()) && !isQFGImportScreen())
 		return Common::String(name.c_str() + prefix.size());
 	return name;
 }
 
+bool SciEngine::isQFGImportScreen() const {
+	if (_gameId == GID_QFG2 && _gamestate->currentRoomNumber() == 805) {
+		// QFG2 character import screen
+		return true;
+	} else if (_gameId == GID_QFG3 && _gamestate->currentRoomNumber() == 54) {
+		// QFG3 character import screen
+		return true;
+	} else if (_gameId == GID_QFG4 && _gamestate->currentRoomNumber() == 54) {
+		return true;
+	} else {
+		return false;
+	}
+}
+
 void SciEngine::pauseEngineIntern(bool pause) {
 	_mixer->pauseAll(pause);
 }

Modified: scummvm/trunk/engines/sci/sci.h
===================================================================
--- scummvm/trunk/engines/sci/sci.h	2010-08-28 21:49:20 UTC (rev 52429)
+++ scummvm/trunk/engines/sci/sci.h	2010-08-29 00:17:56 UTC (rev 52430)
@@ -250,6 +250,12 @@
 	/** Remove the 'TARGET-' prefix of the given filename, if present. */
 	Common::String unwrapFilename(const Common::String &name) const;
 
+	/**
+	 * Checks if we are in a QFG import screen, where special handling
+	 * of save states is performed.
+	 */
+	bool isQFGImportScreen() const;
+
 	void sleep(uint32 msecs);
 
 	void scriptDebug();


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list