[Scummvm-cvs-logs] SF.net SVN: scummvm:[45502] scummvm/trunk/engines/sci/engine/kfile.cpp

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Thu Oct 29 17:05:24 CET 2009


Revision: 45502
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45502&view=rev
Author:   thebluegr
Date:     2009-10-29 16:05:24 +0000 (Thu, 29 Oct 2009)

Log Message:
-----------
Automatically create memory.drv (the file containing the LSL5 password) for non-English versions of LSL5, so that the games don't abort if it can't be found.

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

Modified: scummvm/trunk/engines/sci/engine/kfile.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kfile.cpp	2009-10-29 15:26:48 UTC (rev 45501)
+++ scummvm/trunk/engines/sci/engine/kfile.cpp	2009-10-29 16:05:24 UTC (rev 45502)
@@ -870,14 +870,36 @@
 
 		// Check for regular file
 		bool exists = Common::File::exists(name);
+		Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
+		const Common::String wrappedName = ((Sci::SciEngine*)g_engine)->wrapFilename(name);
 
+		if (!exists)
+			exists = !saveFileMan->listSavefiles(name).empty();
+
 		if (!exists) {
-			// TODO: Transform the name given by the scripts to us, e.g. by
-			// prepending TARGET-
-			Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
-			exists = !saveFileMan->listSavefiles(name).empty();
+			// Try searching for the file prepending target-
+			Common::SeekableReadStream *inFile = saveFileMan->openForLoading(wrappedName);
+			exists = (inFile != 0);
+			delete inFile;
 		}
 
+		// Special case for non-English versions of LSL5: The English version of LSL5 calls
+		// kFileIO(), case K_FILEIO_OPEN for reading to check if memory.drv exists (which is
+		// where the game's password is stored). If it's not found, it calls kFileIO() again,
+		// case K_FILEIO_OPEN for writing and creates a new file. Non-English versions call
+		// kFileIO(), case K_FILEIO_FILE_EXISTS instead, and fail if memory.drv can't be found.
+		// We create a default memory.drv file with no password, so that the game can continue
+		if (!exists && name == "memory.drv") {
+			// Create a new file, and write the bytes for the empty password string inside
+			byte defaultContent[] = { 0xE9, 0xE9, 0xEB, 0xE1, 0x0D, 0x0A, 0x31, 0x30, 0x30, 0x30 };
+			Common::WriteStream *outFile = saveFileMan->openForSaving(wrappedName);
+			for (int i = 0; i < 10; i++)
+				outFile->writeByte(defaultContent[i]);
+			outFile->finalize();
+			delete outFile;
+			exists = true;
+		}
+
 		debug(3, "K_FILEIO_FILE_EXISTS(%s) -> %d", name.c_str(), exists);
 		return make_reg(0, exists);
 	}


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