changed engine class to support multiple data directories for esm files

actorid
Marc Zinnschlag 14 years ago
parent d260e5c1bd
commit 6e880cffb2

@ -240,15 +240,12 @@ OMW::Engine::~Engine()
void OMW::Engine::loadBSA()
{
boost::filesystem::directory_iterator end;
const Files::MultiDirCollection& bsa = mFileCollections.getCollection (".bsa");
for (boost::filesystem::directory_iterator iter (mDataDir); iter!=end; ++iter)
for (Files::MultiDirCollection::TIter iter (bsa.begin()); iter!=bsa.end(); ++iter)
{
if (boost::filesystem::extension (iter->path())==".bsa")
{
std::cout << "Adding " << iter->path().string() << std::endl;
addBSA(iter->path().string());
}
std::cout << "Adding " << iter->second.string() << std::endl;
addBSA (iter->second.string());
}
}
@ -263,9 +260,13 @@ void OMW::Engine::addResourcesDirectory (const boost::filesystem::path& path)
// Set data dir
void OMW::Engine::setDataDir (const boost::filesystem::path& dataDir)
void OMW::Engine::setDataDirs (const std::vector<boost::filesystem::path>& dataDirs)
{
mDataDir = boost::filesystem::system_complete (dataDir);
/// \todo remove mDataDir, once resources system can handle multiple directories
assert (!dataDirs.empty());
mDataDir = dataDirs[0];
mFileCollections = Files::Collections (dataDirs, true);
}
// Set resource dir
@ -318,15 +319,12 @@ void OMW::Engine::setNewGame()
void OMW::Engine::go()
{
assert (!mEnvironment.mWorld);
assert (!mDataDir.empty());
assert (!mCellName.empty());
assert (!mMaster.empty());
test.name = "";
total = 0;
std::cout << "Data directory: " << mDataDir << "\n";
std::string cfgDir = Files::getPath (Files::Path_ConfigGlobal, "openmw", "");
std::string cfgUserDir = Files::getPath (Files::Path_ConfigUser, "openmw", "");
std::string plugCfg = "plugins.cfg";
@ -358,8 +356,8 @@ void OMW::Engine::go()
mPhysicEngine = new OEngine::Physic::PhysicEngine(shapeLoader);
// Create the world
mEnvironment.mWorld = new MWWorld::World (mOgre, mPhysicEngine, mDataDir, mMaster, mResDir, mNewGame, mEnvironment);
mEnvironment.mWorld = new MWWorld::World (mOgre, mPhysicEngine, mFileCollections, mMaster,
mResDir, mNewGame, mEnvironment);
// Set up the GUI system
mGuiManager = new OEngine::GUI::MyGUIManager(mOgre.getWindow(), mOgre.getScene(), false, cfgDir);

@ -10,6 +10,7 @@
#include <openengine/ogre/renderer.hpp>
#include <openengine/bullet/physic.hpp>
#include <components/compiler/extensions.hpp>
#include <components/files/collections.hpp>
#include "mwworld/environment.hpp"
#include "mwworld/ptr.hpp"
@ -55,8 +56,6 @@ namespace OMW
class Engine : private Ogre::FrameListener
{
//int nFiles;
boost::filesystem::path mDataDir;
boost::filesystem::path mResDir;
OEngine::Render::OgreRenderer mOgre;
@ -84,6 +83,8 @@ namespace OMW
MWWorld::Ptr mIgnoreLocalPtr;
Files::Collections mFileCollections;
// not implemented
Engine (const Engine&);
Engine& operator= (const Engine&);
@ -108,8 +109,8 @@ namespace OMW
~Engine();
/// Set data dir
void setDataDir (const boost::filesystem::path& dataDir);
/// Set data dirs
void setDataDirs (const std::vector<boost::filesystem::path>& dataDirs);
/// Set resource dir
void setResourceDir (const boost::filesystem::path& parResDir);

@ -105,7 +105,9 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine)
}
// directory settings
engine.setDataDir (variables["data"].as<std::string>());
std::vector<boost::filesystem::path> dataDirs;
dataDirs.push_back (variables["data"].as<std::string>());
engine.setDataDirs (dataDirs);
engine.setResourceDir (variables["resources"].as<std::string>());
// master and plugin

@ -5,6 +5,7 @@
#include <iostream>
#include <components/bsa/bsa_archive.hpp>
#include <components/files/collections.hpp>
#include "../mwrender/sky.hpp"
#include "../mwrender/interior.hpp"
@ -406,15 +407,16 @@ namespace MWWorld
mCellChanged = true;
}
World::World (OEngine::Render::OgreRenderer& renderer, OEngine::Physic::PhysicEngine* physEng, const boost::filesystem::path& dataDir,
World::World (OEngine::Render::OgreRenderer& renderer, OEngine::Physic::PhysicEngine* physEng,
const Files::Collections& fileCollections,
const std::string& master, const boost::filesystem::path& resDir,
bool newGame, Environment& environment)
: mSkyManager (0), mScene (renderer,physEng), mPlayer (0), mCurrentCell (0), mGlobalVariables (0),
mSky (false), mCellChanged (false), mEnvironment (environment)
{
mPhysEngine = physEng;
boost::filesystem::path masterPath (dataDir);
masterPath /= master;
boost::filesystem::path masterPath (fileCollections.getCollection (".esm").getPath (master));
std::cout << "Loading ESM " << masterPath.string() << "\n";

@ -26,6 +26,11 @@ namespace ESM
struct Position;
}
namespace Files
{
class Collections;
}
namespace Render
{
class OgreRenderer;
@ -107,7 +112,8 @@ namespace MWWorld
/// interior cell.
public:
World (OEngine::Render::OgreRenderer& renderer, OEngine::Physic::PhysicEngine* physEng, const boost::filesystem::path& dataDir,
World (OEngine::Render::OgreRenderer& renderer, OEngine::Physic::PhysicEngine* physEng,
const Files::Collections& fileCollections,
const std::string& master, const boost::filesystem::path& resDir, bool newGame,
Environment& environment);

@ -3,6 +3,8 @@
namespace Files
{
Collections::Collections() : mFoldCase (false) {}
Collections::Collections (const std::vector<boost::filesystem::path>& directories, bool foldCase)
: mDirectories (directories), mFoldCase (foldCase)
{}

@ -13,6 +13,8 @@ namespace Files
public:
Collections();
Collections (const std::vector<boost::filesystem::path>& directories, bool foldCase);
///< Directories are listed with increasing priority.

Loading…
Cancel
Save