diff options
-rw-r--r-- | base/main.cpp | 2 | ||||
-rw-r--r-- | engines/engine.cpp | 4 | ||||
-rw-r--r-- | engines/engine.h | 11 | ||||
-rw-r--r-- | engines/tinsel/tinsel.cpp | 19 | ||||
-rw-r--r-- | engines/tinsel/tinsel.h | 1 |
5 files changed, 28 insertions, 9 deletions
diff --git a/base/main.cpp b/base/main.cpp index c993dfa57a..abf75b7e7e 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -197,7 +197,7 @@ static Common::Error runGame(const EnginePlugin *plugin, OSystem &system, const // // Add the game path to the directory search list - SearchMan.addDirectory(dir.getPath(), dir, 0, 4); + engine->initializePath(dir); // Add extrapath (if any) to the directory search list if (ConfMan.hasKey("extrapath")) { diff --git a/engines/engine.cpp b/engines/engine.cpp index 52020c772e..8326a1fe89 100644 --- a/engines/engine.cpp +++ b/engines/engine.cpp @@ -154,6 +154,10 @@ Engine::~Engine() { CursorMan.popCursorPalette(); } +void Engine::initializePath(const Common::FSNode &gamePath) { + SearchMan.addDirectory(gamePath.getPath(), gamePath, 0, 4); +} + void initCommonGFX(bool defaultTo1XScaler) { const Common::ConfigManager::Domain *transientDomain = ConfMan.getDomain(Common::ConfigManager::kTransientDomain); const Common::ConfigManager::Domain *gameDomain = ConfMan.getActiveDomain(); diff --git a/engines/engine.h b/engines/engine.h index 4f4223384a..33416dda44 100644 --- a/engines/engine.h +++ b/engines/engine.h @@ -37,6 +37,7 @@ class Error; class EventManager; class SaveFileManager; class TimerManager; +class FSNode; } namespace GUI { class Debugger; @@ -142,6 +143,16 @@ public: virtual ~Engine(); /** + * Init SearchMan according to the game path. + * + * By default it adds the directory in non-flat mode with a depth of 4 as + * priority 0 to SearchMan. + * + * @param gamePath The base directory of the game data. + */ + virtual void initializePath(const Common::FSNode &gamePath); + + /** * Init the engine and start its main loop. * @return returns kNoError on success, else an error code. */ diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp index 5d410e62c7..5ba3c5e80a 100644 --- a/engines/tinsel/tinsel.cpp +++ b/engines/tinsel/tinsel.cpp @@ -835,14 +835,6 @@ TinselEngine::TinselEngine(OSystem *syst, const TinselGameDescription *gameDesc) // Setup mixer syncSoundSettings(); - // Add DW2 subfolder to search path in case user is running directly from the CDs - const Common::FSNode gameDataDir(ConfMan.get("path")); - SearchMan.addSubDirectoryMatching(gameDataDir, "dw2"); - - // Add subfolders needed for psx versions of Discworld 1 - if (TinselV1PSX) - SearchMan.addDirectory(gameDataDir.getPath(), gameDataDir, 0, 3, true); - const GameSettings *g; const char *gameid = ConfMan.get("gameid").c_str(); @@ -892,6 +884,17 @@ Common::String TinselEngine::getSavegameFilename(int16 saveNum) const { return Common::String::format("%s.%03d", getTargetName().c_str(), saveNum); } +void TinselEngine::initializePath(const Common::FSNode &gamePath) { + if (TinselV1PSX) { + // Add subfolders needed for psx versions of Discworld 1 + SearchMan.addDirectory(gamePath.getPath(), gamePath, 0, 3, true); + } else { + // Add DW2 subfolder to search path in case user is running directly from the CDs + SearchMan.addSubDirectoryMatching(gamePath, "dw2"); + Engine::initializePath(gamePath); + } +} + Common::Error TinselEngine::run() { // Initialize backend if (getGameID() == GID_DW2) { diff --git a/engines/tinsel/tinsel.h b/engines/tinsel/tinsel.h index d26153245d..efa9355dd5 100644 --- a/engines/tinsel/tinsel.h +++ b/engines/tinsel/tinsel.h @@ -161,6 +161,7 @@ class TinselEngine : public Engine { protected: // Engine APIs + virtual void initializePath(const Common::FSNode &gamePath); virtual Common::Error run(); virtual bool hasFeature(EngineFeature f) const; Common::Error loadGameState(int slot); |