mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-22 11:22:18 -04:00
safe exit when console is closed on Windows (#1269)
This commit is contained in:
parent
b3097103e6
commit
ec600f80c3
@ -17,12 +17,12 @@
|
|||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "SDL.h" // haleyjd
|
#include "SDL.h" // haleyjd
|
||||||
|
|
||||||
#include "i_printf.h"
|
#include "i_printf.h"
|
||||||
|
#include "i_system.h"
|
||||||
#include "m_argv.h"
|
#include "m_argv.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
@ -34,6 +34,13 @@
|
|||||||
|
|
||||||
void D_DoomMain(void);
|
void D_DoomMain(void);
|
||||||
|
|
||||||
|
#if defined(WIN_LAUNCHER)
|
||||||
|
__declspec(dllexport) void Woof_Exit(void)
|
||||||
|
{
|
||||||
|
I_SafeExit(0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(WIN_LAUNCHER)
|
#if defined(WIN_LAUNCHER)
|
||||||
__declspec(dllexport) int Woof_Main(int argc, char **argv)
|
__declspec(dllexport) int Woof_Main(int argc, char **argv)
|
||||||
#else
|
#else
|
||||||
|
@ -13,10 +13,25 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
__declspec(dllexport) extern int Woof_Main(int argc, char **argv);
|
__declspec(dllexport) extern int Woof_Main(int argc, char **argv);
|
||||||
|
__declspec(dllexport) extern void Woof_Exit(void);
|
||||||
|
|
||||||
|
BOOL CtrlHandler(DWORD event)
|
||||||
|
{
|
||||||
|
if (event == CTRL_CLOSE_EVENT)
|
||||||
|
{
|
||||||
|
Woof_Exit();
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
SetConsoleCtrlHandler((PHANDLER_ROUTINE)(CtrlHandler), TRUE);
|
||||||
|
|
||||||
return Woof_Main(argc, argv);
|
return Woof_Main(argc, argv);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user