diff --git a/dll/dll.cpp b/dll/dll.cpp index 05e7cb1e..e8ed43c3 100644 --- a/dll/dll.cpp +++ b/dll/dll.cpp @@ -1384,8 +1384,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 ) diff --git a/dll/steam_apps.cpp b/dll/steam_apps.cpp index 02ad3956..a13752cf 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 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, country_lower.c_str(), 3); + pchValue[2] = 0; + } + return 3; + } + return 0; } diff --git a/dll/steam_ugc.cpp b/dll/steam_ugc.cpp index 75e8cb2f..4279bdb4 100644 --- a/dll/steam_ugc.cpp +++ b/dll/steam_ugc.cpp @@ -1440,10 +1440,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; } @@ -1596,8 +1623,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