add shutdown and cleanup logic

develop
Myk Taylor 2023-04-10 00:00:47 -07:00
parent f0d19c9363
commit e4777d2688
No known key found for this signature in database
2 changed files with 7 additions and 1 deletions

@ -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;

@ -20,6 +20,7 @@ static const std::vector<std::string> 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;
}