From 3d14bbcb4e879cdbb67c4293823d7fdbc67cc4db Mon Sep 17 00:00:00 2001 From: Edremon <106028744+Edremon@users.noreply.github.com.> Date: Tue, 26 Nov 2024 01:36:10 +0000 Subject: [PATCH] Implement GetUGCDetails Co-authored-by: a --- dll/steam_remote_storage.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/dll/steam_remote_storage.cpp b/dll/steam_remote_storage.cpp index 7ab28fbf..08ed2758 100644 --- a/dll/steam_remote_storage.cpp +++ b/dll/steam_remote_storage.cpp @@ -495,8 +495,33 @@ bool Steam_Remote_Storage::GetUGCDownloadProgress( UGCHandle_t hContent, uint32 // Gets metadata for a file after it has been downloaded. This is the same metadata given in the RemoteStorageDownloadUGCResult_t call result bool Steam_Remote_Storage::GetUGCDetails( UGCHandle_t hContent, AppId_t *pnAppID, STEAM_OUT_STRING() char **ppchName, int32 *pnFileSizeInBytes, STEAM_OUT_STRUCT() CSteamID *pSteamIDOwner ) { - PRINT_DEBUG_ENTRY(); + PRINT_DEBUG("%llu", hContent); std::lock_guard lock(global_mutex); + if (hContent == k_UGCHandleInvalid) return false; + + if (pnAppID) *pnAppID = settings->get_local_game_id().AppID(); + if (pSteamIDOwner) *pSteamIDOwner = k_steamIDNil; + if (pnFileSizeInBytes) *pnFileSizeInBytes = 0; + if (ppchName) *ppchName = nullptr; + + if (auto query_res = ugc_bridge->get_ugc_query_result(hContent)) { + auto mod = settings->getMod(query_res.value().mod_id); + auto &mod_name = query_res.value().is_primary_file + ? mod.primaryFileName + : mod.previewFileName; + int32 mod_size = query_res.value().is_primary_file + ? mod.primaryFileSize + : mod.previewFileSize; + + if (ppchName) { + *ppchName = new char[mod_name.size() + 1]; + std::strcpy(*ppchName, mod_name.c_str()); + } + if (pnFileSizeInBytes) *pnFileSizeInBytes = mod_size; + if (pSteamIDOwner) *pSteamIDOwner = mod.steamIDOwner; + + return true; + } return false; }