|
|
|
@ -8,6 +8,22 @@
|
|
|
|
|
#include <components/misc/fileops.hpp>
|
|
|
|
|
#include "engine.hpp"
|
|
|
|
|
|
|
|
|
|
#if defined(_WIN32) && !defined(_CONSOLE)
|
|
|
|
|
#include <boost/iostreams/concepts.hpp>
|
|
|
|
|
#include <boost/iostreams/stream_buffer.hpp>
|
|
|
|
|
|
|
|
|
|
# if !defined(_DEBUG)
|
|
|
|
|
# include <iostream>
|
|
|
|
|
# include <fstream>
|
|
|
|
|
# endif
|
|
|
|
|
|
|
|
|
|
// For OutputDebugString
|
|
|
|
|
#include <Windows.h>
|
|
|
|
|
// makes __argc and __argv available on windows
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
/// Parse command line options and openmw.cfg file (if one exists). Results are directly
|
|
|
|
@ -80,6 +96,7 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine)
|
|
|
|
|
|
|
|
|
|
int main(int argc, char**argv)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
OMW::Engine engine;
|
|
|
|
@ -97,3 +114,71 @@ int main(int argc, char**argv)
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Platform specific for Windows when there is no console built into the executable.
|
|
|
|
|
// Windows will call the WinMain function instead of main in this case, the normal
|
|
|
|
|
// main function is then called with the __argc and __argv parameters.
|
|
|
|
|
// In addition if it is a debug build it will redirect cout to the debug console in Visual Studio
|
|
|
|
|
#if defined(_WIN32) && !defined(_CONSOLE)
|
|
|
|
|
|
|
|
|
|
#if defined(_DEBUG)
|
|
|
|
|
class DebugOutput : public boost::iostreams::sink
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
std::streamsize write(const char *str, std::streamsize size)
|
|
|
|
|
{
|
|
|
|
|
// Make a copy for null termination
|
|
|
|
|
std::string tmp (str, size);
|
|
|
|
|
// Write string to Visual Studio Debug output
|
|
|
|
|
OutputDebugString (tmp.c_str ());
|
|
|
|
|
return size;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
#else
|
|
|
|
|
class Logger : public boost::iostreams::sink
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
Logger(std::ofstream &stream)
|
|
|
|
|
: out(stream)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::streamsize write(const char *str, std::streamsize size)
|
|
|
|
|
{
|
|
|
|
|
out.write (str, size);
|
|
|
|
|
out.flush();
|
|
|
|
|
return size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
std::ofstream &out;
|
|
|
|
|
};
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
|
|
|
|
|
{
|
|
|
|
|
std::streambuf* old_rdbuf = std::cout.rdbuf ();
|
|
|
|
|
|
|
|
|
|
int ret = 0;
|
|
|
|
|
#if defined(_DEBUG)
|
|
|
|
|
// Redirect cout to VS debug output when running in debug mode
|
|
|
|
|
{
|
|
|
|
|
boost::iostreams::stream_buffer<DebugOutput> sb;
|
|
|
|
|
sb.open(DebugOutput());
|
|
|
|
|
#else
|
|
|
|
|
// Redirect cout to openmw.log
|
|
|
|
|
std::ofstream logfile ("openmw.log");
|
|
|
|
|
{
|
|
|
|
|
boost::iostreams::stream_buffer<Logger> sb;
|
|
|
|
|
sb.open (Logger (logfile));
|
|
|
|
|
#endif
|
|
|
|
|
std::cout.rdbuf (&sb);
|
|
|
|
|
|
|
|
|
|
ret = main (__argc, __argv);
|
|
|
|
|
|
|
|
|
|
std::cout.rdbuf(old_rdbuf);
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|