mirror of
https://github.com/dashr9230/SA-MP.git
synced 2025-09-19 20:26:14 +08:00
[server] Add console control handler
This commit is contained in:
@ -40,6 +40,25 @@ int iCookieLogging = 1;
|
|||||||
extern LONG WINAPI exc_handler(_EXCEPTION_POINTERS* exc_inf);
|
extern LONG WINAPI exc_handler(_EXCEPTION_POINTERS* exc_inf);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
|
||||||
|
BOOL WINAPI CtrlHandler(DWORD type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case CTRL_C_EVENT:
|
||||||
|
case CTRL_BREAK_EVENT:
|
||||||
|
case CTRL_CLOSE_EVENT:
|
||||||
|
case CTRL_LOGOFF_EVENT:
|
||||||
|
case CTRL_SHUTDOWN_EVENT:
|
||||||
|
bQuitApp = true;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
|
|
||||||
void ServerPasswordChanged()
|
void ServerPasswordChanged()
|
||||||
@ -244,6 +263,7 @@ int main (int argc, char** argv)
|
|||||||
pConsole->AddStringVariable("version", CON_VARFLAG_RULE | CON_VARFLAG_READONLY, SAMP_VERSION);
|
pConsole->AddStringVariable("version", CON_VARFLAG_RULE | CON_VARFLAG_READONLY, SAMP_VERSION);
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
SetConsoleCtrlHandler(CtrlHandler, TRUE);
|
||||||
// Setup the exception handler on windows
|
// Setup the exception handler on windows
|
||||||
SetUnhandledExceptionFilter(exc_handler);
|
SetUnhandledExceptionFilter(exc_handler);
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user