From e4777d268836d34f1a11ff376dd26cb4a9130c0a Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Mon, 10 Apr 2023 00:00:47 -0700 Subject: [PATCH] add shutdown and cleanup logic --- library/Core.cpp | 1 + library/modules/DFSteam.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/library/Core.cpp b/library/Core.cpp index d03e8c632..b1fe2d389 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -2281,6 +2281,7 @@ int Core::Shutdown ( void ) allModules.clear(); Textures::cleanup(); DFSDL::cleanup(); + DFSteam::cleanup(); memset(&(s_mods), 0, sizeof(s_mods)); d.reset(); return -1; diff --git a/library/modules/DFSteam.cpp b/library/modules/DFSteam.cpp index 8cc921608..f58bc7cb4 100644 --- a/library/modules/DFSteam.cpp +++ b/library/modules/DFSteam.cpp @@ -20,6 +20,7 @@ static const std::vector STEAM_LIBS { }; bool (*g_SteamAPI_Init)() = nullptr; +void (*g_SteamAPI_Shutdown)() = nullptr; bool (*g_SteamAPI_ISteamUtils_IsSteamRunningOnSteamDeck)() = nullptr; bool DFSteam::init(color_ostream& out) { @@ -39,9 +40,10 @@ bool DFSteam::init(color_ostream& out) { } bind(g_steam_handle, SteamAPI_Init); + bind(g_steam_handle, SteamAPI_Shutdown); // TODO: can we remove this initialization of the Steam API once we move to dfhooks? - if (!g_SteamAPI_Init || !g_SteamAPI_Init()) + if (!g_SteamAPI_Init || !g_SteamAPI_Shutdown || !g_SteamAPI_Init()) return false; bind(g_steam_handle, SteamAPI_ISteamUtils_IsSteamRunningOnSteamDeck); @@ -55,6 +57,9 @@ void DFSteam::cleanup() { if (!g_steam_handle) return; + if (g_SteamAPI_Shutdown) + g_SteamAPI_Shutdown(); + ClosePlugin(g_steam_handle); g_steam_handle = nullptr; }