mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-21 19:51:49 +00:00
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
This commit is contained in:
parent
713e61acba
commit
824dd44ddf
@ -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
|
||||
|
@ -682,13 +682,6 @@ void ResourceManager::freeResourceSources() {
|
||||
}
|
||||
|
||||
ResourceManager::ResourceManager() {
|
||||
addAppropriateSources();
|
||||
init();
|
||||
}
|
||||
|
||||
ResourceManager::ResourceManager(const Common::FSList &fslist) {
|
||||
addAppropriateSources(fslist);
|
||||
init();
|
||||
}
|
||||
|
||||
void ResourceManager::init() {
|
||||
|
@ -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
|
||||
@ -324,11 +332,6 @@ protected:
|
||||
ResVersion _volVersion; ///< resource.0xx version
|
||||
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();
|
||||
|
||||
|
@ -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());
|
||||
|
Loading…
x
Reference in New Issue
Block a user