Stabilize steamproxy cleanup

This commit is contained in:
momo5502 2022-10-01 18:52:15 +02:00
parent 95cf7736c6
commit 5fc3ee3588

View File

@ -93,6 +93,8 @@ namespace steam_proxy
client_engine = nullptr; client_engine = nullptr;
client_user = nullptr; client_user = nullptr;
client_utils = nullptr; client_utils = nullptr;
client_friends = nullptr;
client_ugc = nullptr;
steam_pipe = nullptr; steam_pipe = nullptr;
global_user = nullptr; global_user = nullptr;
@ -100,24 +102,34 @@ namespace steam_proxy
steam_client_module = utils::nt::library{nullptr}; steam_client_module = utils::nt::library{nullptr};
} }
bool perform_cleanup_if_needed()
{
if (steam_client_module
&& steam_pipe
&& global_user
&& steam_client_module.invoke<bool>("Steam_BConnected", global_user,
steam_pipe)
&& steam_client_module.invoke<bool>("Steam_BLoggedOn", global_user, steam_pipe)
)
{
return false;
}
do_cleanup();
return true;
}
void clean_up_on_error() void clean_up_on_error()
{ {
scheduler::schedule([] scheduler::schedule([]
{ {
if (steam_client_module if (perform_cleanup_if_needed())
&& steam_pipe
&& global_user
&& steam_client_module.invoke<bool>("Steam_BConnected", global_user,
steam_pipe)
&& steam_client_module.invoke<bool>("Steam_BLoggedOn", global_user, steam_pipe)
)
{ {
return scheduler::cond_continue; return scheduler::cond_end;
} }
do_cleanup(); return scheduler::cond_continue;
return scheduler::cond_end; }, scheduler::main);
});
} }
ownership_state start_mod_unsafe(const std::string& title, size_t app_id) ownership_state start_mod_unsafe(const std::string& title, size_t app_id)