diff --git a/dll/dll.cpp b/dll/dll.cpp index 2895520b..3b26b733 100644 --- a/dll/dll.cpp +++ b/dll/dll.cpp @@ -177,6 +177,7 @@ bool steamclient_has_ipv6_functions() static void *create_client_interface(const char *ver) { + std::lock_guard lock(global_mutex); if (strstr(ver, "SteamClient") == ver) { void *steam_client; diff --git a/dll/steam_apps.cpp b/dll/steam_apps.cpp index 2c52cf7e..8eb594f3 100644 --- a/dll/steam_apps.cpp +++ b/dll/steam_apps.cpp @@ -165,11 +165,15 @@ bool Steam_Apps::BGetDLCDataByIndex( int iDLC, AppId_t *pAppID, bool *pbAvailabl void Steam_Apps::InstallDLC( AppId_t nAppID ) { PRINT_DEBUG("InstallDLC\n"); + // we lock here because the API is supposed to modify the DLC list + std::lock_guard lock(global_mutex); } void Steam_Apps::UninstallDLC( AppId_t nAppID ) { PRINT_DEBUG("UninstallDLC\n"); + // we lock here because the API is supposed to modify the DLC list + std::lock_guard lock(global_mutex); } @@ -227,7 +231,7 @@ void Steam_Apps::RequestAppProofOfPurchaseKey( AppId_t nAppID ) bool Steam_Apps::GetCurrentBetaName( char *pchName, int cchNameBufferSize ) { PRINT_DEBUG("GetCurrentBetaName %i\n", cchNameBufferSize); - + std::lock_guard lock(global_mutex); if (pchName && cchNameBufferSize > settings->current_branch_name.size()) { memcpy(pchName, settings->current_branch_name.c_str(), settings->current_branch_name.size()); } @@ -239,6 +243,7 @@ bool Steam_Apps::GetCurrentBetaName( char *pchName, int cchNameBufferSize ) bool Steam_Apps::MarkContentCorrupt( bool bMissingFilesOnly ) { PRINT_DEBUG("MarkContentCorrupt\n"); + std::lock_guard lock(global_mutex); //TODO: warn user return true; } @@ -248,8 +253,8 @@ uint32 Steam_Apps::GetInstalledDepots( AppId_t appID, DepotId_t *pvecDepots, uin { PRINT_DEBUG("GetInstalledDepots %u, %u\n", appID, cMaxDepots); //TODO not sure about the behavior of this function, I didn't actually test this. - if (!pvecDepots) return 0; std::lock_guard lock(global_mutex); + if (!pvecDepots) return 0; unsigned int count = settings->depots.size(); if (cMaxDepots < count) count = cMaxDepots; std::copy(settings->depots.begin(), settings->depots.begin() + count, pvecDepots); @@ -319,6 +324,7 @@ bool Steam_Apps::BIsAppInstalled( AppId_t appID ) CSteamID Steam_Apps::GetAppOwner() { PRINT_DEBUG("GetAppOwner\n"); + std::lock_guard lock(global_mutex); return settings->get_local_steam_id(); } @@ -337,6 +343,7 @@ const char *Steam_Apps::GetLaunchQueryParam( const char *pchKey ) bool Steam_Apps::GetDlcDownloadProgress( AppId_t nAppID, uint64 *punBytesDownloaded, uint64 *punBytesTotal ) { PRINT_DEBUG("GetDlcDownloadProgress\n"); + std::lock_guard lock(global_mutex); return false; } @@ -345,6 +352,7 @@ bool Steam_Apps::GetDlcDownloadProgress( AppId_t nAppID, uint64 *punBytesDownloa int Steam_Apps::GetAppBuildId() { PRINT_DEBUG("GetAppBuildId\n"); + std::lock_guard lock(global_mutex); return this->settings->build_id; } @@ -427,6 +435,7 @@ int Steam_Apps::GetLaunchCommandLine( char *pszCommandLine, int cubCommandLine ) bool Steam_Apps::BIsSubscribedFromFamilySharing() { PRINT_DEBUG("BIsSubscribedFromFamilySharing\n"); + std::lock_guard lock(global_mutex); return false; } @@ -434,6 +443,7 @@ bool Steam_Apps::BIsSubscribedFromFamilySharing() bool Steam_Apps::BIsTimedTrial( uint32* punSecondsAllowed, uint32* punSecondsPlayed ) { PRINT_DEBUG("BIsTimedTrial\n"); + std::lock_guard lock(global_mutex); return false; } @@ -441,5 +451,6 @@ bool Steam_Apps::BIsTimedTrial( uint32* punSecondsAllowed, uint32* punSecondsPla bool Steam_Apps::SetDlcContext( AppId_t nAppID ) { PRINT_DEBUG("SetDlcContext %u\n", nAppID); + std::lock_guard lock(global_mutex); return true; } diff --git a/dll/steam_client.cpp b/dll/steam_client.cpp index 746f4baa..225ae7c4 100644 --- a/dll/steam_client.cpp +++ b/dll/steam_client.cpp @@ -879,7 +879,7 @@ uint32 Steam_Client::GetIPCCallCount() // callbacks will occur directly after the API function is called that generated the warning or message. void Steam_Client::SetWarningMessageHook( SteamAPIWarningMessageHook_t pFunction ) { - PRINT_DEBUG("Steam_Client::SetWarningMessageHook\n"); + PRINT_DEBUG("Steam_Client::SetWarningMessageHook, %p\n", pFunction); } // Trigger global shutdown for the DLL @@ -1103,7 +1103,8 @@ void Steam_Client::DEPRECATED_Remove_SteamAPI_CPostAPIResultInProcess( void (*)( void Steam_Client::Set_SteamAPI_CCheckCallbackRegisteredInProcess( SteamAPI_CheckCallbackRegistered_t func ) { - PRINT_DEBUG("Set_SteamAPI_CCheckCallbackRegisteredInProcess\n"); + PRINT_DEBUG("Set_SteamAPI_CCheckCallbackRegisteredInProcess %p\n", func); + std::lock_guard lock(global_mutex); } void Steam_Client::Set_SteamAPI_CPostAPIResultInProcess( SteamAPI_PostAPIResultInProcess_t func ) diff --git a/dll/steam_gameserver.cpp b/dll/steam_gameserver.cpp index 597651c5..c680cc5f 100644 --- a/dll/steam_gameserver.cpp +++ b/dll/steam_gameserver.cpp @@ -187,7 +187,7 @@ void Steam_GameServer::LogOff() // status functions bool Steam_GameServer::BLoggedOn() { - PRINT_DEBUG("BLoggedOn\n"); + PRINT_DEBUG("Steam_GameServer::BLoggedOn\n"); std::lock_guard lock(global_mutex); return logged_in; } @@ -439,6 +439,7 @@ void Steam_GameServer::SendUserDisconnect( CSteamID steamIDUser ) bool Steam_GameServer::BUpdateUserData( CSteamID steamIDUser, const char *pchPlayerName, uint32 uScore ) { PRINT_DEBUG("BUpdateUserData %llu %s %u\n", steamIDUser.ConvertToUint64(), pchPlayerName, uScore); + std::lock_guard lock(global_mutex); auto player_it = std::find_if(players.begin(), players.end(), [&steamIDUser](std::pair& player) { @@ -610,6 +611,7 @@ void Steam_GameServer::CancelAuthTicket( HAuthTicket hAuthTicket ) EUserHasLicenseForAppResult Steam_GameServer::UserHasLicenseForApp( CSteamID steamID, AppId_t appID ) { PRINT_DEBUG("Steam_GameServer::UserHasLicenseForApp\n"); + std::lock_guard lock(global_mutex); return k_EUserHasLicenseResultHasLicense; } @@ -630,6 +632,7 @@ bool Steam_GameServer::RequestUserGroupStatus( CSteamID steamIDUser, CSteamID st void Steam_GameServer::GetGameplayStats( ) { PRINT_DEBUG("GetGameplayStats\n"); + std::lock_guard lock(global_mutex); } STEAM_CALL_RESULT( GSReputation_t ) diff --git a/dll/steam_remoteplay.h b/dll/steam_remoteplay.h index 868a7dd2..e183b619 100644 --- a/dll/steam_remoteplay.h +++ b/dll/steam_remoteplay.h @@ -66,6 +66,7 @@ Steam_RemotePlay(class Settings *settings, class Networking *network, class Stea uint32 GetSessionCount() { PRINT_DEBUG("Steam_RemotePlay::GetSessionCount\n"); + std::lock_guard lock(global_mutex); return 0; } @@ -73,6 +74,7 @@ uint32 GetSessionCount() uint32 GetSessionID( int iSessionIndex ) { PRINT_DEBUG("Steam_RemotePlay::GetSessionID\n"); + std::lock_guard lock(global_mutex); return 0; } @@ -80,6 +82,7 @@ uint32 GetSessionID( int iSessionIndex ) CSteamID GetSessionSteamID( uint32 unSessionID ) { PRINT_DEBUG("Steam_RemotePlay::GetSessionSteamID\n"); + std::lock_guard lock(global_mutex); return k_steamIDNil; } @@ -88,6 +91,7 @@ CSteamID GetSessionSteamID( uint32 unSessionID ) const char *GetSessionClientName( uint32 unSessionID ) { PRINT_DEBUG("Steam_RemotePlay::GetSessionClientName\n"); + std::lock_guard lock(global_mutex); return NULL; } @@ -95,6 +99,7 @@ const char *GetSessionClientName( uint32 unSessionID ) ESteamDeviceFormFactor GetSessionClientFormFactor( uint32 unSessionID ) { PRINT_DEBUG("Steam_RemotePlay::GetSessionClientFormFactor\n"); + std::lock_guard lock(global_mutex); return k_ESteamDeviceFormFactorUnknown; } @@ -112,6 +117,7 @@ bool BGetSessionClientResolution( uint32 unSessionID, int *pnResolutionX, int *p bool BStartRemotePlayTogether( bool bShowOverlay ) { PRINT_DEBUG("Steam_RemotePlay::BStartRemotePlayTogether: %d\n", (int)bShowOverlay); + std::lock_guard lock(global_mutex); return false; } @@ -120,6 +126,7 @@ bool BStartRemotePlayTogether( bool bShowOverlay ) bool BSendRemotePlayTogetherInvite( CSteamID steamIDFriend ) { PRINT_DEBUG("Steam_RemotePlay::BSendRemotePlayTogetherInvite\n"); + std::lock_guard lock(global_mutex); return false; } diff --git a/dll/steam_user.h b/dll/steam_user.h index 0a03a78f..d634a9a6 100644 --- a/dll/steam_user.h +++ b/dll/steam_user.h @@ -77,7 +77,7 @@ HSteamUser GetHSteamUser() // The Steam client will automatically be trying to recreate the connection as often as possible. bool BLoggedOn() { - PRINT_DEBUG("BLoggedOn\n"); + PRINT_DEBUG("Steam_User::BLoggedOn\n"); return !settings->is_offline(); } diff --git a/dll/steam_user_stats.h b/dll/steam_user_stats.h index b8bb5a9a..2db556c3 100644 --- a/dll/steam_user_stats.h +++ b/dll/steam_user_stats.h @@ -296,10 +296,11 @@ bool RequestCurrentStats() bool GetStat( const char *pchName, int32 *pData ) { PRINT_DEBUG("GetStat int32 %s\n", pchName); + std::lock_guard lock(global_mutex); + if (!pchName || !pData) return false; std::string stat_name = ascii_to_lowercase(pchName); - std::lock_guard lock(global_mutex); auto stats_config = settings->getStats(); auto stats_data = stats_config.find(stat_name); if (stats_data != stats_config.end()) { @@ -332,10 +333,11 @@ bool GetStat( const char *pchName, int32 *pData ) bool GetStat( const char *pchName, float *pData ) { PRINT_DEBUG("GetStat float %s\n", pchName); + std::lock_guard lock(global_mutex); + if (!pchName || !pData) return false; std::string stat_name = ascii_to_lowercase(pchName); - std::lock_guard lock(global_mutex); auto stats_config = settings->getStats(); auto stats_data = stats_config.find(stat_name); if (stats_data != stats_config.end()) { @@ -370,10 +372,11 @@ bool GetStat( const char *pchName, float *pData ) bool SetStat( const char *pchName, int32 nData ) { PRINT_DEBUG("SetStat int32 %s\n", pchName); + std::lock_guard lock(global_mutex); + if (!pchName) return false; std::string stat_name = ascii_to_lowercase(pchName); - std::lock_guard lock(global_mutex); auto cached_stat = stats_cache_int.find(stat_name); if (cached_stat != stats_cache_int.end()) { if (cached_stat->second == nData) return true; @@ -399,10 +402,11 @@ bool SetStat( const char *pchName, int32 nData ) bool SetStat( const char *pchName, float fData ) { PRINT_DEBUG("SetStat float %s\n", pchName); + std::lock_guard lock(global_mutex); + if (!pchName) return false; std::string stat_name = ascii_to_lowercase(pchName); - std::lock_guard lock(global_mutex); auto cached_stat = stats_cache_float.find(stat_name); if (cached_stat != stats_cache_float.end()) { if (cached_stat->second == fData) return true; @@ -428,11 +432,11 @@ bool SetStat( const char *pchName, float fData ) bool UpdateAvgRateStat( const char *pchName, float flCountThisSession, double dSessionLength ) { PRINT_DEBUG("UpdateAvgRateStat %s\n", pchName); + std::lock_guard lock(global_mutex); + if (!pchName) return false; std::string stat_name = ascii_to_lowercase(pchName); - std::lock_guard lock(global_mutex); - char data[sizeof(float) + sizeof(float) + sizeof(double)]; int read_data = local_storage->get_data(Local_Storage::stats_storage_folder, stat_name, (char* )data, sizeof(*data)); float oldcount = 0; @@ -463,9 +467,10 @@ bool UpdateAvgRateStat( const char *pchName, float flCountThisSession, double dS bool GetAchievement( const char *pchName, bool *pbAchieved ) { PRINT_DEBUG("GetAchievement %s\n", pchName); - if (pchName == nullptr) return false; std::lock_guard lock(global_mutex); + if (pchName == nullptr) return false; + try { auto it = defined_achievements_find(pchName); if (it == defined_achievements.end()) return false; @@ -486,12 +491,12 @@ bool GetAchievement( const char *pchName, bool *pbAchieved ) bool SetAchievement( const char *pchName ) { PRINT_DEBUG("SetAchievement %s\n", pchName); + std::lock_guard lock(global_mutex); + if (pchName == nullptr) return false; if (settings->achievement_bypass) return true; - std::lock_guard lock(global_mutex); - try { auto it = defined_achievements_find(pchName); if (it == defined_achievements.end()) return false; @@ -517,9 +522,10 @@ bool SetAchievement( const char *pchName ) bool ClearAchievement( const char *pchName ) { PRINT_DEBUG("ClearAchievement %s\n", pchName); - if (pchName == nullptr) return false; std::lock_guard lock(global_mutex); + if (pchName == nullptr) return false; + try { auto it = defined_achievements_find(pchName); if (it == defined_achievements.end()) return false; @@ -543,9 +549,10 @@ bool ClearAchievement( const char *pchName ) bool GetAchievementAndUnlockTime( const char *pchName, bool *pbAchieved, uint32 *punUnlockTime ) { PRINT_DEBUG("GetAchievementAndUnlockTime\n"); - if (pchName == nullptr) return false; std::lock_guard lock(global_mutex); + if (pchName == nullptr) return false; + try { auto it = defined_achievements_find(pchName); if (it == defined_achievements.end()) return false; @@ -594,16 +601,16 @@ bool StoreStats() int GetAchievementIcon( const char *pchName ) { PRINT_DEBUG("GetAchievementIcon\n"); - if (pchName == nullptr) return 0; std::lock_guard lock(global_mutex); + if (pchName == nullptr) return 0; return 0; } std::string get_achievement_icon_name( const char *pchName, bool pbAchieved ) { - if (pchName == nullptr) return ""; std::lock_guard lock(global_mutex); + if (pchName == nullptr) return ""; try { auto it = defined_achievements_find(pchName); @@ -623,10 +630,11 @@ std::string get_achievement_icon_name( const char *pchName, bool pbAchieved ) const char * GetAchievementDisplayAttribute( const char *pchName, const char *pchKey ) { PRINT_DEBUG("GetAchievementDisplayAttribute %s %s\n", pchName, pchKey); + std::lock_guard lock(global_mutex); + if (pchName == nullptr) return ""; if (pchKey == nullptr) return ""; - std::lock_guard lock(global_mutex); if (strcmp (pchKey, "name") == 0) { try { @@ -664,9 +672,10 @@ const char * GetAchievementDisplayAttribute( const char *pchName, const char *pc bool IndicateAchievementProgress( const char *pchName, uint32 nCurProgress, uint32 nMaxProgress ) { PRINT_DEBUG("IndicateAchievementProgress %s\n", pchName); - if (pchName == nullptr) return false; std::lock_guard lock(global_mutex); + if (pchName == nullptr) return false; + try { auto it = defined_achievements_find(pchName); if (it == defined_achievements.end()) return false; @@ -718,6 +727,7 @@ uint32 GetNumAchievements() const char * GetAchievementName( uint32 iAchievement ) { PRINT_DEBUG("GetAchievementName\n"); + std::lock_guard lock(global_mutex); if (iAchievement >= sorted_achievement_names.size()) { return ""; } @@ -756,10 +766,10 @@ SteamAPICall_t RequestUserStats( CSteamID steamIDUser ) bool GetUserStat( CSteamID steamIDUser, const char *pchName, int32 *pData ) { PRINT_DEBUG("GetUserStat %s %llu\n", pchName, steamIDUser.ConvertToUint64()); - if (pchName == nullptr) return false; - std::lock_guard lock(global_mutex); + if (pchName == nullptr) return false; + if (steamIDUser == settings->get_local_steam_id()) { GetStat(pchName, pData); } else { @@ -772,10 +782,10 @@ bool GetUserStat( CSteamID steamIDUser, const char *pchName, int32 *pData ) bool GetUserStat( CSteamID steamIDUser, const char *pchName, float *pData ) { PRINT_DEBUG("GetUserStat %s %llu\n", pchName, steamIDUser.ConvertToUint64()); - if (pchName == nullptr) return false; - std::lock_guard lock(global_mutex); + if (pchName == nullptr) return false; + if (steamIDUser == settings->get_local_steam_id()) { GetStat(pchName, pData); } else { @@ -788,8 +798,9 @@ bool GetUserStat( CSteamID steamIDUser, const char *pchName, float *pData ) bool GetUserAchievement( CSteamID steamIDUser, const char *pchName, bool *pbAchieved ) { PRINT_DEBUG("GetUserAchievement %s\n", pchName); - if (pchName == nullptr) return false; std::lock_guard lock(global_mutex); + + if (pchName == nullptr) return false; if (steamIDUser == settings->get_local_steam_id()) { return GetAchievement(pchName, pbAchieved); @@ -802,9 +813,10 @@ bool GetUserAchievement( CSteamID steamIDUser, const char *pchName, bool *pbAchi bool GetUserAchievementAndUnlockTime( CSteamID steamIDUser, const char *pchName, bool *pbAchieved, uint32 *punUnlockTime ) { PRINT_DEBUG("GetUserAchievementAndUnlockTime %s\n", pchName); - if (pchName == nullptr) return false; std::lock_guard lock(global_mutex); + if (pchName == nullptr) return false; + if (steamIDUser == settings->get_local_steam_id()) { return GetAchievementAndUnlockTime(pchName, pbAchieved, punUnlockTime); } @@ -965,7 +977,7 @@ SteamAPICall_t DownloadLeaderboardEntries( SteamLeaderboard_t hSteamLeaderboard, // if a user doesn't have a leaderboard entry, they won't be included in the result // a max of 100 users can be downloaded at a time, with only one outstanding call at a time STEAM_METHOD_DESC(Downloads leaderboard entries for an arbitrary set of users - ELeaderboardDataRequest is k_ELeaderboardDataRequestUsers) - STEAM_CALL_RESULT( LeaderboardScoresDownloaded_t ) +STEAM_CALL_RESULT( LeaderboardScoresDownloaded_t ) SteamAPICall_t DownloadLeaderboardEntriesForUsers( SteamLeaderboard_t hSteamLeaderboard, STEAM_ARRAY_COUNT_D(cUsers, Array of users to retrieve) CSteamID *prgUsers, int cUsers ) { diff --git a/dll/steam_utils.h b/dll/steam_utils.h index 81e468c7..feb8d2cd 100644 --- a/dll/steam_utils.h +++ b/dll/steam_utils.h @@ -89,9 +89,10 @@ const char *GetIPCountry() bool GetImageSize( int iImage, uint32 *pnWidth, uint32 *pnHeight ) { PRINT_DEBUG("GetImageSize %i\n", iImage); - if (!iImage || !pnWidth || !pnHeight) return false; std::lock_guard lock(global_mutex); + if (!iImage || !pnWidth || !pnHeight) return false; + auto image = settings->images.find(iImage); if (image == settings->images.end()) return false; @@ -106,9 +107,10 @@ bool GetImageSize( int iImage, uint32 *pnWidth, uint32 *pnHeight ) bool GetImageRGBA( int iImage, uint8 *pubDest, int nDestBufferSize ) { PRINT_DEBUG("GetImageRGBA %i\n", iImage); - if (!iImage || !pubDest || !nDestBufferSize) return false; std::lock_guard lock(global_mutex); + if (!iImage || !pubDest || !nDestBufferSize) return false; + auto image = settings->images.find(iImage); if (image == settings->images.end()) return false; @@ -138,6 +140,7 @@ uint8 GetCurrentBatteryPower() uint32 GetAppID() { PRINT_DEBUG("GetAppID\n"); + std::lock_guard lock(global_mutex); return settings->get_local_game_id().AppID(); } @@ -147,6 +150,7 @@ uint32 GetAppID() void SetOverlayNotificationPosition( ENotificationPosition eNotificationPosition ) { PRINT_DEBUG("SetOverlayNotificationPosition\n"); + std::lock_guard lock(global_mutex); overlay->SetNotificationPosition(eNotificationPosition); } @@ -156,12 +160,12 @@ void SetOverlayNotificationPosition( ENotificationPosition eNotificationPosition bool IsAPICallCompleted( SteamAPICall_t hSteamAPICall, bool *pbFailed ) { PRINT_DEBUG("IsAPICallCompleted: %llu\n", hSteamAPICall); + std::lock_guard lock(global_mutex); if (hSteamAPICall == 1) { //bug ? soul calibur 6 calls this function with the return value 1 of Steam_User_Stats::RequestCurrentStats and expects this function to return true if (pbFailed) *pbFailed = true; return true; } - std::lock_guard lock(global_mutex); if (!callback_results->exists(hSteamAPICall)) return false; if (pbFailed) *pbFailed = false; return true; //all api calls "complete" right away @@ -222,6 +226,7 @@ void SetWarningMessageHook( SteamAPIWarningMessageHook_t pFunction ) bool IsOverlayEnabled() { PRINT_DEBUG("IsOverlayEnabled\n"); + std::lock_guard lock(global_mutex); return overlay->Ready(); } @@ -238,6 +243,7 @@ bool IsOverlayEnabled() bool BOverlayNeedsPresent() { PRINT_DEBUG("BOverlayNeedsPresent\n"); + std::lock_guard lock(global_mutex); return overlay->NeedPresent(); } @@ -271,6 +277,7 @@ bool ShowGamepadTextInput( EGamepadTextInputMode eInputMode, EGamepadTextInputLi bool ShowGamepadTextInput( EGamepadTextInputMode eInputMode, EGamepadTextInputLineMode eLineInputMode, const char *pchDescription, uint32 unCharMax ) { PRINT_DEBUG("ShowGamepadTextInput old\n"); + std::lock_guard lock(global_mutex); return ShowGamepadTextInput(eInputMode, eLineInputMode, pchDescription, unCharMax, NULL); } @@ -292,6 +299,7 @@ bool GetEnteredGamepadTextInput( char *pchText, uint32 cchText ) const char *GetSteamUILanguage() { PRINT_DEBUG("GetSteamUILanguage\n"); + std::lock_guard lock(global_mutex); return settings->get_language(); } @@ -300,6 +308,7 @@ const char *GetSteamUILanguage() bool IsSteamRunningInVR() { PRINT_DEBUG("IsSteamRunningInVR\n"); + std::lock_guard lock(global_mutex); return false; } @@ -308,6 +317,7 @@ bool IsSteamRunningInVR() void SetOverlayNotificationInset( int nHorizontalInset, int nVerticalInset ) { PRINT_DEBUG("SetOverlayNotificationInset\n"); + std::lock_guard lock(global_mutex); overlay->SetNotificationInset(nHorizontalInset, nVerticalInset); } @@ -318,6 +328,7 @@ void SetOverlayNotificationInset( int nHorizontalInset, int nVerticalInset ) bool IsSteamInBigPictureMode() { PRINT_DEBUG("IsSteamInBigPictureMode\n"); + std::lock_guard lock(global_mutex); return false; } @@ -333,6 +344,7 @@ void StartVRDashboard() bool IsVRHeadsetStreamingEnabled() { PRINT_DEBUG("IsVRHeadsetStreamingEnabled\n"); + std::lock_guard lock(global_mutex); return false; } @@ -351,6 +363,7 @@ void SetVRHeadsetStreamingEnabled( bool bEnabled ) bool IsSteamChinaLauncher() { PRINT_DEBUG("IsSteamChinaLauncher\n"); + std::lock_guard lock(global_mutex); return false; } @@ -359,6 +372,7 @@ bool IsSteamChinaLauncher() bool InitFilterText() { PRINT_DEBUG("InitFilterText old\n"); + std::lock_guard lock(global_mutex); return false; } @@ -368,6 +382,7 @@ bool InitFilterText() bool InitFilterText( uint32 unFilterOptions ) { PRINT_DEBUG("InitFilterText\n"); + std::lock_guard lock(global_mutex); return false; } @@ -380,6 +395,7 @@ bool InitFilterText( uint32 unFilterOptions ) int FilterText( char* pchOutFilteredText, uint32 nByteSizeOutFilteredText, const char * pchInputMessage, bool bLegalOnly ) { PRINT_DEBUG("FilterText old\n"); + std::lock_guard lock(global_mutex); return FilterText(k_ETextFilteringContextUnknown, CSteamID(), pchInputMessage, pchOutFilteredText, nByteSizeOutFilteredText ); } @@ -393,6 +409,7 @@ int FilterText( char* pchOutFilteredText, uint32 nByteSizeOutFilteredText, const int FilterText( ETextFilteringContext eContext, CSteamID sourceSteamID, const char *pchInputMessage, char *pchOutFilteredText, uint32 nByteSizeOutFilteredText ) { PRINT_DEBUG("FilterText\n"); + std::lock_guard lock(global_mutex); if (!nByteSizeOutFilteredText) return 0; unsigned len = strlen(pchInputMessage); if (!len) return 0; @@ -411,6 +428,7 @@ int FilterText( ETextFilteringContext eContext, CSteamID sourceSteamID, const ch ESteamIPv6ConnectivityState GetIPv6ConnectivityState( ESteamIPv6ConnectivityProtocol eProtocol ) { PRINT_DEBUG("GetIPv6ConnectivityState\n"); + std::lock_guard lock(global_mutex); return k_ESteamIPv6ConnectivityState_Unknown; } diff --git a/overlay_experimental/steam_overlay.cpp b/overlay_experimental/steam_overlay.cpp index db0cb1e5..5504a9e9 100644 --- a/overlay_experimental/steam_overlay.cpp +++ b/overlay_experimental/steam_overlay.cpp @@ -210,6 +210,8 @@ void Steam_Overlay::SetupOverlay() void Steam_Overlay::UnSetupOverlay() { + PRINT_DEBUG("%s\n", __FUNCTION__); + std::lock_guard lock(overlay_mutex); ingame_overlay::StopRendererDetection(); if (!Ready() && future_renderer.valid()) { if (future_renderer.wait_for(std::chrono::milliseconds{500}) == std::future_status::ready) { @@ -358,10 +360,10 @@ void Steam_Overlay::NotifyUserAchievement() void Steam_Overlay::SetLobbyInvite(Friend friendId, uint64 lobbyId) { + std::lock_guard lock(overlay_mutex); if (!Ready()) return; - std::lock_guard lock(overlay_mutex); auto i = friends.find(friendId); if (i != friends.end()) { @@ -377,10 +379,10 @@ void Steam_Overlay::SetLobbyInvite(Friend friendId, uint64 lobbyId) void Steam_Overlay::SetRichInvite(Friend friendId, const char* connect_str) { + std::lock_guard lock(overlay_mutex); if (!Ready()) return; - std::lock_guard lock(overlay_mutex); auto i = friends.find(friendId); if (i != friends.end()) { @@ -421,8 +423,8 @@ void Steam_Overlay::FriendDisconnect(Friend _friend) void Steam_Overlay::AddMessageNotification(std::string const& message) { - if (settings->disable_overlay_friend_notification) return; std::lock_guard lock(notifications_mutex); + if (settings->disable_overlay_friend_notification) return; int id = find_free_notification_id(notifications); if (id != 0) { @@ -487,8 +489,8 @@ void Steam_Overlay::AddAchievementNotification(nlohmann::json const& ach) void Steam_Overlay::AddInviteNotification(std::pair& wnd_state) { - if (settings->disable_overlay_friend_notification) return; std::lock_guard lock(notifications_mutex); + if (settings->disable_overlay_friend_notification) return; int id = find_free_notification_id(notifications); if (id != 0) {