diff --git a/launcher/launcher.cpp b/launcher/launcher.cpp index b1f1527..4aff697 100644 --- a/launcher/launcher.cpp +++ b/launcher/launcher.cpp @@ -2067,9 +2067,8 @@ int main_implementation(int argc, char *argv[]) { game->post_attach(); } - // game start - log_info("launcher", "calling game entry"); - avs::game::entry_main(); + // cleanup procedure + launcher::on_shutdown = [&]() { // clear presence richpresence::shutdown(); @@ -2158,6 +2157,11 @@ int main_implementation(int argc, char *argv[]) { #ifdef SPICE64 games::iidx::camera_release(); #endif + }; + + // game start + log_info("launcher", "calling game entry"); + avs::game::entry_main(); // shutdown log_warning("launcher", "end"); diff --git a/launcher/shutdown.cpp b/launcher/shutdown.cpp index bdd75f6..578498b 100644 --- a/launcher/shutdown.cpp +++ b/launcher/shutdown.cpp @@ -15,11 +15,15 @@ namespace launcher { + std::function on_shutdown = []() {}; + void stop_subsystems() { // note that it is possible for stop_subsystems to be called multiple times // (e.g., crashing, and then closing the window) // therefore, subsystems need to be guarded against multiple unload attempts log_info("launcher", "stopping subsystems"); + on_shutdown(); //_BUG: not thread safe, required? + on_shutdown = []() {}; // flush/stop logger logger::stop(); diff --git a/launcher/shutdown.h b/launcher/shutdown.h index aad346a..a6f2ddc 100644 --- a/launcher/shutdown.h +++ b/launcher/shutdown.h @@ -2,8 +2,10 @@ #include #include +#include namespace launcher { + extern std::function on_shutdown; void stop_subsystems(); void kill(UINT exit_code = EXIT_FAILURE); void shutdown(UINT exit_code = EXIT_SUCCESS);