[Scummvm-cvs-logs] SF.net SVN: scummvm:[53377] scummvm/trunk/engines/sword25

sev at users.sourceforge.net sev at users.sourceforge.net
Wed Oct 13 02:01:04 CEST 2010


Revision: 53377
          http://scummvm.svn.sourceforge.net/scummvm/?rev=53377&view=rev
Author:   sev
Date:     2010-10-13 00:01:04 +0000 (Wed, 13 Oct 2010)

Log Message:
-----------
SWORD25: Add support for language patch

Modified Paths:
--------------
    scummvm/trunk/engines/sword25/package/packagemanager.cpp
    scummvm/trunk/engines/sword25/sword25.cpp

Modified: scummvm/trunk/engines/sword25/package/packagemanager.cpp
===================================================================
--- scummvm/trunk/engines/sword25/package/packagemanager.cpp	2010-10-13 00:00:41 UTC (rev 53376)
+++ scummvm/trunk/engines/sword25/package/packagemanager.cpp	2010-10-13 00:01:04 UTC (rev 53377)
@@ -106,6 +106,8 @@
 }
 
 bool PackageManager::LoadPackage(const Common::String &fileName, const Common::String &mountPosition) {
+	debug(0, "LoadPackage(%s, %s)", fileName.c_str(), mountPosition.c_str());
+
 	Common::Archive *zipFile = Common::makeZipArchive(fileName);
 	if (zipFile == NULL) {
 		BS_LOG_ERRORLN("Unable to mount file \"%s\" to \"%s\"", fileName.c_str(), mountPosition.c_str());
@@ -119,7 +121,7 @@
 		for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); ++it)
 			debug(3, "%s", (*it)->getName().c_str());
 
-		_archiveList.push_back(new ArchiveEntry(zipFile, mountPosition));
+		_archiveList.push_front(new ArchiveEntry(zipFile, mountPosition));
 
 		return true;
 	}
@@ -271,7 +273,18 @@
 		for (Common::ArchiveMemberList::iterator it = memberList.begin(); it != memberList.end(); ++it) {
 			if (((typeFilter & PackageManager::FT_DIRECTORY) && (*it)->getName().hasSuffix("/")) ||
 				((typeFilter & PackageManager::FT_FILE) && !(*it)->getName().hasSuffix("/"))) {
-				list.push_back(*it);
+
+				// Do not add duplicate files
+				bool found = false;
+				for (Common::ArchiveMemberList::iterator it1 = list.begin(); it1 != list.end(); ++it1) {
+					if ((*it1)->getName() == (*it)->getName()) {
+						found = true;
+						break;
+					}
+				}
+
+				if (!found)
+					list.push_back(*it);
 				num++;
 			}
 		}

Modified: scummvm/trunk/engines/sword25/sword25.cpp
===================================================================
--- scummvm/trunk/engines/sword25/sword25.cpp	2010-10-13 00:00:41 UTC (rev 53376)
+++ scummvm/trunk/engines/sword25/sword25.cpp	2010-10-13 00:01:04 UTC (rev 53377)
@@ -155,54 +155,33 @@
 	if (!PackageManagerPtr->LoadPackage("data.b25c", "/")) return false;
 
 	// Get the contents of the main program directory and sort them alphabetically
-	Common::StringArray Filenames = FileSystemUtil::GetInstance().GetFilesInDirectory(".");
-	Common::sort(Filenames.begin(), Filenames.end());
+	Common::FSNode dir(ConfMan.get("path"));
+	Common::FSList files;
+	if (!dir.isDirectory() || !dir.getChildren(files, Common::FSNode::kListAll)) {
+		warning("Game data path does not exist or is not a directory");
+		return false;
+	}
 
+	Common::sort(files.begin(), files.end());
+
 	// Identity all patch packages
 	// The filename of patch packages must have the form patch??.b25c, with the question marks
 	// are placeholders for numbers.
 	// Since the filenames have been sorted, patches are mounted with low numbers first, through
 	// to ones with high numbers. This is important, because newly mount packages overwrite
 	// existing files in the virtual file system, if they include files with the same name.
-	for (Common::StringArray::const_iterator it = Filenames.begin(); it != Filenames.end(); ++it) {
-		const Common::String &CurFilename = *it;
-
-		// Is the current file a patch package?
-		static const Common::String PatchPattern = "patch???.b25c";
-		if (CurFilename.size() == PatchPattern.size()) {
-			// Check the file against the patch pattern character by character
-			Common::String::const_iterator PatchPatternIt = PatchPattern.begin();
-			Common::String::const_iterator CurFilenameIt = CurFilename.begin();
-			for (; PatchPatternIt != PatchPattern.end(); ++PatchPatternIt, ++CurFilenameIt) {
-				if (*PatchPatternIt == '?') {
-					if (*CurFilenameIt < '0' || *CurFilenameIt > '9') break;
-				} else {
-					if (*PatchPatternIt != *CurFilenameIt) break;
-				}
-			}
-
-			if (PatchPatternIt == PatchPattern.end()) {
-				// The pattern fits, so the file should be mounted
-				if (!PackageManagerPtr->LoadPackage(CurFilename, "/")) return false;
-			}
-		}
+	for (Common::FSList::const_iterator it = files.begin(); it != files.end(); ++it) {
+		if (it->getName().matchString("patch???.b25c", true))
+			if (!PackageManagerPtr->LoadPackage(it->getName(), "/"))
+				return false;
 	}
 
 	// Identity and mount all language packages
 	// The filename of the packages have the form lang_*.b25c (eg. lang_de.b25c)
-	for (Common::StringArray::const_iterator it = Filenames.begin(); it != Filenames.end(); ++it) {
-		const Common::String &CurFilename = *it;
-
-		static const Common::String Prefix = "lang_";
-		static const Common::String Suffix = ".b25c";
-
-		// Make sure the filename prefix and suffix has characters between them
-		if ((CurFilename.size() >= Prefix.size() && Common::String(CurFilename.begin(), CurFilename.begin() + Prefix.size()) == Prefix) &&  // Prefix test
-		        (CurFilename.size() >= Suffix.size() && Common::String(CurFilename.end() - Suffix.size(), CurFilename.end()) == Suffix) &&      // Suffix test
-		        (CurFilename.size() > Prefix.size() + Suffix.size())) {
-			// Pattern matches - the file should be mounted
-			if (!PackageManagerPtr->LoadPackage(CurFilename, "/")) return false;
-		}
+	for (Common::FSList::const_iterator it = files.begin(); it != files.end(); ++it) {
+		if (it->getName().matchString("lang_*.b25c", true))
+			if (!PackageManagerPtr->LoadPackage(it->getName(), "/"))
+				return false;
 	}
 
 	return true;


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