From 7e4f6559399b74263cfccc345eaa753a026870cf Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 16 Jun 2010 20:15:48 +0200 Subject: [PATCH] pull in all bsa files instead of only the bsa file matching the master --- game/engine.cpp | 33 +++++++++++++++------------------ game/engine.hpp | 4 +++- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/game/engine.cpp b/game/engine.cpp index a0803838e..f7855847c 100644 --- a/game/engine.cpp +++ b/game/engine.cpp @@ -18,33 +18,30 @@ OMW::Engine::Engine() {} void OMW::Engine::prepareMaster() { - assert (!mDataDir.empty()); - - std::string masterName; // name without extension - std::string::size_type sep = mMaster.find_last_of ("."); if (sep==std::string::npos) { - masterName = mMaster; mMaster += ".esm"; } - else - { - masterName = mMaster.substr (0, sep); - } - - // bsa - boost::filesystem::path bsa (mDataDir); - bsa /= masterName + ".bsa"; +} + +// Load all BSA files in data directory. - if (boost::filesystem::exists (bsa)) +void OMW::Engine::loadBSA() +{ + boost::filesystem::directory_iterator end; + + for (boost::filesystem::directory_iterator iter (mDataDir); iter!=end; ++iter) { - std::cout << "Adding " << bsa.string() << std::endl; - addBSA(bsa.file_string()); + if (boost::filesystem::extension (iter->path())==".bsa") + { + std::cout << "Adding " << iter->path().string() << std::endl; + addBSA(iter->path().file_string()); + } } } - + // add resources directory // \note This function works recursively. @@ -70,7 +67,6 @@ void OMW::Engine::setCell (const std::string& cellName) // Set master file (esm) // - If the given name does not have an extension, ".esm" is added automatically -// - If there is a bsa file with the same name, OpenMW will load it. // - Currently OpenMW only supports one master at the same time. void OMW::Engine::addMaster (const std::string& master) @@ -101,6 +97,7 @@ void OMW::Engine::go() addResourcesDirectory (mDataDir / "Textures"); prepareMaster(); + loadBSA(); boost::filesystem::path masterPath (mDataDir); masterPath /= mMaster; diff --git a/game/engine.hpp b/game/engine.hpp index 55c8285e0..fb6ddbbe4 100644 --- a/game/engine.hpp +++ b/game/engine.hpp @@ -29,6 +29,9 @@ namespace OMW /// \note This function works recursively. void addResourcesDirectory (const boost::filesystem::path& path); + /// Load all BSA files in data directory. + void loadBSA(); + public: Engine(); @@ -41,7 +44,6 @@ namespace OMW /// Set master file (esm) /// - If the given name does not have an extension, ".esm" is added automatically - /// - If there is a bsa file with the same name, OpenMW will load it. /// - Currently OpenMW only supports one master at the same time. void addMaster (const std::string& master);