From 07c353727e54ffd68b269ae9780561bcbcc3b2fc Mon Sep 17 00:00:00 2001 From: Anonymous275 <36374260+Anonymous-275@users.noreply.github.com> Date: Wed, 19 Jan 2022 23:31:11 +0200 Subject: [PATCH] Added discord-rpc with different commit and proper signal handling --- .gitmodules | 3 +++ src/Launcher.cpp | 16 +++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.gitmodules b/.gitmodules index 0c68433..5eda04d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,6 @@ [submodule "include/easyloggingpp"] path = include/easyloggingpp url = https://github.com/amrayn/easyloggingpp.git +[submodule "include/discord-rpc"] + path = include/discord-rpc + url = https://github.com/discord/discord-rpc.git diff --git a/src/Launcher.cpp b/src/Launcher.cpp index efe285b..f3202a9 100644 --- a/src/Launcher.cpp +++ b/src/Launcher.cpp @@ -43,12 +43,10 @@ Launcher::~Launcher() { Abort(); } -BOOL WINAPI CtrlHandler(DWORD Flag) { - if((Flag >= 0 && Flag < 3) || (Flag > 4 && Flag < 7)) { - Launcher::StaticAbort(); - return 1; - } - return 0; +void ShutdownHandler(int sig) { + LOG(INFO) << "Got signal " << sig; + Launcher::StaticAbort(); + exit(sig); } void Launcher::StaticAbort(Launcher* Instance) { @@ -63,9 +61,9 @@ void Launcher::StaticAbort(Launcher* Instance) { void Launcher::WindowsInit() { system("cls"); SetConsoleTitleA(("BeamMP Launcher v" + FullVersion).c_str()); - if(!SetConsoleCtrlHandler(CtrlHandler, TRUE)) { - LOG(WARNING) << "Failed to set CtrlHandler"; - } + signal(SIGINT, ShutdownHandler); + signal(SIGTERM, ShutdownHandler); + signal(SIGABRT, ShutdownHandler); } void Launcher::LaunchGame() {