1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-30 07:06:43 +00:00

added --master option; reimplemented file handling with boost::filesystem

This commit is contained in:
Marc Zinnschlag 2010-06-15 19:04:52 +02:00
parent b1e96386c6
commit f32105a2ae

View file

@ -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,65 +17,85 @@
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);
}
const char* plugCfg = "plugins.cfg"; boost::filesystem::path masterPath (dataDir);
masterPath /= master;
cout << "Hello, fellow traveler!\n"; boost::filesystem::path bsa (dataDir);
bsa /= masterName + ".bsa";
const char* plugCfg = "plugins.cfg";
cout << "Hello, fellow traveler!\n";
cout << "Your data directory for today is: " << dataDir << "\n"; cout << "Your data directory for today is: " << dataDir << "\n";
cout << "Initializing OGRE\n"; cout << "Initializing OGRE\n";
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);
// Create the window // Create the window
ogre.createWindow("OpenMW"); ogre.createWindow("OpenMW");
cout << "\nSetting up cell rendering\n"; cout << "\nSetting up cell rendering\n";
// Sets up camera, scene manager etc // Sets up camera, scene manager etc
MWRender::MWScene scene(ogre); MWRender::MWScene scene(ogre);
// This connects the cell data with the rendering scene. // This connects the cell data with the rendering scene.
MWRender::InteriorCellRender rend(cell, scene); MWRender::InteriorCellRender rend(cell, scene);
// Load the cell and insert it into the renderer // Load the cell and insert it into the renderer
rend.show(); rend.show();
cout << "Setting up input system\n"; cout << "Setting up input system\n";
// Sets up the input system // Sets up the input system
MWInput::MWInputManager input(ogre); MWInput::MWInputManager input(ogre);
cout << "\nStart! Press Q/ESC or close window to exit.\n"; cout << "\nStart! Press Q/ESC or close window to exit.\n";
// Start the main rendering loop // Start the main rendering loop
ogre.start(); ogre.start();
cout << "\nThat's all for now!\n"; cout << "\nThat's all for now!\n";
} }
int main(int argc, char**argv) int main(int argc, char**argv)
@ -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)