From 455d5f479a025f72a1b52f8c5a1c258972957da7 Mon Sep 17 00:00:00 2001 From: a Date: Fri, 6 Dec 2024 23:07:19 +0200 Subject: [PATCH 1/5] implement `Steam_Apps::GetAppData()` --- dll/steam_apps.cpp | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/dll/steam_apps.cpp b/dll/steam_apps.cpp index 02ad3956..5ad0b226 100644 --- a/dll/steam_apps.cpp +++ b/dll/steam_apps.cpp @@ -30,8 +30,32 @@ Steam_Apps::Steam_Apps(Settings *settings, class SteamCallResults *callback_resu // If you expect it to exists wait for the AppDataChanged_t after the first failure and ask again int Steam_Apps::GetAppData( AppId_t nAppID, const char *pchKey, char *pchValue, int cchValueMax ) { - //TODO - PRINT_DEBUG_TODO(); + PRINT_DEBUG("%u, %p = ['%s'] (%i)", nAppID, pchValue, pchKey, cchValueMax); + std::lock_guard lock(global_mutex); + + if (common_helpers::str_cmp_insensitive("subscribed", pchKey)) { + bool val = BIsSubscribedApp(nAppID); + if (pchValue && cchValueMax >= 2) { + strncpy(pchValue, val ? "1" : "0", 2); + } + return 2; + } else if (common_helpers::str_cmp_insensitive("installed", pchKey)) { + bool val = BIsAppInstalled(nAppID); + if (pchValue && cchValueMax >= 2) { + strncpy(pchValue, val ? "1" : "0", 2); + } + return 2; + } else if (common_helpers::str_cmp_insensitive("country", pchKey)) { + // TODO this is not exactly how real client does it, but close enough + auto lang = GetCurrentGameLanguage(); + auto lang_lower = common_helpers::to_lower(lang && lang[0] ? lang : "--"); // "--" is an actual value the client returns + if (pchValue && cchValueMax >= 3) { + strncpy(pchValue, lang_lower.c_str(), 3); + pchValue[2] = 0; + } + return 3; + } + return 0; } From 907be7ee4548fe1398971689ca9320b02e2c649b Mon Sep 17 00:00:00 2001 From: a Date: Fri, 6 Dec 2024 23:15:36 +0200 Subject: [PATCH 2/5] implement `Steam_UGC::GetWorkshopEULAStatus()` --- dll/steam_ugc.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dll/steam_ugc.cpp b/dll/steam_ugc.cpp index 66ce3274..2e2db131 100644 --- a/dll/steam_ugc.cpp +++ b/dll/steam_ugc.cpp @@ -1592,8 +1592,17 @@ SteamAPICall_t Steam_UGC::GetWorkshopEULAStatus() { PRINT_DEBUG_TODO(); std::lock_guard lock(global_mutex); + WorkshopEULAStatus_t data{}; + data.m_eResult = k_EResultOK; + data.m_nAppID = settings->get_local_game_id().AppID(); + data.m_unVersion = 0; // TODO + data.m_rtAction = (RTime32)std::chrono::duration_cast(startup_time.time_since_epoch()).count(); + data.m_bAccepted = true; + data.m_bNeedsAction = false; - return k_uAPICallInvalid; + auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data)); + callbacks->addCBResult(data.k_iCallback, &data, sizeof(data)); + return ret; } // Return the user's community content descriptor preferences From bf275a79f16adf788272221a2fb8f5ab8acf72e9 Mon Sep 17 00:00:00 2001 From: a Date: Fri, 6 Dec 2024 23:16:10 +0200 Subject: [PATCH 3/5] basic implementation for `Steam_UGC::DownloadItem()` --- dll/steam_ugc.cpp | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/dll/steam_ugc.cpp b/dll/steam_ugc.cpp index 2e2db131..10f83925 100644 --- a/dll/steam_ugc.cpp +++ b/dll/steam_ugc.cpp @@ -1436,10 +1436,37 @@ bool Steam_UGC::GetItemInstallInfo( PublishedFileId_t nPublishedFileID, uint64 * // If bHighPriority is set, any other item download will be suspended and this item downloaded ASAP. bool Steam_UGC::DownloadItem( PublishedFileId_t nPublishedFileID, bool bHighPriority ) { - PRINT_DEBUG_ENTRY(); + PRINT_DEBUG("%llu %i // TODO", nPublishedFileID, (int)bHighPriority); std::lock_guard lock(global_mutex); + + if (!settings->isModInstalled(nPublishedFileID)) { + DownloadItemResult_t data_fail{}; + data_fail.m_eResult = EResult::k_EResultFail; + data_fail.m_nPublishedFileId = nPublishedFileID; + data_fail.m_unAppID = settings->get_local_game_id().AppID(); + callbacks->addCBResult(data_fail.k_iCallback, &data_fail, sizeof(data_fail), 0.050); + return false; + } - return false; + { + DownloadItemResult_t data{}; + data.m_eResult = EResult::k_EResultOK; + data.m_nPublishedFileId = nPublishedFileID; + data.m_unAppID = settings->get_local_game_id().AppID(); + callbacks->addCBResult(data.k_iCallback, &data, sizeof(data), 0.1); + } + + { + ItemInstalled_t data{}; + data.m_hLegacyContent = nPublishedFileID; + data.m_nPublishedFileId = nPublishedFileID; + data.m_unAppID = settings->get_local_game_id().AppID(); + data.m_unManifestID = 123; // TODO + callbacks->addCBResult(data.k_iCallback, &data, sizeof(data), 0.15); + } + + PRINT_DEBUG("downloaded!"); + return true; } From 0e0df256c5763993aea53c3113b8c6cb414f3a9b Mon Sep 17 00:00:00 2001 From: a Date: Fri, 6 Dec 2024 23:06:48 +0200 Subject: [PATCH 4/5] respect logon setting in client function `Steam_BLoggedOn()` --- dll/dll.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/dll/dll.cpp b/dll/dll.cpp index 424716e3..a57cf0b9 100644 --- a/dll/dll.cpp +++ b/dll/dll.cpp @@ -1383,8 +1383,24 @@ STEAMCLIENT_API steam_bool Steam_BConnected( HSteamUser hUser, HSteamPipe hSteam STEAMCLIENT_API steam_bool Steam_BLoggedOn( HSteamUser hUser, HSteamPipe hSteamPipe ) { - PRINT_DEBUG_ENTRY(); - return true; + PRINT_DEBUG("%i %i", hUser, hSteamPipe); + Steam_Client *steam_client = get_steam_client(); + + auto pipe_it = steam_client->steam_pipes.find(hSteamPipe); + if (steam_client->steam_pipes.end() == pipe_it) { + return false; + } + + class Settings *settings_tmp{}; + if (pipe_it->second == Steam_Pipe::SERVER) { + settings_tmp = steam_client->settings_server; + } else if (pipe_it->second == Steam_Pipe::CLIENT) { + settings_tmp = steam_client->settings_client; + } else { + return false; + } + + return !settings_tmp->is_offline(); } STEAMCLIENT_API steam_bool Steam_BReleaseSteamPipe( HSteamPipe hSteamPipe ) From b9d50520e448e030bef61c8de316f330e1db7010 Mon Sep 17 00:00:00 2001 From: a Date: Sat, 7 Dec 2024 06:35:13 +0200 Subject: [PATCH 5/5] fix country in `Steam_Apps::GetAppData()` --- dll/steam_apps.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dll/steam_apps.cpp b/dll/steam_apps.cpp index 5ad0b226..a13752cf 100644 --- a/dll/steam_apps.cpp +++ b/dll/steam_apps.cpp @@ -47,10 +47,10 @@ int Steam_Apps::GetAppData( AppId_t nAppID, const char *pchKey, char *pchValue, return 2; } else if (common_helpers::str_cmp_insensitive("country", pchKey)) { // TODO this is not exactly how real client does it, but close enough - auto lang = GetCurrentGameLanguage(); - auto lang_lower = common_helpers::to_lower(lang && lang[0] ? lang : "--"); // "--" is an actual value the client returns + auto country = settings->ip_country.c_str(); + auto country_lower = common_helpers::to_lower(country && country[0] ? country : "--"); // "--" is an actual value the client returns if (pchValue && cchValueMax >= 3) { - strncpy(pchValue, lang_lower.c_str(), 3); + strncpy(pchValue, country_lower.c_str(), 3); pchValue[2] = 0; } return 3;