mirror of
https://github.com/acidicoala/SmokeAPI.git
synced 2025-12-06 05:25:43 -05:00
Implemented ISteamGameServer
This commit is contained in:
@@ -32,7 +32,7 @@ namespace smoke_api::api {
|
||||
|
||||
std::optional<std::vector<DLC>> fetch_dlcs_from_steam(const AppId_t app_id) {
|
||||
try {
|
||||
// TODO: Communicate directly with Steam servers.
|
||||
// TODO: Communicate directly with Steam servers?
|
||||
// ref.: https://github.com/SteamRE/SteamKit
|
||||
const auto url =
|
||||
std::format("https://store.steampowered.com/dlc/{}/ajaxgetdlclist", app_id);
|
||||
|
||||
@@ -32,6 +32,9 @@ namespace smoke_api::cache {
|
||||
}
|
||||
|
||||
bool save_dlcs(AppId_t app_id, const std::vector<DLC>& dlcs) noexcept {
|
||||
static std::mutex section;
|
||||
const std::lock_guard lock(section);
|
||||
|
||||
try {
|
||||
LOG_DEBUG("Caching DLC IDs for the app: {}", app_id);
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include <koalabox/config.hpp>
|
||||
#include <koalabox/io.hpp>
|
||||
#include <koalabox/logger.hpp>
|
||||
#include <koalabox/util.hpp>
|
||||
|
||||
#include "smoke_api/config.hpp"
|
||||
|
||||
@@ -40,6 +39,7 @@ namespace smoke_api::config {
|
||||
break;
|
||||
case AppStatus::ORIGINAL:
|
||||
case AppStatus::UNDEFINED:
|
||||
default:
|
||||
is_unlocked = original_function();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -14,10 +14,10 @@ namespace smoke_api::config {
|
||||
AppStatus,
|
||||
// @formatter:off
|
||||
{
|
||||
{AppStatus::UNDEFINED, nullptr},
|
||||
{AppStatus::ORIGINAL, "original"},
|
||||
{AppStatus::UNLOCKED, "unlocked"},
|
||||
{AppStatus::LOCKED, "locked"},
|
||||
{ AppStatus::UNDEFINED, nullptr },
|
||||
{ AppStatus::ORIGINAL, "original" },
|
||||
{ AppStatus::UNLOCKED, "unlocked" },
|
||||
{ AppStatus::LOCKED, "locked" },
|
||||
}
|
||||
// @formatter:on
|
||||
)
|
||||
@@ -26,7 +26,6 @@ namespace smoke_api::config {
|
||||
uint32_t $version = 3;
|
||||
bool logging = false;
|
||||
AppStatus default_app_status = AppStatus::UNLOCKED;
|
||||
uint32_t override_app_id = 0;
|
||||
std::map<std::string, AppStatus> override_app_status;
|
||||
std::map<std::string, AppStatus> override_dlc_status;
|
||||
AppDlcNameMap extra_dlcs;
|
||||
@@ -35,11 +34,9 @@ namespace smoke_api::config {
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(
|
||||
Config,
|
||||
// NOLINT(misc-const-correctness)
|
||||
$version,
|
||||
logging,
|
||||
default_app_status,
|
||||
override_app_id,
|
||||
override_app_status,
|
||||
override_dlc_status,
|
||||
extra_dlcs,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include <set>
|
||||
|
||||
#include <koalabox/logger.hpp>
|
||||
#include <koalabox/util.hpp>
|
||||
|
||||
#include "smoke_api/interfaces/steam_apps.hpp"
|
||||
#include "smoke_api/api.hpp"
|
||||
@@ -88,7 +87,7 @@ namespace smoke_api::steam_apps {
|
||||
const std::function<bool()>& original_function
|
||||
) {
|
||||
try {
|
||||
const auto unlocked = smoke_api::config::is_dlc_unlocked(
|
||||
const auto unlocked = config::is_dlc_unlocked(
|
||||
app_id,
|
||||
dlc_id,
|
||||
original_function
|
||||
@@ -172,10 +171,10 @@ namespace smoke_api::steam_apps {
|
||||
);
|
||||
};
|
||||
|
||||
const auto inject_dlc = [&](const DLC& dlc) {
|
||||
const auto output_dlc = [&](const DLC& dlc) {
|
||||
// Fill the output pointers
|
||||
*pDlcId = dlc.get_id();
|
||||
*pbAvailable = smoke_api::config::is_dlc_unlocked(
|
||||
*pbAvailable = config::is_dlc_unlocked(
|
||||
app_id,
|
||||
*pDlcId,
|
||||
[&] {
|
||||
@@ -192,7 +191,7 @@ namespace smoke_api::steam_apps {
|
||||
const auto& dlcs = app_dlcs[app_id];
|
||||
|
||||
if(iDLC >= 0 && iDLC < dlcs.size()) {
|
||||
inject_dlc(dlcs[iDLC]);
|
||||
output_dlc(dlcs[iDLC]);
|
||||
print_dlc_info("injected");
|
||||
return true;
|
||||
}
|
||||
@@ -204,7 +203,7 @@ namespace smoke_api::steam_apps {
|
||||
const auto success = original_function();
|
||||
|
||||
if(success) {
|
||||
*pbAvailable = smoke_api::config::is_dlc_unlocked(
|
||||
*pbAvailable = config::is_dlc_unlocked(
|
||||
app_id,
|
||||
*pDlcId,
|
||||
[&] {
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace smoke_api::steam_inventory {
|
||||
"{} -> handle: {}, pOutItemsArray: {}, arraySize: {}",
|
||||
function_name,
|
||||
resultHandle,
|
||||
fmt::ptr(pOutItemsArray),
|
||||
reinterpret_cast<void*>(pOutItemsArray),
|
||||
*punOutItemsArraySize
|
||||
);
|
||||
|
||||
@@ -140,26 +140,32 @@ namespace smoke_api::steam_inventory {
|
||||
const uint32_t* punValueBufferSizeOut,
|
||||
const std::function<bool()>& original_function
|
||||
) {
|
||||
const auto common_info = fmt::format(
|
||||
LOG_DEBUG(
|
||||
"{} -> Handle: {}, Index: {}, Name: '{}'",
|
||||
function_name,
|
||||
resultHandle,
|
||||
unItemIndex,
|
||||
pchPropertyName
|
||||
// can be empty, in which case steam responds with property list in csv format
|
||||
pchPropertyName ? pchPropertyName : "nullptr"
|
||||
);
|
||||
|
||||
const auto success = original_function();
|
||||
|
||||
if(!success) {
|
||||
LOG_WARN("{}, Result is false", common_info);
|
||||
LOG_WARN("{} -> Result is false", function_name);
|
||||
return false;
|
||||
}
|
||||
|
||||
LOG_DEBUG(
|
||||
"{}, Buffer: '{}'",
|
||||
common_info,
|
||||
std::string(pchValueBuffer, *punValueBufferSizeOut - 1)
|
||||
);
|
||||
if(
|
||||
pchValueBuffer && *pchValueBuffer &&
|
||||
punValueBufferSizeOut && *punValueBufferSizeOut > 0
|
||||
) {
|
||||
LOG_DEBUG(
|
||||
R"({} -> Buffer: "{}")",
|
||||
function_name,
|
||||
std::string(pchValueBuffer, *punValueBufferSizeOut - 1)
|
||||
);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user