Skip to content

Commit

Permalink
Merge pull request Detanup01#77 from otavepto/patch-SendQueryUGCReque…
Browse files Browse the repository at this point in the history
…st-failure

trigger callback + call-result for failure in `SendQueryUGCRequest()`
  • Loading branch information
Detanup01 authored Nov 4, 2024
2 parents 7936cd6 + 266c4ef commit 6792e9a
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions dll/steam_ugc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,24 @@ SteamAPICall_t Steam_UGC::SendQueryUGCRequest( UGCQueryHandle_t handle )
{
PRINT_DEBUG("%llu", handle);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (handle == k_UGCQueryHandleInvalid) return k_uAPICallInvalid;

const auto trigger_failure = [handle, this](){
SteamUGCQueryCompleted_t data{};
data.m_handle = handle;
data.m_eResult = k_EResultFail;
data.m_unNumResultsReturned = 0;
data.m_unTotalMatchingResults = 0;
data.m_bCachedData = false;

auto ret = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
return ret;
};

if (handle == k_UGCQueryHandleInvalid) return trigger_failure();

auto request = std::find_if(ugc_queries.begin(), ugc_queries.end(), [&handle](struct UGC_query const& item) { return item.handle == handle; });
if (ugc_queries.end() == request)
return k_uAPICallInvalid;
if (ugc_queries.end() == request) return trigger_failure();

if (request->return_all_subscribed) {
request->results = std::set<PublishedFileId_t>(ugc_bridge->subbed_mods_itr_begin(), ugc_bridge->subbed_mods_itr_end());
Expand Down

0 comments on commit 6792e9a

Please sign in to comment.