diff options
author | Max Horn | 2010-06-15 12:15:52 +0000 |
---|---|---|
committer | Max Horn | 2010-06-15 12:15:52 +0000 |
commit | 824dd44ddfc7ca70aafcb4182b3afc58fa480528 (patch) | |
tree | 95c101e1b987c3f442be807782b75d05334bb148 /engines/sci | |
parent | 713e61acba05c49ec4bc896fa2e873c3265000a7 (diff) | |
download | scummvm-rg350-824dd44ddfc7ca70aafcb4182b3afc58fa480528.tar.gz scummvm-rg350-824dd44ddfc7ca70aafcb4182b3afc58fa480528.tar.bz2 scummvm-rg350-824dd44ddfc7ca70aafcb4182b3afc58fa480528.zip |
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.
svn-id: r49825
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/detection.cpp | 7 | ||||
-rw-r--r-- | engines/sci/resource.cpp | 7 | ||||
-rw-r--r-- | engines/sci/resource.h | 18 | ||||
-rw-r--r-- | engines/sci/sci.cpp | 21 |
4 files changed, 33 insertions, 20 deletions
diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp index 7163c879b1..3b153d3dd1 100644 --- a/engines/sci/detection.cpp +++ b/engines/sci/detection.cpp @@ -428,7 +428,12 @@ const ADGameDescription *SciMetaEngine::fallbackDetect(const Common::FSList &fsl 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 diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp index 1614700886..a1e7a5c85c 100644 --- a/engines/sci/resource.cpp +++ b/engines/sci/resource.cpp @@ -682,13 +682,6 @@ void ResourceManager::freeResourceSources() { } ResourceManager::ResourceManager() { - addAppropriateSources(); - init(); -} - -ResourceManager::ResourceManager(const Common::FSList &fslist) { - addAppropriateSources(fslist); - init(); } void ResourceManager::init() { diff --git a/engines/sci/resource.h b/engines/sci/resource.h index 3d5b874977..36d75fb56f 100644 --- a/engines/sci/resource.h +++ b/engines/sci/resource.h @@ -229,9 +229,17 @@ public: * 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 @@ -325,11 +333,6 @@ protected: 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 @@ protected: * @return One of SCI_ERROR_*. */ void scanNewSources(); - int addAppropriateSources(); - int addAppropriateSources(const Common::FSList &fslist); + int addInternalSources(); void freeResourceSources(); diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index e8847f380b..2680da9d39 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -66,11 +66,20 @@ class GfxDriver; 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 @@ SciEngine::SciEngine(OSystem *syst, const ADGameDescription *desc) 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 @@ Common::Error SciEngine::run() { 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()); |