From 75035de2f4ac24adac97f31dc648a7845421f84e Mon Sep 17 00:00:00 2001 From: redpolline <11156324-redpolline@users.noreply.gitlab.com> Date: Wed, 11 Dec 2024 16:58:36 -0500 Subject: [PATCH] Add try_get_steam_client(). This allows the emulator to attempt to access the global steam_client object without creating it if it doesn't exist. --- dll/dll.cpp | 10 ++++++++++ dll/dll.h | 1 + 2 files changed, 11 insertions(+) diff --git a/dll/dll.cpp b/dll/dll.cpp index 4fef715..7029d37 100644 --- a/dll/dll.cpp +++ b/dll/dll.cpp @@ -140,6 +140,16 @@ Steam_Client *get_steam_client() return steamclient_instance; } +Steam_Client *try_get_steam_client() +{ + Steam_Client * ret = NULL; + if (global_mutex.try_lock() == true) { + ret = steamclient_instance; + global_mutex.unlock(); + } + return ret; +} + void destroy_client() { std::lock_guard lock(global_mutex); diff --git a/dll/dll.h b/dll/dll.h index 7e2effd..1cfdbb0 100644 --- a/dll/dll.h +++ b/dll/dll.h @@ -93,6 +93,7 @@ class GB_CCallbackInterImp : protected CCallbackBase Steam_Client *get_steam_client(); bool steamclient_has_ipv6_functions(); +Steam_Client *try_get_steam_client(); HSteamUser flat_hsteamuser(); HSteamPipe flat_hsteampipe();