mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Give process time to shutdown properly
Game gets max 10 seconds to shutdown properly when closed directly by the external console window (g_pHostState->m_iNextState = HostStates_t::HS_SHUTDOWN).
This commit is contained in:
parent
93375d9a1f
commit
b846809ac3
@ -11,6 +11,7 @@
|
||||
#ifndef DEDICATED
|
||||
#include "windows/id3dx.h"
|
||||
#endif // !DEDICATED
|
||||
#include "windows/system.h"
|
||||
#include "windows/console.h"
|
||||
#include "common/opcodes.h"
|
||||
|
||||
@ -111,6 +112,7 @@ void Console_Init()
|
||||
SetConsoleBackgroundColor(0x0000);
|
||||
AnsiColors_Init();
|
||||
}
|
||||
SetConsoleCtrlHandler(ConsoleHandlerRoutine, true);
|
||||
}
|
||||
|
||||
//#############################################################################
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "core/stdafx.h"
|
||||
#include "windows/system.h"
|
||||
#include "engine/host_state.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
typedef BOOL(WINAPI* IGetVersionExA)(
|
||||
@ -48,6 +49,28 @@ HPeekMessage(
|
||||
#endif // DEDICATED
|
||||
}
|
||||
|
||||
BOOL
|
||||
WINAPI
|
||||
ConsoleHandlerRoutine(
|
||||
DWORD eventCode)
|
||||
{
|
||||
switch (eventCode)
|
||||
{
|
||||
case CTRL_CLOSE_EVENT:
|
||||
case CTRL_LOGOFF_EVENT:
|
||||
case CTRL_SHUTDOWN_EVENT:
|
||||
if (g_pHostState)
|
||||
{
|
||||
g_pHostState->m_iNextState = HostStates_t::HS_SHUTDOWN;
|
||||
}
|
||||
|
||||
Sleep(10000);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//#############################################################################
|
||||
// MANAGEMENT
|
||||
//#############################################################################
|
||||
|
@ -1,4 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
BOOL
|
||||
WINAPI
|
||||
ConsoleHandlerRoutine(
|
||||
DWORD eventCode);
|
||||
|
||||
void WinSys_Attach();
|
||||
void WinSys_Detach();
|
||||
|
Loading…
x
Reference in New Issue
Block a user