|
@@ -7,6 +7,9 @@
|
|
#include <Klient.h>
|
|
#include <Klient.h>
|
|
#ifndef _WINDOWS
|
|
#ifndef _WINDOWS
|
|
# include <sys/resource.h>
|
|
# include <sys/resource.h>
|
|
|
|
+#else
|
|
|
|
+# define NO_MAIN
|
|
|
|
+# include <main.h>
|
|
#endif
|
|
#endif
|
|
#include <AsynchronCall.h>
|
|
#include <AsynchronCall.h>
|
|
#include <Text.h>
|
|
#include <Text.h>
|
|
@@ -18,15 +21,45 @@
|
|
|
|
|
|
FactoryCraftServer* mserver = 0;
|
|
FactoryCraftServer* mserver = 0;
|
|
|
|
|
|
-void exit()
|
|
|
|
|
|
+#ifdef _WINDOWS
|
|
|
|
+LONG WINAPI exceptionHandler(struct _EXCEPTION_POINTERS* apExceptionInfo)
|
|
{
|
|
{
|
|
|
|
+ Sleep(10000);
|
|
|
|
+ std::cout << "ERROR: Creating dump";
|
|
|
|
+ std::cout.flush();
|
|
|
|
+ createMinidump(apExceptionInfo);
|
|
if (mserver)
|
|
if (mserver)
|
|
{
|
|
{
|
|
std::cout << "The server terminated unexpectedly. Trying to save game "
|
|
std::cout << "The server terminated unexpectedly. Trying to save game "
|
|
"progress.\n";
|
|
"progress.\n";
|
|
mserver->close();
|
|
mserver->close();
|
|
}
|
|
}
|
|
|
|
+ return EXCEPTION_CONTINUE_SEARCH;
|
|
}
|
|
}
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+void onError(int i)
|
|
|
|
+{
|
|
|
|
+ Sleep(10000);
|
|
|
|
+ std::cout << "ERROR: Creating dump";
|
|
|
|
+ std::cout.flush();
|
|
|
|
+ createMinidump(0);
|
|
|
|
+ if (mserver)
|
|
|
|
+ {
|
|
|
|
+ std::cout << "The server terminated unexpectedly. Trying to save game "
|
|
|
|
+ "progress.\n";
|
|
|
|
+ mserver->close();
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void onExit()
|
|
|
|
+{
|
|
|
|
+ Sleep(10000);
|
|
|
|
+ std::cout << "Programm exited";
|
|
|
|
+ std::cout.flush();
|
|
|
|
+ onError(0);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
|
|
bool exited = false;
|
|
bool exited = false;
|
|
|
|
|
|
@@ -141,6 +174,9 @@ public:
|
|
|
|
|
|
int main()
|
|
int main()
|
|
{
|
|
{
|
|
|
|
+#ifdef _WINDOWS
|
|
|
|
+ SetUnhandledExceptionFilter(exceptionHandler);
|
|
|
|
+#endif
|
|
Framework::initFramework();
|
|
Framework::initFramework();
|
|
|
|
|
|
#ifndef _WINDOWS
|
|
#ifndef _WINDOWS
|
|
@@ -199,13 +235,13 @@ int main()
|
|
}
|
|
}
|
|
|
|
|
|
mserver = new FactoryCraftServer(dat);
|
|
mserver = new FactoryCraftServer(dat);
|
|
- std::atexit(exit);
|
|
|
|
- signal(SIGTERM, exit);
|
|
|
|
- signal(SIGSEGV, exit);
|
|
|
|
- signal(SIGILL, exit);
|
|
|
|
- signal(SIGABRT, exit);
|
|
|
|
- signal(SIGFPE, exit);
|
|
|
|
- signal(SIGINT, exit);
|
|
|
|
|
|
+ std::atexit(onExit);
|
|
|
|
+ signal(SIGTERM, onError);
|
|
|
|
+ signal(SIGSEGV, onError);
|
|
|
|
+ signal(SIGILL, onError);
|
|
|
|
+ signal(SIGABRT, onError);
|
|
|
|
+ signal(SIGFPE, onError);
|
|
|
|
+ signal(SIGINT, onError);
|
|
|
|
|
|
new Framework::AsynchronCall("Commander", []() {
|
|
new Framework::AsynchronCall("Commander", []() {
|
|
while (mserver)
|
|
while (mserver)
|