diff options
author | xazax-hun <xazax-hun@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-03-18 00:06:38 +0000 |
---|---|---|
committer | xazax-hun <xazax-hun@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-03-18 00:06:38 +0000 |
commit | 9374324b4198605a9ee57f31de010ae18af49256 (patch) | |
tree | cb34cf39adc7ad919174faef8931007a701d1d29 /src | |
parent | 95c375db8b813406db03a3f7754525198c696cc1 (diff) | |
download | hercules-9374324b4198605a9ee57f31de010ae18af49256.tar.gz hercules-9374324b4198605a9ee57f31de010ae18af49256.tar.bz2 hercules-9374324b4198605a9ee57f31de010ae18af49256.tar.xz hercules-9374324b4198605a9ee57f31de010ae18af49256.zip |
* Properly handling, when closing the consoles via X button on windows.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15706 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r-- | src/common/core.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/common/core.c b/src/common/core.c index 89a002ebe..243fac24c 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -18,6 +18,8 @@ #include <string.h> #ifndef _WIN32 #include <unistd.h> +#else +#include <windows.h> // Console close event handling #endif @@ -69,6 +71,35 @@ sigfunc *compat_signal(int signo, sigfunc *func) #endif /*====================================== + * CORE : Console events for Windows + *--------------------------------------*/ +#ifdef _WIN32 +static BOOL WINAPI console_handler(DWORD c_event) +{ + switch(c_event) + { + case CTRL_CLOSE_EVENT: + case CTRL_LOGOFF_EVENT: + case CTRL_SHUTDOWN_EVENT: + if( shutdown_callback != NULL ) + shutdown_callback(); + else + runflag = CORE_ST_STOP;// auto-shutdown + break; + default: + break; + } + return TRUE; +} + +static void cevents_init() +{ + if (SetConsoleCtrlHandler(console_handler,TRUE)==FALSE) + ShowWarning ("Unable to install the console handler!\n"); +} +#endif + +/*====================================== * CORE : Signal Sub Function *--------------------------------------*/ static void sig_proc(int sn) @@ -251,6 +282,10 @@ int main (int argc, char **argv) db_init(); signals_init(); +#ifdef _WIN32 + cevents_init(); +#endif + timer_init(); socket_init(); plugins_init(); |