mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-04-01 18:36:43 +00:00
added --master option; reimplemented file handling with boost::filesystem
This commit is contained in:
parent
b1e96386c6
commit
f32105a2ae
1 changed files with 64 additions and 40 deletions
|
@ -3,7 +3,8 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#include "boost/program_options.hpp"
|
#include <boost/program_options.hpp>
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
#include "esm_store/cell_store.hpp"
|
#include "esm_store/cell_store.hpp"
|
||||||
#include "bsa/bsa_archive.hpp"
|
#include "bsa/bsa_archive.hpp"
|
||||||
|
@ -16,15 +17,32 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
void maintest (std::string dataDir, const std::string& cellName)
|
void maintest (boost::filesystem::path dataDir, const std::string& cellName,
|
||||||
|
std::string master)
|
||||||
{
|
{
|
||||||
assert (!dataDir.empty());
|
assert (!dataDir.empty());
|
||||||
|
|
||||||
if (dataDir[dataDir.size()-1]!='/' && dataDir[dataDir.size()-1]!='\\')
|
dataDir = boost::filesystem::system_complete (dataDir);
|
||||||
dataDir += "/";
|
|
||||||
|
|
||||||
const char* esmFile = "Morrowind.esm";
|
std::string masterName; // name without extension
|
||||||
const char* bsaFile = "Morrowind.bsa";
|
|
||||||
|
std::string::size_type sep = master.find_last_of (".");
|
||||||
|
|
||||||
|
if (sep==std::string::npos)
|
||||||
|
{
|
||||||
|
masterName = master;
|
||||||
|
master += ".esm";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
masterName = master.substr (0, sep);
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::filesystem::path masterPath (dataDir);
|
||||||
|
masterPath /= master;
|
||||||
|
|
||||||
|
boost::filesystem::path bsa (dataDir);
|
||||||
|
bsa /= masterName + ".bsa";
|
||||||
|
|
||||||
const char* plugCfg = "plugins.cfg";
|
const char* plugCfg = "plugins.cfg";
|
||||||
|
|
||||||
|
@ -36,16 +54,19 @@ void maintest (std::string dataDir, const std::string& cellName)
|
||||||
Render::OgreRenderer ogre;
|
Render::OgreRenderer ogre;
|
||||||
ogre.configure(!isFile("ogre.cfg"), plugCfg, false);
|
ogre.configure(!isFile("ogre.cfg"), plugCfg, false);
|
||||||
|
|
||||||
cout << "Adding " << bsaFile << endl;
|
if (boost::filesystem::exists (bsa))
|
||||||
addBSA(dataDir + bsaFile);
|
{
|
||||||
|
cout << "Adding " << bsa.string() << endl;
|
||||||
|
addBSA(bsa.file_string());
|
||||||
|
}
|
||||||
|
|
||||||
cout << "Loading ESM " << esmFile << "\n";
|
cout << "Loading ESM " << masterPath.string() << "\n";
|
||||||
ESM::ESMReader esm;
|
ESM::ESMReader esm;
|
||||||
ESMS::ESMStore store;
|
ESMS::ESMStore store;
|
||||||
ESMS::CellStore cell;
|
ESMS::CellStore cell;
|
||||||
|
|
||||||
// This parses the ESM file and loads a sample cell
|
// This parses the ESM file and loads a sample cell
|
||||||
esm.open(dataDir + esmFile);
|
esm.open(masterPath.file_string());
|
||||||
store.load(esm);
|
store.load(esm);
|
||||||
|
|
||||||
cell.loadInt(cellName, store, esm);
|
cell.loadInt(cellName, store, esm);
|
||||||
|
@ -90,6 +111,8 @@ int main(int argc, char**argv)
|
||||||
"set data directory")
|
"set data directory")
|
||||||
("start", boost::program_options::value<std::string>()->default_value ("Beshara"),
|
("start", boost::program_options::value<std::string>()->default_value ("Beshara"),
|
||||||
"set initial cell (only interior cells supported at the moment")
|
"set initial cell (only interior cells supported at the moment")
|
||||||
|
("master", boost::program_options::value<std::string>()->default_value ("Morrowind"),
|
||||||
|
"master file")
|
||||||
;
|
;
|
||||||
|
|
||||||
boost::program_options::variables_map variables;
|
boost::program_options::variables_map variables;
|
||||||
|
@ -110,7 +133,8 @@ int main(int argc, char**argv)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
maintest (variables["data"].as<std::string>(), variables["start"].as<std::string>());
|
maintest (variables["data"].as<std::string>(), variables["start"].as<std::string>(),
|
||||||
|
variables["master"].as<std::string>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(exception &e)
|
catch(exception &e)
|
||||||
|
|
Loading…
Reference in a new issue