[Scummvm-cvs-logs] SF.net SVN: scummvm:[34659] scummvm/trunk

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sat Sep 27 20:32:02 CEST 2008


Revision: 34659
          http://scummvm.svn.sourceforge.net/scummvm/?rev=34659&view=rev
Author:   fingolfin
Date:     2008-09-27 18:32:01 +0000 (Sat, 27 Sep 2008)

Log Message:
-----------
Modified Common::SearchSet to take signed integer priorities, for convenience (so that one can add archives with less-than-default priority)

Modified Paths:
--------------
    scummvm/trunk/backends/platform/sdl/sdl.cpp
    scummvm/trunk/backends/platform/sdl/sdl.h
    scummvm/trunk/common/archive.cpp
    scummvm/trunk/common/archive.h
    scummvm/trunk/common/system.h

Modified: scummvm/trunk/backends/platform/sdl/sdl.cpp
===================================================================
--- scummvm/trunk/backends/platform/sdl/sdl.cpp	2008-09-27 17:51:22 UTC (rev 34658)
+++ scummvm/trunk/backends/platform/sdl/sdl.cpp	2008-09-27 18:32:01 UTC (rev 34659)
@@ -275,7 +275,7 @@
 	return _fsFactory;
 }
 
-void OSystem_SDL::addSysArchivesToSearchSet(Common::SearchSet &s, uint priority) {
+void OSystem_SDL::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
 
 #ifdef DATA_PATH
 	// Add the global DATA_PATH to the directory search list

Modified: scummvm/trunk/backends/platform/sdl/sdl.h
===================================================================
--- scummvm/trunk/backends/platform/sdl/sdl.h	2008-09-27 17:51:22 UTC (rev 34658)
+++ scummvm/trunk/backends/platform/sdl/sdl.h	2008-09-27 18:32:01 UTC (rev 34659)
@@ -209,7 +209,7 @@
 
 	virtual Common::SaveFileManager *getSavefileManager();
 	virtual FilesystemFactory *getFilesystemFactory();
-	virtual void addSysArchivesToSearchSet(Common::SearchSet &s, uint priority = 0);
+	virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0);
 
 	virtual Common::SeekableReadStream *openConfigFileForReading();
 	virtual Common::WriteStream *openConfigFileForWriting();

Modified: scummvm/trunk/common/archive.cpp
===================================================================
--- scummvm/trunk/common/archive.cpp	2008-09-27 17:51:22 UTC (rev 34658)
+++ scummvm/trunk/common/archive.cpp	2008-09-27 18:32:01 UTC (rev 34659)
@@ -26,6 +26,7 @@
 #include "common/archive.h"
 #include "common/fs.h"
 #include "common/util.h"
+#include "common/system.h"
 
 namespace Common {
 
@@ -231,7 +232,7 @@
 	_list.insert(it, node);
 }
 
-void SearchSet::add(const String& name, ArchivePtr archive, uint priority) {
+void SearchSet::add(const String& name, ArchivePtr archive, int priority) {
 	if (find(name) == _list.end()) {
 		Node node = { priority, name, archive };
 		insert(node);
@@ -256,7 +257,7 @@
 	_list.clear();
 }
 
-void SearchSet::setPriority(const String& name, uint priority) {
+void SearchSet::setPriority(const String& name, int priority) {
 	ArchiveList::iterator it = find(name);
 	if (it == _list.end()) {
 		warning("SearchSet::setPriority: archive '%s' is not present", name.c_str());
@@ -328,6 +329,10 @@
 
 DECLARE_SINGLETON(SearchManager);
 
+SearchManager::SearchManager() {
+	clear();	// Force a reset
+}
+
 void SearchManager::addArchive(const String &name, ArchivePtr archive) {
 	add(name, archive);
 }
@@ -337,8 +342,16 @@
 }
 
 void SearchManager::addDirectoryRecursive(const String &name, const String &directory, int depth) {
-	add(name, SharedPtr<FSDirectory>(new FSDirectory(directory, depth)));
+	add(name, ArchivePtr(new FSDirectory(directory, depth)));
 }
 
+void SearchManager::clear() {
+	SearchSet::clear();
 
+	// Always keep system specific archives in the SearchManager.
+	// But we give them a lower priority than the default priority (which is 0),
+	// so that archives added by client code are searched first.
+	g_system->addSysArchivesToSearchSet(*this, -1);
+}
+
 } // namespace Common

Modified: scummvm/trunk/common/archive.h
===================================================================
--- scummvm/trunk/common/archive.h	2008-09-27 17:51:22 UTC (rev 34658)
+++ scummvm/trunk/common/archive.h	2008-09-27 18:32:01 UTC (rev 34659)
@@ -153,7 +153,7 @@
  */
 class SearchSet : public Archive {
 	struct Node {
-		uint		_priority;
+		int			_priority;
 		String		_name;
 		ArchivePtr	_arc;
 	};
@@ -169,7 +169,7 @@
 	/**
 	 * Add a new archive to the searchable set.
 	 */
-	void add(const String& name, ArchivePtr archive, uint priority = 0);
+	void add(const String& name, ArchivePtr archive, int priority = 0);
 
 	/**
 	 * Remove an archive from the searchable set.
@@ -184,12 +184,12 @@
 	/**
      * Empties the searchable set.
      */
-	void clear();
+	virtual void clear();
 
 	/**
      * Change the order of searches.
      */
-	void setPriority(const String& name, uint priority);
+	void setPriority(const String& name, int priority);
 
 	virtual bool hasFile(const String &name);
 	virtual int matchPattern(StringList &list, const String &pattern);
@@ -205,6 +205,8 @@
 
 class SearchManager : public Singleton<SearchManager>, public SearchSet {
 public:
+	SearchManager();
+
 	/**
 	 * Add an existing Archive. This is meant to support searching in system-specific
 	 * archives, namely the MACOSX/IPHONE bundles.
@@ -221,6 +223,10 @@
 	 */
 	void addDirectoryRecursive(const String &name, const String &directory, int depth = 4);
 
+	/**
+	 * TODO
+	 */
+	virtual void clear();
 };
 
 /** Shortcut for accessing the search manager. */

Modified: scummvm/trunk/common/system.h
===================================================================
--- scummvm/trunk/common/system.h	2008-09-27 17:51:22 UTC (rev 34658)
+++ scummvm/trunk/common/system.h	2008-09-27 18:32:01 UTC (rev 34659)
@@ -917,7 +917,7 @@
 	 * @param s		the SearchSet to which the system specific dirs, if any, are added
 	 * @param priority	the priority with which those dirs are added
 	 */
-	virtual void addSysArchivesToSearchSet(Common::SearchSet &s, uint priority = 0) {}
+	virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0) {}
 
 	/**
 	 * Open the default config file for reading, by returning a suitable


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