From 43d771e3cd017384528137aaa5c8a3d0379764c7 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sun, 14 Jan 2024 11:25:50 +0100 Subject: [PATCH] System: handle other close events as well Give the engine and SDK time to shutdown properly. --- r5dev/windows/system.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/r5dev/windows/system.cpp b/r5dev/windows/system.cpp index 6fbec474..d72c47b0 100644 --- a/r5dev/windows/system.cpp +++ b/r5dev/windows/system.cpp @@ -56,6 +56,8 @@ ConsoleHandlerRoutine( { switch (eventCode) { + case CTRL_C_EVENT: + case CTRL_BREAK_EVENT: case CTRL_CLOSE_EVENT: case CTRL_LOGOFF_EVENT: case CTRL_SHUTDOWN_EVENT: @@ -64,7 +66,9 @@ ConsoleHandlerRoutine( g_pHostState->m_iNextState = HostStates_t::HS_SHUTDOWN; } - Sleep(10000); + // Give it time to shutdown properly, value is set to the max possible + // of SPI_GETWAITTOKILLSERVICETIMEOUT, which is 20000ms by default. + Sleep(20000); return TRUE; }