mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-02 03:06:41 +00:00
second round of refactoring; moving configuration handling out of main function
This commit is contained in:
parent
04037fb01a
commit
b7db6dcda3
1 changed files with 43 additions and 45 deletions
|
@ -4,32 +4,17 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#include <boost/program_options.hpp>
|
#include <boost/program_options.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
|
||||||
|
|
||||||
#include "engine.hpp"
|
#include "engine.hpp"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
void maintest (boost::filesystem::path dataDir, const std::string& cellName,
|
/// Parse command line options and openmw.cfg file (if one exists). Results are directly
|
||||||
std::string master)
|
/// written to \a engine.
|
||||||
|
/// \return Run OpenMW?
|
||||||
|
|
||||||
|
bool parseOptions (int argc, char**argv, OMW::Engine& engine)
|
||||||
{
|
{
|
||||||
assert (!dataDir.empty());
|
|
||||||
|
|
||||||
OMW::Engine engine;
|
|
||||||
|
|
||||||
engine.setDataDir (dataDir);
|
|
||||||
|
|
||||||
engine.setCell (cellName);
|
|
||||||
|
|
||||||
engine.addMaster (master);
|
|
||||||
|
|
||||||
engine.go();
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char**argv)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
boost::program_options::options_description desc (
|
boost::program_options::options_description desc (
|
||||||
"Syntax: openmw <options>\nAllowed options");
|
"Syntax: openmw <options>\nAllowed options");
|
||||||
|
|
||||||
|
@ -58,11 +43,23 @@ int main(int argc, char**argv)
|
||||||
if (variables.count ("help"))
|
if (variables.count ("help"))
|
||||||
{
|
{
|
||||||
std::cout << desc << std::endl;
|
std::cout << desc << std::endl;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
engine.setDataDir (variables["data"].as<std::string>());
|
||||||
|
engine.setCell (variables["start"].as<std::string>());
|
||||||
|
engine.addMaster (variables["master"].as<std::string>());
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char**argv)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
maintest (variables["data"].as<std::string>(), variables["start"].as<std::string>(),
|
OMW::Engine engine;
|
||||||
variables["master"].as<std::string>());
|
|
||||||
|
if (parseOptions (argc, argv, engine))
|
||||||
|
{
|
||||||
|
engine.go();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(exception &e)
|
catch(exception &e)
|
||||||
|
@ -70,5 +67,6 @@ int main(int argc, char**argv)
|
||||||
cout << "\nERROR: " << e.what() << endl;
|
cout << "\nERROR: " << e.what() << endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue