Skip to content

Commit

Permalink
Merge pull request #114 from otavepto/patch-implement-functions
Browse files Browse the repository at this point in the history
implement some functions
  • Loading branch information
Detanup01 authored Dec 7, 2024
2 parents 62fb59a + b9d5052 commit e02cc9b
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 7 deletions.
20 changes: 18 additions & 2 deletions dll/dll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
28 changes: 26 additions & 2 deletions dll/steam_apps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
42 changes: 39 additions & 3 deletions dll/steam_ugc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::recursive_mutex> 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;
}


Expand Down Expand Up @@ -1596,8 +1623,17 @@ SteamAPICall_t Steam_UGC::GetWorkshopEULAStatus()
{
PRINT_DEBUG_TODO();
std::lock_guard<std::recursive_mutex> 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<std::chrono::seconds>(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
Expand Down

0 comments on commit e02cc9b

Please sign in to comment.