2011-08-14 04:09:11 +02:00
|
|
|
#include "otclient.h"
|
2010-11-18 23:13:35 +01:00
|
|
|
|
2011-07-13 23:12:36 +02:00
|
|
|
#include <csignal>
|
2011-08-14 04:09:11 +02:00
|
|
|
#include <core/eventdispatcher.h>
|
2011-07-13 23:12:36 +02:00
|
|
|
|
2010-11-18 23:13:35 +01:00
|
|
|
void signal_handler(int sig)
|
|
|
|
{
|
2011-08-14 04:09:11 +02:00
|
|
|
static bool signaled = false;
|
2010-11-18 23:13:35 +01:00
|
|
|
switch(sig) {
|
|
|
|
case SIGTERM:
|
|
|
|
case SIGINT:
|
2011-08-14 04:09:11 +02:00
|
|
|
if(!signaled) {
|
|
|
|
signaled = true;
|
|
|
|
g_dispatcher.addEvent(std::bind(&OTClient::onClose, &g_client));
|
2010-11-18 23:13:35 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-17 01:56:57 +02:00
|
|
|
#ifdef WIN32_NO_CONSOLE
|
|
|
|
#include <windows.h>
|
2011-05-17 06:32:18 +02:00
|
|
|
int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nCmdShow)
|
2011-05-17 01:56:57 +02:00
|
|
|
{
|
|
|
|
std::vector<std::string> args;
|
2011-05-17 06:32:18 +02:00
|
|
|
boost::split(args, lpszArgument, boost::is_any_of(std::string(" ")));
|
2011-05-17 01:56:57 +02:00
|
|
|
#else
|
2011-08-14 04:09:11 +02:00
|
|
|
int main(int argc, const char* argv[])
|
2010-11-18 23:13:35 +01:00
|
|
|
{
|
2011-05-17 01:56:57 +02:00
|
|
|
std::vector<std::string> args;
|
2011-08-14 04:09:11 +02:00
|
|
|
for(int i=0; i<argc; ++i)
|
2011-05-17 01:56:57 +02:00
|
|
|
args.push_back(argv[i]);
|
|
|
|
#endif
|
2011-08-14 04:09:11 +02:00
|
|
|
g_client.init(args);
|
|
|
|
g_client.run();
|
|
|
|
g_client.terminate();
|
2010-11-18 23:13:35 +01:00
|
|
|
return 0;
|
|
|
|
}
|