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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Tue Jun 15 14:15:52 CEST 2010


Revision: 49825
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49825&view=rev
Author:   fingolfin
Date:     2010-06-15 12:15:52 +0000 (Tue, 15 Jun 2010)

Log Message:
-----------
SCI: Revise how ResourceManager is instantiated.

This should allow for better error handling. Also, it
means that g_sci->getResMan() returns a valid value much sooner,
allowing me to simplify some code.

Also added a note about potentially replacing Common::FSList usage
by Common::Archive (and FSNode by Archive/ArchiveMember ?). This
might be a way to unify the addAppropriateSources variants again.

Modified Paths:
--------------
    scummvm/trunk/engines/sci/detection.cpp
    scummvm/trunk/engines/sci/resource.cpp
    scummvm/trunk/engines/sci/resource.h
    scummvm/trunk/engines/sci/sci.cpp

Modified: scummvm/trunk/engines/sci/detection.cpp
===================================================================
--- scummvm/trunk/engines/sci/detection.cpp	2010-06-15 12:15:27 UTC (rev 49824)
+++ scummvm/trunk/engines/sci/detection.cpp	2010-06-15 12:15:52 UTC (rev 49825)
@@ -428,7 +428,12 @@
 		return 0;
 	}
 
-	ResourceManager *resMan = new ResourceManager(fslist);
+	ResourceManager *resMan = new ResourceManager();
+	assert(resMan);
+	resMan->addAppropriateSources(fslist);
+	resMan->init();
+	// TODO: Add error handling.
+
 	ViewType gameViews = resMan->getViewType();
 
 	// Have we identified the game views? If not, stop here

Modified: scummvm/trunk/engines/sci/resource.cpp
===================================================================
--- scummvm/trunk/engines/sci/resource.cpp	2010-06-15 12:15:27 UTC (rev 49824)
+++ scummvm/trunk/engines/sci/resource.cpp	2010-06-15 12:15:52 UTC (rev 49825)
@@ -682,15 +682,8 @@
 }
 
 ResourceManager::ResourceManager() {
-	addAppropriateSources();
-	init();
 }
 
-ResourceManager::ResourceManager(const Common::FSList &fslist) {
-	addAppropriateSources(fslist);
-	init();
-}
-
 void ResourceManager::init() {
 	_memoryLocked = 0;
 	_memoryLRU = 0;

Modified: scummvm/trunk/engines/sci/resource.h
===================================================================
--- scummvm/trunk/engines/sci/resource.h	2010-06-15 12:15:27 UTC (rev 49824)
+++ scummvm/trunk/engines/sci/resource.h	2010-06-15 12:15:52 UTC (rev 49825)
@@ -229,10 +229,18 @@
 	 * Creates a new SCI resource manager.
 	 */
 	ResourceManager();
-	ResourceManager(const Common::FSList &fslist);
 	~ResourceManager();
 
+
 	/**
+	 * Initializes the resource manager.
+	 */
+	void init();
+
+	int addAppropriateSources();
+	int addAppropriateSources(const Common::FSList &fslist);	// TODO: Switch from FSList to Common::Archive?
+
+	/**
 	 * Looks up a resource's data.
 	 * @param id	The resource type to look for
 	 * @param lock	non-zero iff the resource should be locked
@@ -325,11 +333,6 @@
 	ResVersion _mapVersion; ///< resource.map version
 
 	/**
-	 * Initializes the resource manager
-	 */
-	void init();
-
-	/**
 	 * Add a path to the resource manager's list of sources.
 	 * @return a pointer to the added source structure, or NULL if an error occurred.
 	 */
@@ -379,8 +382,7 @@
 	 * @return One of SCI_ERROR_*.
 	 */
 	void scanNewSources();
-	int addAppropriateSources();
-	int addAppropriateSources(const Common::FSList &fslist);
+
 	int addInternalSources();
 	void freeResourceSources();
 

Modified: scummvm/trunk/engines/sci/sci.cpp
===================================================================
--- scummvm/trunk/engines/sci/sci.cpp	2010-06-15 12:15:27 UTC (rev 49824)
+++ scummvm/trunk/engines/sci/sci.cpp	2010-06-15 12:15:52 UTC (rev 49825)
@@ -66,11 +66,20 @@
 
 SciEngine::SciEngine(OSystem *syst, const ADGameDescription *desc)
 		: Engine(syst), _gameDescription(desc), _system(syst) {
-	_console = NULL;
 
 	assert(g_sci == 0);
 	g_sci = this;
+
+	_gfxMacIconBar = 0;
+
+	_audio = 0;
 	_features = 0;
+	_resMan = 0;
+	_gamestate = 0;
+	_kernel = 0;
+	_vocabulary = 0;
+	_eventMan = 0;
+	_console = 0;
 
 	// Set up the engine specific debug levels
 	DebugMan.addDebugChannel(kDebugLevelError, "Error", "Script error debugging");
@@ -98,9 +107,6 @@
 	DebugMan.addDebugChannel(kDebugLevelResMan, "ResMan", "Resource manager debugging");
 	DebugMan.addDebugChannel(kDebugLevelOnStartup, "OnStartup", "Enter debugger at start of game");
 
-	_gamestate = 0;
-	_gfxMacIconBar = 0;
-
 	const Common::FSNode gameDataDir(ConfMan.get("path"));
 
 	SearchMan.addSubDirectoryMatching(gameDataDir, "actors");	// KQ6 hi-res portraits
@@ -138,11 +144,18 @@
 	ConfMan.registerDefault("enable_fb01", "false");
 
 	_resMan = new ResourceManager();
+	assert(_resMan);
+	_resMan->addAppropriateSources();
+	_resMan->init();
 
+	// TODO: Add error handling. Check return values of addAppropriateSources
+	// and init. We first have to *add* sensible return values, though ;).
+/*
 	if (!_resMan) {
 		warning("No resources found, aborting");
 		return Common::kNoGameDataFoundError;
 	}
+*/
 
 	// Add the after market GM patches for the specified game, if they exist
 	_resMan->addNewGMPatch(getGameID());


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