From f6ec01fd49de444c4a0df3623142e42295ab0aea Mon Sep 17 00:00:00 2001 From: a Date: Fri, 6 Dec 2024 23:13:38 +0200 Subject: [PATCH 01/10] set missing result data in `Steam_UGC::SetUserItemVote()` --- dll/steam_ugc.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dll/steam_ugc.cpp b/dll/steam_ugc.cpp index 66ce3274..ea0bf7d1 100644 --- a/dll/steam_ugc.cpp +++ b/dll/steam_ugc.cpp @@ -1188,9 +1188,6 @@ SteamAPICall_t Steam_UGC::SetUserItemVote( PublishedFileId_t nPublishedFileID, b if (!settings->isModInstalled(nPublishedFileID)) return k_uAPICallInvalid; // TODO is this correct auto mod = settings->getMod(nPublishedFileID); - SetUserItemVoteResult_t data{}; - data.m_eResult = EResult::k_EResultOK; - data.m_nPublishedFileId = nPublishedFileID; if (bVoteUp) { ++mod.votesUp; } else { @@ -1198,6 +1195,11 @@ SteamAPICall_t Steam_UGC::SetUserItemVote( PublishedFileId_t nPublishedFileID, b } settings->addModDetails(nPublishedFileID, mod); + SetUserItemVoteResult_t data{}; + data.m_eResult = EResult::k_EResultOK; + data.m_nPublishedFileId = nPublishedFileID; + data.m_bVoteUp = bVoteUp; + auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data)); callbacks->addCBResult(data.k_iCallback, &data, sizeof(data)); return ret; From b63140ca63551706a9b362461aab8c86fca9ecb8 Mon Sep 17 00:00:00 2001 From: a Date: Fri, 6 Dec 2024 23:08:32 +0200 Subject: [PATCH 02/10] properly extract inventory item quantity in `Steam_Inventory::GetResultItems()` --- dll/steam_inventory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dll/steam_inventory.cpp b/dll/steam_inventory.cpp index 9e0b19f3..fcdbbe49 100644 --- a/dll/steam_inventory.cpp +++ b/dll/steam_inventory.cpp @@ -164,7 +164,7 @@ bool Steam_Inventory::GetResultItems( SteamInventoryResult_t resultHandle, pOutItemsArray->m_itemId = pOutItemsArray->m_iDefinition; try { - pOutItemsArray->m_unQuantity = i.value().get(); + pOutItemsArray->m_unQuantity = i->value("quantity", static_cast(0)); } catch (...) { @@ -183,7 +183,7 @@ bool Steam_Inventory::GetResultItems( SteamInventoryResult_t resultHandle, try { - pOutItemsArray->m_unQuantity = it->get(); + pOutItemsArray->m_unQuantity = it->value("quantity", static_cast(0)); } catch (...) { From afb848e427fe40d8c654ec70e3363abe9a065e7b Mon Sep 17 00:00:00 2001 From: a Date: Fri, 6 Dec 2024 23:09:13 +0200 Subject: [PATCH 03/10] properly implement `Steam_Remote_Storage::UpdateUserPublishedItemVote()` --- dll/steam_remote_storage.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/dll/steam_remote_storage.cpp b/dll/steam_remote_storage.cpp index b3dcb3c2..af374533 100644 --- a/dll/steam_remote_storage.cpp +++ b/dll/steam_remote_storage.cpp @@ -1030,12 +1030,14 @@ SteamAPICall_t Steam_Remote_Storage::UpdateUserPublishedItemVote( PublishedFileI RemoteStorageUpdateUserPublishedItemVoteResult_t data{}; data.m_nPublishedFileId = unPublishedFileId; if (settings->isModInstalled(unPublishedFileId)) { + data.m_eResult = EResult::k_EResultOK; auto mod = settings->getMod(unPublishedFileId); - if (mod.steamIDOwner == settings->get_local_steam_id().ConvertToUint64()) { - data.m_eResult = EResult::k_EResultOK; - } else { // not published by this user - data.m_eResult = EResult::k_EResultFail; // TODO is this correct? + if (bVoteUp) { + ++mod.votesUp; + } else { + ++mod.votesDown; } + settings->addModDetails(unPublishedFileId, mod); } else { // mod not installed data.m_eResult = EResult::k_EResultFail; // TODO is this correct? } From 574b8c411e732b18941012a22fa5d7bcec627e90 Mon Sep 17 00:00:00 2001 From: a Date: Fri, 6 Dec 2024 23:10:48 +0200 Subject: [PATCH 04/10] fix implementation of `Steam_Remote_Storage::GetUserPublishedItemVoteDetails()` --- dll/steam_remote_storage.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/dll/steam_remote_storage.cpp b/dll/steam_remote_storage.cpp index af374533..ad61f240 100644 --- a/dll/steam_remote_storage.cpp +++ b/dll/steam_remote_storage.cpp @@ -1060,15 +1060,11 @@ SteamAPICall_t Steam_Remote_Storage::GetUserPublishedItemVoteDetails( PublishedF data.m_unPublishedFileId = unPublishedFileId; if (settings->isModInstalled(unPublishedFileId)) { auto mod = settings->getMod(unPublishedFileId); - if (mod.steamIDOwner == settings->get_local_steam_id().ConvertToUint64()) { - data.m_eResult = EResult::k_EResultOK; - data.m_fScore = mod.score; - data.m_nReports = 0; // TODO is this ok? - data.m_nVotesAgainst = mod.votesDown; - data.m_nVotesFor = mod.votesUp; - } else { // not published by this user - data.m_eResult = EResult::k_EResultFail; // TODO is this correct? - } + data.m_eResult = EResult::k_EResultOK; + data.m_fScore = mod.score; + data.m_nReports = 0; // TODO is this ok? + data.m_nVotesAgainst = mod.votesDown; + data.m_nVotesFor = mod.votesUp; } else { // mod not installed data.m_eResult = EResult::k_EResultFail; // TODO is this correct? } From fa0041db0c32c4dd8f7432051bc620f60e93472f Mon Sep 17 00:00:00 2001 From: a Date: Fri, 6 Dec 2024 23:12:35 +0200 Subject: [PATCH 05/10] minor fix for `Steam_User_Stats::FindLeaderboard()` --- dll/steam_user_stats_leaderboard.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/dll/steam_user_stats_leaderboard.cpp b/dll/steam_user_stats_leaderboard.cpp index 3665e82e..e1a8d3e3 100644 --- a/dll/steam_user_stats_leaderboard.cpp +++ b/dll/steam_user_stats_leaderboard.cpp @@ -318,12 +318,11 @@ SteamAPICall_t Steam_User_Stats::FindLeaderboard( const char *pchLeaderboardName return ret; } - std::string name_lower(common_helpers::ascii_to_lowercase(pchLeaderboardName)); + std::string board_name(pchLeaderboardName); const auto &settings_Leaderboards = settings->getLeaderboards(); - auto it = settings_Leaderboards.begin(); - for (; settings_Leaderboards.end() != it; ++it) { - if (common_helpers::str_cmp_insensitive(it->first, name_lower)) break; - } + auto it = std::find_if(settings_Leaderboards.begin(), settings_Leaderboards.end(), [&board_name](const std::pair &item){ + return common_helpers::str_cmp_insensitive(item.first, board_name); + }); if (settings_Leaderboards.end() != it) { auto &config = it->second; return FindOrCreateLeaderboard(pchLeaderboardName, config.sort_method, config.display_type); @@ -331,7 +330,7 @@ SteamAPICall_t Steam_User_Stats::FindLeaderboard( const char *pchLeaderboardName return FindOrCreateLeaderboard(pchLeaderboardName, k_ELeaderboardSortMethodDescending, k_ELeaderboardDisplayTypeNumeric); } else { LeaderboardFindResult_t data{}; - data.m_hSteamLeaderboard = find_cached_leaderboard(name_lower); + data.m_hSteamLeaderboard = find_cached_leaderboard(board_name); data.m_bLeaderboardFound = !!data.m_hSteamLeaderboard; auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data)); callbacks->addCBResult(data.k_iCallback, &data, sizeof(data)); From c7ce32dad1a8c2cb3501f4a7786c67d8cd8ada77 Mon Sep 17 00:00:00 2001 From: a Date: Fri, 6 Dec 2024 23:15:07 +0200 Subject: [PATCH 06/10] fix implementation of `Steam_UGC::GetItemState()` --- dll/steam_ugc.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/dll/steam_ugc.cpp b/dll/steam_ugc.cpp index ea0bf7d1..b8ae61d6 100644 --- a/dll/steam_ugc.cpp +++ b/dll/steam_ugc.cpp @@ -1350,18 +1350,20 @@ uint32 Steam_UGC::GetItemState( PublishedFileId_t nPublishedFileID ) { PRINT_DEBUG("%llu", nPublishedFileID); std::lock_guard lock(global_mutex); - if (ugc_bridge->has_subbed_mod(nPublishedFileID)) { - if (settings->isModInstalled(nPublishedFileID)) { - PRINT_DEBUG(" mod is subscribed and installed"); - return k_EItemStateInstalled | k_EItemStateSubscribed; - } - - PRINT_DEBUG(" mod is subscribed"); - return k_EItemStateSubscribed; + + if (!settings->isModInstalled(nPublishedFileID)) { + PRINT_DEBUG(" mod isn't found"); + return k_EItemStateNone; } - PRINT_DEBUG(" mod isn't found"); - return k_EItemStateNone; + if (ugc_bridge->has_subbed_mod(nPublishedFileID)) { + PRINT_DEBUG(" mod is subscribed and installed"); + return k_EItemStateInstalled | k_EItemStateSubscribed; + } + + + PRINT_DEBUG(" mod is not subscribed"); + return k_EItemStateDisabledLocally; } From 9c976d730f4c72e62040cf78631cd5067e7f2cb5 Mon Sep 17 00:00:00 2001 From: a Date: Fri, 6 Dec 2024 23:17:00 +0200 Subject: [PATCH 07/10] missing shutdown in controller --- dll/steam_controller.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/dll/steam_controller.cpp b/dll/steam_controller.cpp index 5fbe5311..720637b1 100644 --- a/dll/steam_controller.cpp +++ b/dll/steam_controller.cpp @@ -231,6 +231,7 @@ Steam_Controller::~Steam_Controller() { //TODO rm network callbacks //TODO rumble thread + Shutdown(); this->run_every_runcb->remove(&Steam_Controller::steam_run_every_runcb, this); } From 05616b30dc61fd00cccce911091eddc7f1de77c0 Mon Sep 17 00:00:00 2001 From: a Date: Fri, 6 Dec 2024 23:17:59 +0200 Subject: [PATCH 08/10] missing objects destruction in steam_client + fix order --- dll/steam_client.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dll/steam_client.cpp b/dll/steam_client.cpp index fc336d45..ea77945c 100644 --- a/dll/steam_client.cpp +++ b/dll/steam_client.cpp @@ -163,7 +163,6 @@ Steam_Client::~Steam_Client() DEL_INST(background_thread); - DEL_INST(steam_gameserver); DEL_INST(steam_gameserver_utils); DEL_INST(steam_gameserverstats); DEL_INST(steam_gameserver_networking); @@ -176,6 +175,8 @@ Steam_Client::~Steam_Client() DEL_INST(steam_gameserver_networking_messages); DEL_INST(steam_gameserver_game_coordinator); DEL_INST(steam_masterserver_updater); + DEL_INST(steam_gameserver); + DEL_INST(steam_gameserver_gamestats); DEL_INST(steam_matchmaking); DEL_INST(steam_matchmaking_servers); @@ -212,6 +213,8 @@ Steam_Client::~Steam_Client() DEL_INST(steam_friends); DEL_INST(steam_user); DEL_INST(steam_overlay); + + DEL_INST(steam_app_ticket); DEL_INST(ugc_bridge); From 648faa9f79808897b141bb859c74b87a3384c7e4 Mon Sep 17 00:00:00 2001 From: a Date: Fri, 6 Dec 2024 23:04:51 +0200 Subject: [PATCH 09/10] minor changes + some debug messages amd comments --- dll/callsystem.cpp | 2 +- dll/dll.cpp | 15 ++++++++------- dll/dll/steam_client.h | 2 +- dll/dll/steam_ugc.h | 2 +- dll/steam_controller.cpp | 9 +++++---- dll/steam_matchmaking.cpp | 4 ++-- dll/steam_networking_messages.cpp | 2 +- dll/steam_networking_sockets.cpp | 2 +- dll/steam_remote_storage.cpp | 12 ++++++------ dll/steam_timeline.cpp | 3 ++- dll/steam_ugc.cpp | 12 ++++++------ dll/steam_user_stats_leaderboard.cpp | 4 +++- dll/steam_utils.cpp | 2 +- sdk/steam/isteamfriends.h | 2 +- sdk/steam/steam_api_flat.h | 2 ++ sdk/steam/steamclientpublic.h | 2 ++ sdk/steam/steamnetworkingtypes.h | 2 +- 17 files changed, 44 insertions(+), 35 deletions(-) diff --git a/dll/callsystem.cpp b/dll/callsystem.cpp index 83352509..d2ba8b22 100644 --- a/dll/callsystem.cpp +++ b/dll/callsystem.cpp @@ -277,7 +277,7 @@ void SteamCallResults::runCallResults() } } - PRINT_DEBUG("erase to_delete"); + // PRINT_DEBUG("erase to_delete"); auto c = std::begin(callresults); while (c != std::end(callresults)) { if (c->to_delete) { diff --git a/dll/dll.cpp b/dll/dll.cpp index 424716e3..85067006 100644 --- a/dll/dll.cpp +++ b/dll/dll.cpp @@ -491,7 +491,7 @@ STEAMAPI_API void S_CALLTYPE SteamAPI_SetMiniDumpComment( const char *pchMsg ) // and call SteamAPI_ReleaseCurrentThreadMemory regularly on other threads. STEAMAPI_API void S_CALLTYPE SteamAPI_RunCallbacks() { - PRINT_DEBUG_ENTRY(); + // PRINT_DEBUG_ENTRY(); get_steam_client()->RunCallbacks(true, false); //std::this_thread::sleep_for(std::chrono::microseconds(1)); //fixes resident evil revelations lagging. (Seems to work fine without this right now, commenting out) } @@ -575,7 +575,7 @@ STEAMAPI_API steam_bool S_CALLTYPE SteamAPI_IsSteamRunning() // NOT THREADSAFE - do not call from multiple threads simultaneously. STEAMAPI_API void Steam_RunCallbacks( HSteamPipe hSteamPipe, bool bGameServerCallbacks ) { - PRINT_DEBUG_ENTRY(); + // PRINT_DEBUG_ENTRY(); SteamAPI_RunCallbacks(); @@ -1007,7 +1007,7 @@ STEAMAPI_API void SteamGameServer_Shutdown() STEAMAPI_API void SteamGameServer_RunCallbacks() { - PRINT_DEBUG_ENTRY(); + // PRINT_DEBUG_ENTRY(); get_steam_client()->RunCallbacks(false, true); } @@ -1027,7 +1027,7 @@ STEAMAPI_API ISteamClient *SteamGameServerClient() { PRINT_DEBUG("old"); if (!get_steam_clientserver_old()->IsServerInit()) return NULL; - return (ISteamClient *)SteamInternal_CreateInterface(old_client); + return reinterpret_cast(SteamInternal_CreateInterface(old_client)); } STEAMAPI_API uint32 SteamGameServer_GetIPCCallCount() @@ -1133,7 +1133,7 @@ STEAMAPI_API steam_bool S_CALLTYPE SteamAPI_ManualDispatch_GetNextCallback( HSte } if (q->empty()) { - PRINT_DEBUG("error queue is empty"); + //PRINT_DEBUG("error queue is empty"); return false; } @@ -1321,13 +1321,13 @@ STEAMCLIENT_API steam_bool Steam_BGetCallback( HSteamPipe hSteamPipe, CallbackMs STEAMCLIENT_API void Steam_FreeLastCallback( HSteamPipe hSteamPipe ) { - PRINT_DEBUG("%i", hSteamPipe); + //PRINT_DEBUG("%i", hSteamPipe); SteamAPI_ManualDispatch_FreeLastCallback( hSteamPipe ); } STEAMCLIENT_API steam_bool Steam_GetAPICallResult( HSteamPipe hSteamPipe, SteamAPICall_t hSteamAPICall, void* pCallback, int cubCallback, int iCallbackExpected, bool* pbFailed ) { - PRINT_DEBUG("%i %llu %i %i", hSteamPipe, hSteamAPICall, cubCallback, iCallbackExpected); + //PRINT_DEBUG("%i %llu %i %i", hSteamPipe, hSteamAPICall, cubCallback, iCallbackExpected); return SteamAPI_ManualDispatch_GetAPICallResult(hSteamPipe, hSteamAPICall, pCallback, cubCallback, iCallbackExpected, pbFailed); } @@ -1351,6 +1351,7 @@ STEAMCLIENT_API void Breakpad_SteamMiniDumpInit( uint32 a, const char *b, const STEAMCLIENT_API void Breakpad_SteamSendMiniDump( void *a, uint32 b ) { PRINT_DEBUG_TODO(); + PRINT_DEBUG(" app is sending a crash dump! [XXXXXXXXXXXXXXXXXXXXXXXXXXX]"); } STEAMCLIENT_API void Breakpad_SteamSetAppID( uint32 unAppID ) diff --git a/dll/dll/steam_client.h b/dll/dll/steam_client.h index 93f53584..b3ac676c 100644 --- a/dll/dll/steam_client.h +++ b/dll/dll/steam_client.h @@ -245,7 +245,7 @@ public: // steam timeline ISteamTimeline *GetISteamTimeline( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ); - // steam appp disable update + // steam app disable update ISteamAppDisableUpdate *GetISteamAppDisableUpdate( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ); diff --git a/dll/dll/steam_ugc.h b/dll/dll/steam_ugc.h index 84da347f..dd335501 100644 --- a/dll/dll/steam_ugc.h +++ b/dll/dll/steam_ugc.h @@ -76,7 +76,7 @@ private: UGCQueryHandle_t new_ugc_query( bool return_all_subscribed = false, - std::set return_only = std::set()); + const std::set &return_only = std::set()); std::optional get_query_ugc(UGCQueryHandle_t handle, uint32 index); diff --git a/dll/steam_controller.cpp b/dll/steam_controller.cpp index 720637b1..27c15e81 100644 --- a/dll/steam_controller.cpp +++ b/dll/steam_controller.cpp @@ -221,7 +221,7 @@ Steam_Controller::Steam_Controller(class Settings *settings, class SteamCallResu this->run_every_runcb = run_every_runcb; set_handles(settings->controller_settings.action_sets); - disabled = !action_handles.size(); + disabled = action_handles.empty(); initialized = false; this->run_every_runcb->add(&Steam_Controller::steam_run_every_runcb, this); @@ -292,6 +292,7 @@ bool Steam_Controller::Shutdown() rumble_thread_data->rumble_thread_cv.notify_one(); background_rumble_thread.join(); delete rumble_thread_data; + rumble_thread_data = nullptr; GamepadShutdown(); initialized = false; return true; @@ -354,10 +355,10 @@ void Steam_Controller::EnableActionEventCallbacks( SteamInputActionEventCallback // possible latency, you call this directly before reading controller state. void Steam_Controller::RunFrame(bool bReservedValue) { - PRINT_DEBUG_ENTRY(); if (disabled || !initialized) { return; } + PRINT_DEBUG_ENTRY(); GamepadUpdate(); } @@ -574,7 +575,7 @@ int Steam_Controller::GetDigitalActionOrigins( ControllerHandle_t controllerHand EInputActionOrigin origins[STEAM_CONTROLLER_MAX_ORIGINS]; int ret = GetDigitalActionOrigins(controllerHandle, actionSetHandle, digitalActionHandle, origins ); for (int i = 0; i < ret; ++i) { - originsOut[i] = (EControllerActionOrigin)(origins[i] - (k_EInputActionOrigin_XBox360_A - k_EControllerActionOrigin_XBox360_A)); + originsOut[i] = (EControllerActionOrigin)(origins[i] - ((long)k_EInputActionOrigin_XBox360_A - (long)k_EControllerActionOrigin_XBox360_A)); } return ret; @@ -768,7 +769,7 @@ int Steam_Controller::GetAnalogActionOrigins( ControllerHandle_t controllerHandl EInputActionOrigin origins[STEAM_CONTROLLER_MAX_ORIGINS]; int ret = GetAnalogActionOrigins(controllerHandle, actionSetHandle, analogActionHandle, origins ); for (int i = 0; i < ret; ++i) { - originsOut[i] = (EControllerActionOrigin)(origins[i] - (k_EInputActionOrigin_XBox360_A - k_EControllerActionOrigin_XBox360_A)); + originsOut[i] = (EControllerActionOrigin)(origins[i] - ((long)k_EInputActionOrigin_XBox360_A - (long)k_EControllerActionOrigin_XBox360_A)); } return ret; diff --git a/dll/steam_matchmaking.cpp b/dll/steam_matchmaking.cpp index 45060f97..c2bc1080 100644 --- a/dll/steam_matchmaking.cpp +++ b/dll/steam_matchmaking.cpp @@ -129,7 +129,7 @@ bool Steam_Matchmaking::send_owner_packet(CSteamID lobby_id, Lobby_Messages *mes return false; } - Common_Message msg; + Common_Message msg{}; msg.set_allocated_lobby_messages(message); msg.set_source_id(settings->get_local_steam_id().ConvertToUint64()); msg.set_dest_id((uint64)lobby->owner()); @@ -1123,7 +1123,7 @@ int Steam_Matchmaking::GetLobbyMemberLimit( CSteamID steamIDLobby ) void Steam_Matchmaking::SetLobbyVoiceEnabled( CSteamID steamIDLobby, bool bVoiceEnabled ) { - PRINT_DEBUG_ENTRY(); + PRINT_DEBUG_TODO(); } // updates which type of lobby it is diff --git a/dll/steam_networking_messages.cpp b/dll/steam_networking_messages.cpp index 5b1885b4..1b89ee9b 100644 --- a/dll/steam_networking_messages.cpp +++ b/dll/steam_networking_messages.cpp @@ -247,7 +247,7 @@ int Steam_Networking_Messages::ReceiveMessagesOnChannel( int nLocalChannel, Stea } } - PRINT_DEBUG("got %u", message_counter); + PRINT_DEBUG("got %i", message_counter); return message_counter; } diff --git a/dll/steam_networking_sockets.cpp b/dll/steam_networking_sockets.cpp index c789968b..35e494dc 100644 --- a/dll/steam_networking_sockets.cpp +++ b/dll/steam_networking_sockets.cpp @@ -195,7 +195,7 @@ void Steam_Networking_Sockets::set_steamnetconnectioninfo(std::mapm_eState = convert_status(connect_socket->second.status); pInfo->m_eEndReason = 0; //TODO pInfo->m_szEndDebug[0] = 0; - sprintf(pInfo->m_szConnectionDescription, "%u", connect_socket->first); + snprintf(pInfo->m_szConnectionDescription, sizeof(pInfo->m_szConnectionDescription), "%u", connect_socket->first); //Note some games might not allocate a struct the whole size of SteamNetConnectionInfo_t when calling GetConnectionInfo //keep this in mind in future interface updates diff --git a/dll/steam_remote_storage.cpp b/dll/steam_remote_storage.cpp index ad61f240..8446e4c6 100644 --- a/dll/steam_remote_storage.cpp +++ b/dll/steam_remote_storage.cpp @@ -476,7 +476,7 @@ SteamAPICall_t Steam_Remote_Storage::UGCDownload( UGCHandle_t hContent ) // or if the transfer hasn't started yet, so be careful to check for that before dividing to get a percentage bool Steam_Remote_Storage::GetUGCDownloadProgress( UGCHandle_t hContent, int32 *pnBytesDownloaded, int32 *pnBytesExpected ) { - PRINT_DEBUG_ENTRY(); + PRINT_DEBUG_TODO(); std::lock_guard lock(global_mutex); return false; @@ -484,7 +484,7 @@ bool Steam_Remote_Storage::GetUGCDownloadProgress( UGCHandle_t hContent, int32 * bool Steam_Remote_Storage::GetUGCDownloadProgress( UGCHandle_t hContent, uint32 *pnBytesDownloaded, uint32 *pnBytesExpected ) { - PRINT_DEBUG("old"); + PRINT_DEBUG_TODO(); std::lock_guard lock(global_mutex); return false; @@ -1206,7 +1206,7 @@ SteamAPICall_t Steam_Remote_Storage::UGCDownloadToLocation( UGCHandle_t hContent // Cloud dynamic state change notification int32 Steam_Remote_Storage::GetLocalFileChangeCount() { - PRINT_DEBUG("GetLocalFileChangeCount"); + PRINT_DEBUG_TODO(); std::lock_guard lock(global_mutex); return 0; @@ -1214,7 +1214,7 @@ int32 Steam_Remote_Storage::GetLocalFileChangeCount() const char* Steam_Remote_Storage::GetLocalFileChange( int iFile, ERemoteStorageLocalFileChange *pEChangeType, ERemoteStorageFilePathType *pEFilePathType ) { - PRINT_DEBUG("GetLocalFileChange"); + PRINT_DEBUG_TODO(); std::lock_guard lock(global_mutex); return ""; @@ -1224,7 +1224,7 @@ const char* Steam_Remote_Storage::GetLocalFileChange( int iFile, ERemoteStorageL // operations - for example, writing a game save that requires updating two files. bool Steam_Remote_Storage::BeginFileWriteBatch() { - PRINT_DEBUG("BeginFileWriteBatch"); + PRINT_DEBUG_ENTRY(); std::lock_guard lock(global_mutex); return true; @@ -1232,7 +1232,7 @@ bool Steam_Remote_Storage::BeginFileWriteBatch() bool Steam_Remote_Storage::EndFileWriteBatch() { - PRINT_DEBUG("EndFileWriteBatch"); + PRINT_DEBUG_ENTRY(); std::lock_guard lock(global_mutex); return true; diff --git a/dll/steam_timeline.cpp b/dll/steam_timeline.cpp index 0a2fb54c..71b8a060 100644 --- a/dll/steam_timeline.cpp +++ b/dll/steam_timeline.cpp @@ -68,6 +68,7 @@ Steam_Timeline::Steam_Timeline(class Settings *settings, class Networking *netwo this->run_every_runcb->add(&Steam_Timeline::steam_run_every_runcb, this); // timeline starts with a default event as seen here: https://www.youtube.com/watch?v=YwBD0E4-EsI + PRINT_DEBUG("adding an initial game mode"); SetTimelineGameMode(ETimelineGameMode::k_ETimelineGameMode_Invalid); } @@ -166,7 +167,7 @@ TimelineEventHandle_t Steam_Timeline::AddRangeTimelineEvent( const char *pchTitl std::lock_guard lock(timeline_mutex); auto event_id = StartRangeTimelineEvent(pchTitle, pchDescription, pchIcon, unIconPriority, flStartOffsetSeconds, ePossibleClip); - if (!event_id || event_id > timeline_events.size()) return event_id; + if (!event_id || event_id > timeline_events.size()) return 0; auto& my_event = timeline_events[static_cast(event_id - 1)]; my_event.ended = true; // ranged and instantaneous events are ended/closed events, they can't be modified later according to docs diff --git a/dll/steam_ugc.cpp b/dll/steam_ugc.cpp index b8ae61d6..75e8cb2f 100644 --- a/dll/steam_ugc.cpp +++ b/dll/steam_ugc.cpp @@ -17,7 +17,7 @@ #include "dll/steam_ugc.h" -UGCQueryHandle_t Steam_UGC::new_ugc_query(bool return_all_subscribed, std::set return_only) +UGCQueryHandle_t Steam_UGC::new_ugc_query(bool return_all_subscribed, const std::set &return_only) { std::lock_guard lock(global_mutex); @@ -29,7 +29,7 @@ UGCQueryHandle_t Steam_UGC::new_ugc_query(bool return_all_subscribed, std::set

lock(global_mutex); - RemoteStorageSubscribePublishedFileResult_t data; + RemoteStorageSubscribePublishedFileResult_t data{}; data.m_nPublishedFileId = nPublishedFileID; if (settings->isModInstalled(nPublishedFileID)) { data.m_eResult = k_EResultOK; @@ -1307,7 +1307,7 @@ SteamAPICall_t Steam_UGC::UnsubscribeItem( PublishedFileId_t nPublishedFileID ) PRINT_DEBUG("%llu", nPublishedFileID); std::lock_guard lock(global_mutex); - RemoteStorageUnsubscribePublishedFileResult_t data; + RemoteStorageUnsubscribePublishedFileResult_t data{}; data.m_nPublishedFileId = nPublishedFileID; if (!ugc_bridge->has_subbed_mod(nPublishedFileID)) { data.m_eResult = k_EResultFail; //TODO: check if this is accurate @@ -1461,7 +1461,7 @@ bool Steam_UGC::BInitWorkshopForGameServer( DepotId_t unWorkshopDepotID, const c // SuspendDownloads( true ) will suspend all workshop downloads until SuspendDownloads( false ) is called or the game ends void Steam_UGC::SuspendDownloads( bool bSuspend ) { - PRINT_DEBUG_ENTRY(); + PRINT_DEBUG_TODO(); std::lock_guard lock(global_mutex); } diff --git a/dll/steam_user_stats_leaderboard.cpp b/dll/steam_user_stats_leaderboard.cpp index e1a8d3e3..860a1cee 100644 --- a/dll/steam_user_stats_leaderboard.cpp +++ b/dll/steam_user_stats_leaderboard.cpp @@ -346,7 +346,9 @@ const char * Steam_User_Stats::GetLeaderboardName( SteamLeaderboard_t hSteamLead std::lock_guard lock(global_mutex); if (hSteamLeaderboard > cached_leaderboards.size() || hSteamLeaderboard <= 0) return ""; - return cached_leaderboards[static_cast(hSteamLeaderboard - 1)].name.c_str(); + auto name_ptr = cached_leaderboards[static_cast(hSteamLeaderboard - 1)].name.c_str(); + PRINT_DEBUG(" returned '%s'", name_ptr); + return name_ptr; } diff --git a/dll/steam_utils.cpp b/dll/steam_utils.cpp index f4395135..3f43559d 100644 --- a/dll/steam_utils.cpp +++ b/dll/steam_utils.cpp @@ -184,7 +184,7 @@ bool Steam_Utils::GetAPICallResult( SteamAPICall_t hSteamAPICall, void *pCallbac STEAM_PRIVATE_API( void Steam_Utils::RunFrame() { - PRINT_DEBUG_TODO(); + //PRINT_DEBUG_TODO(); std::lock_guard lock(global_mutex); // Steam_Client *client = get_steam_client(); // client ->RunCallbacks(true, false, false); diff --git a/sdk/steam/isteamfriends.h b/sdk/steam/isteamfriends.h index 48b313dc..192b95b5 100644 --- a/sdk/steam/isteamfriends.h +++ b/sdk/steam/isteamfriends.h @@ -765,7 +765,7 @@ struct EquippedProfileItems_t bool m_bHasProfileModifier; bool m_bHasProfileBackground; bool m_bHasMiniProfileBackground; - bool m_bFromCache; + bool m_bFromCache; // added in sdk v1.61 }; #pragma pack( pop ) diff --git a/sdk/steam/steam_api_flat.h b/sdk/steam/steam_api_flat.h index 1928e272..348e328c 100644 --- a/sdk/steam/steam_api_flat.h +++ b/sdk/steam/steam_api_flat.h @@ -1213,7 +1213,9 @@ STEAMAPI_API steam_bool SteamAPI_SteamNetworkingIdentity_SetXboxPairwiseID( Stea STEAMAPI_API const char * SteamAPI_SteamNetworkingIdentity_GetXboxPairwiseID( SteamNetworkingIdentity* self ); STEAMAPI_API void SteamAPI_SteamNetworkingIdentity_SetPSNID( SteamNetworkingIdentity* self, uint64 id ); STEAMAPI_API uint64 SteamAPI_SteamNetworkingIdentity_GetPSNID( SteamNetworkingIdentity* self ); +// removed since SDK v1.61 STEAMAPI_API void SteamAPI_SteamNetworkingIdentity_SetStadiaID( SteamNetworkingIdentity* self, uint64 id ); +// removed since SDK v1.61 STEAMAPI_API uint64 SteamAPI_SteamNetworkingIdentity_GetStadiaID( SteamNetworkingIdentity* self ); STEAMAPI_API void SteamAPI_SteamNetworkingIdentity_SetIPAddr( SteamNetworkingIdentity* self, const SteamNetworkingIPAddr & addr ); STEAMAPI_API const SteamNetworkingIPAddr * SteamAPI_SteamNetworkingIdentity_GetIPAddr( SteamNetworkingIdentity* self ); diff --git a/sdk/steam/steamclientpublic.h b/sdk/steam/steamclientpublic.h index 8a302b34..988ac6ce 100644 --- a/sdk/steam/steamclientpublic.h +++ b/sdk/steam/steamclientpublic.h @@ -1088,6 +1088,8 @@ public: // and is preferred when the caller knows it's safe to be strict. // Returns whether the string parsed correctly. bool SetFromStringStrict( const char *pchSteamID, EUniverse eDefaultUniverse ); + + // removed in sdk 1.61 bool SetFromSteam2String( const char *pchSteam2ID, EUniverse eUniverse ); inline bool operator==( const CSteamID &val ) const { return m_steamid.m_unAll64Bits == val.m_steamid.m_unAll64Bits; } diff --git a/sdk/steam/steamnetworkingtypes.h b/sdk/steam/steamnetworkingtypes.h index 8f60221b..a1d9f53b 100644 --- a/sdk/steam/steamnetworkingtypes.h +++ b/sdk/steam/steamnetworkingtypes.h @@ -341,7 +341,7 @@ struct SteamNetworkingIdentity union { uint64 m_steamID64; uint64 m_PSNID; - uint64 m_stadiaID; + uint64 m_stadiaID; // removed in sdk v1.61 char m_szGenericString[ k_cchMaxGenericString ]; char m_szXboxPairwiseID[ k_cchMaxXboxPairwiseID ]; uint8 m_genericBytes[ k_cbMaxGenericBytes ]; From 49a9cfa37573bb00ae449c1831620ade356368fd Mon Sep 17 00:00:00 2001 From: a Date: Fri, 6 Dec 2024 23:19:58 +0200 Subject: [PATCH 10/10] remove duplicate helper --- dll/settings.cpp | 2 +- dll/steam_user_stats.cpp | 2 +- dll/steam_user_stats_leaderboard.cpp | 5 +++-- dll/steam_user_stats_stats.cpp | 14 +++++++------- helpers/common_helpers.cpp | 6 ------ helpers/common_helpers/common_helpers.hpp | 2 -- 6 files changed, 12 insertions(+), 19 deletions(-) diff --git a/dll/settings.cpp b/dll/settings.cpp index 6a6d6609..eb19297f 100644 --- a/dll/settings.cpp +++ b/dll/settings.cpp @@ -354,7 +354,7 @@ const std::map& Settings::getStats() const std::map::const_iterator Settings::setStatDefiniton(const std::string &name, const struct Stat_config &stat_config) { - auto ins_it = stats.insert_or_assign(common_helpers::ascii_to_lowercase(name), stat_config); + auto ins_it = stats.insert_or_assign(common_helpers::to_lower(name), stat_config); return ins_it.first; } diff --git a/dll/steam_user_stats.cpp b/dll/steam_user_stats.cpp index c804b087..b7905fa1 100644 --- a/dll/steam_user_stats.cpp +++ b/dll/steam_user_stats.cpp @@ -69,7 +69,7 @@ Steam_User_Stats::Steam_User_Stats(Settings *settings, class Networking *network try { trig.name = name; trig.value_operation = static_cast(it["progress"]["value"]["operation"]); - std::string stat_name = common_helpers::ascii_to_lowercase(static_cast(it["progress"]["value"]["operand1"])); + std::string stat_name = common_helpers::to_lower(static_cast(it["progress"]["value"]["operand1"])); trig.min_value = static_cast(it["progress"]["min_val"]); trig.max_value = static_cast(it["progress"]["max_val"]); achievement_stat_trigger[stat_name].push_back(trig); diff --git a/dll/steam_user_stats_leaderboard.cpp b/dll/steam_user_stats_leaderboard.cpp index 860a1cee..6a812915 100644 --- a/dll/steam_user_stats_leaderboard.cpp +++ b/dll/steam_user_stats_leaderboard.cpp @@ -81,7 +81,7 @@ std::vector Steam_User_Stats::load_leaderboard_entries( std::vector out{}; - std::string leaderboard_name(common_helpers::ascii_to_lowercase(name)); + std::string leaderboard_name(common_helpers::to_lower(name)); unsigned read_bytes = local_storage->file_size(Local_Storage::leaderboard_storage_folder, leaderboard_name); if ((read_bytes == 0) || (read_bytes < (ELEMENT_SIZE * MAIN_HEADER_ELEMENTS_COUNT)) || @@ -138,7 +138,7 @@ void Steam_User_Stats::save_my_leaderboard_entry(const Steam_Leaderboard &leader output.push_back(detail); } - std::string leaderboard_name(common_helpers::ascii_to_lowercase(leaderboard.name)); + std::string leaderboard_name(common_helpers::to_lower(leaderboard.name)); unsigned int buffer_size = static_cast(output.size() * sizeof(output[0])); // in bytes local_storage->store_data(Local_Storage::leaderboard_storage_folder, leaderboard_name, (char* )&output[0], buffer_size); } @@ -186,6 +186,7 @@ unsigned int Steam_User_Stats::cache_leaderboard_ifneeded(const std::string &nam // create a new entry in-memory and try reading the entries from disk struct Steam_Leaderboard new_board{}; + // don't make this lower/upper case, appid 1372280 later calls GetLeaderboardName() and hangs if the name wasn't the same as the original new_board.name = name; new_board.sort_method = eLeaderboardSortMethod; new_board.display_type = eLeaderboardDisplayType; diff --git a/dll/steam_user_stats_stats.cpp b/dll/steam_user_stats_stats.cpp index 6b8a20a0..7b892cef 100644 --- a/dll/steam_user_stats_stats.cpp +++ b/dll/steam_user_stats_stats.cpp @@ -28,7 +28,7 @@ bool Steam_User_Stats::clear_stats_internal() bool notify_server = false; for (const auto &stat : settings->getStats()) { - std::string stat_name(common_helpers::ascii_to_lowercase(stat.first)); + std::string stat_name(common_helpers::to_lower(stat.first)); switch (stat.second.type) { @@ -79,7 +79,7 @@ Steam_User_Stats::InternalSetResult Steam_User_Stats::set_stat_internal( Steam_User_Stats::InternalSetResult result{}; if (!pchName) return result; - std::string stat_name(common_helpers::ascii_to_lowercase(pchName)); + std::string stat_name(common_helpers::to_lower(pchName)); const auto &stats_config = settings->getStats(); auto stats_data = stats_config.find(stat_name); @@ -152,7 +152,7 @@ Steam_User_Stats::InternalSetResult> result{}; if (!pchName) return result; - std::string stat_name(common_helpers::ascii_to_lowercase(pchName)); + std::string stat_name(common_helpers::to_lower(pchName)); const auto &stats_config = settings->getStats(); auto stats_data = stats_config.find(stat_name); @@ -226,7 +226,7 @@ Steam_User_Stats::InternalSetResult> result{}; if (!pchName) return result; - std::string stat_name(common_helpers::ascii_to_lowercase(pchName)); + std::string stat_name(common_helpers::to_lower(pchName)); const auto &stats_config = settings->getStats(); auto stats_data = stats_config.find(stat_name); @@ -305,7 +305,7 @@ bool Steam_User_Stats::GetStat( const char *pchName, int32 *pData ) std::lock_guard lock(global_mutex); if (!pchName) return false; - std::string stat_name = common_helpers::ascii_to_lowercase(pchName); + std::string stat_name = common_helpers::to_lower(pchName); const auto &stats_config = settings->getStats(); auto stats_data = stats_config.find(stat_name); @@ -344,7 +344,7 @@ bool Steam_User_Stats::GetStat( const char *pchName, float *pData ) std::lock_guard lock(global_mutex); if (!pchName) return false; - std::string stat_name = common_helpers::ascii_to_lowercase(pchName); + std::string stat_name = common_helpers::to_lower(pchName); const auto &stats_config = settings->getStats(); auto stats_data = stats_config.find(stat_name); @@ -531,7 +531,7 @@ bool Steam_User_Stats::ResetAllStats( bool bAchievementsToo ) clear_stats_internal(); // this will save stats to disk if necessary if (!settings->disable_sharing_stats_with_gameserver) { for (const auto &stat : settings->getStats()) { - std::string stat_name(common_helpers::ascii_to_lowercase(stat.first)); + std::string stat_name(common_helpers::to_lower(stat.first)); auto &new_stat = (*pending_server_updates.mutable_user_stats())[stat_name]; new_stat.set_stat_type(stat.second.type); diff --git a/helpers/common_helpers.cpp b/helpers/common_helpers.cpp index f040fde0..f7e36f77 100644 --- a/helpers/common_helpers.cpp +++ b/helpers/common_helpers.cpp @@ -225,12 +225,6 @@ bool common_helpers::str_cmp_insensitive(std::wstring_view str1, std::wstring_vi }); } -std::string common_helpers::ascii_to_lowercase(std::string data) { - std::transform(data.begin(), data.end(), data.begin(), - [](char c){ return std::tolower(c); }); - return data; -} - void common_helpers::thisThreadYieldFor(std::chrono::microseconds u) { const auto start = std::chrono::high_resolution_clock::now(); diff --git a/helpers/common_helpers/common_helpers.hpp b/helpers/common_helpers/common_helpers.hpp index 7d6707a0..0f3b11eb 100644 --- a/helpers/common_helpers/common_helpers.hpp +++ b/helpers/common_helpers/common_helpers.hpp @@ -71,8 +71,6 @@ std::string uint8_vector_to_hex_string(const std::vector &v); bool str_cmp_insensitive(std::string_view str1, std::string_view str2); bool str_cmp_insensitive(std::wstring_view str1, std::wstring_view str2); -std::string ascii_to_lowercase(std::string data); - void thisThreadYieldFor(std::chrono::microseconds u); void consume_bom(std::ifstream &input);