diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb79eba..2794529 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,7 @@ on: push jobs: ci: name: CI - uses: acidicoala/KoalaBox/.github/workflows/build-and-package.yml@d9b0d1a00beb065a9a931a60ef615ce8d1fc7164 + uses: acidicoala/KoalaBox/.github/workflows/build-and-package.yml@15d5cfc2e515bc72e47da6c0c563820cff98551f permissions: contents: write with: diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index 73a5d51..98e618b 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -4,5 +4,6 @@ + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index a47deff..49063d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,8 +35,6 @@ configure_build_config(extra_build_config) set( SMOKE_API_SOURCES - src/core/cache.cpp - src/core/cache.hpp src/core/config.cpp src/core/config.hpp src/core/globals.cpp @@ -44,9 +42,11 @@ set( src/core/macros.hpp src/core/paths.cpp src/core/paths.hpp - src/core/steam_types.hpp + src/core/types.hpp src/smoke_api/smoke_api.cpp src/smoke_api/smoke_api.hpp + src/smoke_api/app_cache.cpp + src/smoke_api/app_cache.hpp src/steam_api_exports/steam_api_flat.cpp src/steam_api_exports/steam_api_internal.cpp src/steam_api_exports/steam_api_unversioned.cpp @@ -73,12 +73,15 @@ set( if (CMAKE_SIZEOF_VOID_P EQUAL 4) set( SMOKE_API_SOURCES ${SMOKE_API_SOURCES} + src/koalageddon/cache.hpp + src/koalageddon/cache.cpp src/koalageddon/koalageddon.hpp src/koalageddon/koalageddon.cpp - src/koalageddon/vstdlib.cpp - src/koalageddon/vstdlib.hpp src/koalageddon/steamclient.cpp src/koalageddon/steamclient.hpp + src/koalageddon/types.hpp + src/koalageddon/vstdlib.cpp + src/koalageddon/vstdlib.hpp src/steamclient_virtuals/client_app_manager.cpp src/steamclient_virtuals/client_apps.cpp src/steamclient_virtuals/client_inventory.cpp diff --git a/KoalaBox b/KoalaBox index 15d5cfc..b076544 160000 --- a/KoalaBox +++ b/KoalaBox @@ -1 +1 @@ -Subproject commit 15d5cfc2e515bc72e47da6c0c563820cff98551f +Subproject commit b076544f304c91859a2260e195846aaaa99e6567 diff --git a/src/core/cache.cpp b/src/core/cache.cpp deleted file mode 100644 index ce6491d..0000000 --- a/src/core/cache.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include -#include -#include -#include - -namespace cache { - - - Cache read_cache_from_disk() { - try { - const auto cache_string = koalabox::io::read_file(paths::get_cache_path()); - - if (cache_string.empty()) { - return {}; - } - - return nlohmann::json::parse(cache_string).get(); - } catch (const Exception& e) { - LOG_WARN("{} -> Failed to read cache from disk: {}", __func__, e.what()) - - return {}; - } - } - - void write_cache_to_disk(const Cache& cache) { - try { - const auto cache_string = nlohmann::json(cache).dump(2); - - koalabox::io::write_file(paths::get_cache_path(), cache_string); - } catch (const Exception& e) { - LOG_ERROR("{} -> Failed to write cache to disk: {}", __func__, e.what()) - } - } - - Vector get_dlc_ids(AppId_t app_id) { - const auto cache = read_cache_from_disk(); - - const auto app_id_str = std::to_string(app_id); - - if (cache.apps.contains(app_id_str)) { - return cache.apps.at(app_id_str).dlc_ids; - } - - return {}; - } - - std::optional get_koalageddon_config() { - const auto cache = read_cache_from_disk(); - - if (cache.koalageddon_config.is_null()) { - return std::nullopt; - } - - return cache.koalageddon_config.get(); - } - - void save_dlc_ids(AppId_t app_id, const Vector& dlc_ids) { - LOG_DEBUG("{} -> Caching DLC IDs for the app: {}", __func__, app_id) - - auto cache = read_cache_from_disk(); - - const auto app_id_str = std::to_string(app_id); - - if (not cache.apps.contains(app_id_str)) { - cache.apps[app_id_str] = {}; - } - - cache.apps[app_id_str].dlc_ids = dlc_ids; - - write_cache_to_disk(cache); - } - - void save_koalageddon_config(const koalageddon::KoalageddonConfig& config) { - LOG_DEBUG("{} -> Caching koalageddon config", __func__) - - auto cache = read_cache_from_disk(); - - cache.koalageddon_config = config; - - write_cache_to_disk(cache); - } -} diff --git a/src/core/cache.hpp b/src/core/cache.hpp deleted file mode 100644 index feb8e86..0000000 --- a/src/core/cache.hpp +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -/** - * This namespace contains utility functions for reading from and writing to cache file on disk. - * All functions are intended to be safe to call, i.e. they should not throw exceptions. - */ -namespace cache { - - struct App { - Vector dlc_ids; - - NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(App, dlc_ids) // NOLINT(misc-const-correctness) - }; - - struct Cache { - // Key represents App ID - Map apps; - nlohmann::json koalageddon_config; - - NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Cache, apps, koalageddon_config) // NOLINT(misc-const-correctness) - }; - - Vector get_dlc_ids(AppId_t app_id); - - std::optional get_koalageddon_config(); - - void save_dlc_ids(AppId_t app_id, const Vector& dlc_ids); - - void save_koalageddon_config(const koalageddon::KoalageddonConfig& config); -} diff --git a/src/core/config.hpp b/src/core/config.hpp index 660ef9d..114de96 100644 --- a/src/core/config.hpp +++ b/src/core/config.hpp @@ -1,6 +1,6 @@ #pragma once -#include -#include + +#include namespace config { enum class AppStatus { @@ -41,7 +41,7 @@ namespace config { bool auto_inject_inventory = true; Vector extra_inventory_items; // We have to use general json type here since the library doesn't support std::optional - nlohmann::json koalageddon_config; + Json koalageddon_config; NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT( Config, $version, // NOLINT(misc-const-correctness) @@ -63,6 +63,8 @@ namespace config { void init(); AppStatus get_app_status(uint32_t app_id); + DlcStatus get_dlc_status(uint32_t dlc_id); + bool is_dlc_unlocked(uint32_t app_id, uint32_t dlc_id, const Function& original_function); } diff --git a/src/core/globals.cpp b/src/core/globals.cpp index 4b5b0fc..e3c2e38 100644 --- a/src/core/globals.cpp +++ b/src/core/globals.cpp @@ -1,9 +1,11 @@ #include namespace globals { + HMODULE smokeapi_handle = nullptr; HMODULE steamapi_module = nullptr; HMODULE vstdlib_module = nullptr; HMODULE steamclient_module = nullptr; Map address_map; // NOLINT(cert-err58-cpp) + } diff --git a/src/core/globals.hpp b/src/core/globals.hpp index b0c44e7..74608a7 100644 --- a/src/core/globals.hpp +++ b/src/core/globals.hpp @@ -1,5 +1,6 @@ #pragma once -#include + +#include namespace globals { diff --git a/src/core/paths.hpp b/src/core/paths.hpp index d57873c..1a7a7d5 100644 --- a/src/core/paths.hpp +++ b/src/core/paths.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace paths { diff --git a/src/core/steam_types.hpp b/src/core/types.hpp similarity index 93% rename from src/core/steam_types.hpp rename to src/core/types.hpp index 3ee84a8..1b97f23 100644 --- a/src/core/steam_types.hpp +++ b/src/core/types.hpp @@ -1,6 +1,8 @@ #pragma once -#include +#include + +#define COMPILE_KOALAGEDDON _WIN64 using AppId_t = uint32_t; using SteamInventoryResult_t = uint32_t; diff --git a/src/koalageddon/cache.cpp b/src/koalageddon/cache.cpp new file mode 100644 index 0000000..0dd0c5f --- /dev/null +++ b/src/koalageddon/cache.cpp @@ -0,0 +1,33 @@ +#include +#include +#include + +constexpr auto KEY_KG_CONFIG = "koalageddon_config"; + +namespace koalageddon::cache { + + std::optional get_koalageddon_config() { + try { + const auto cache = koalabox::cache::read_from_cache(KEY_KG_CONFIG).value(); + + return cache.at(KEY_KG_CONFIG).get(); + } catch (const Exception& e) { + LOG_ERROR("{} -> Failed to get cached koalageddon config: {}", __func__, e.what()) + + return std::nullopt; + } + } + + bool save_koalageddon_config(const KoalageddonConfig& config) { + try { + LOG_DEBUG("{} -> Caching koalageddon config", __func__) + + return koalabox::cache::save_to_cache(KEY_KG_CONFIG, config); + } catch (const Exception& e) { + LOG_ERROR("{} -> Failed to cache koalageddon config: {}", __func__, e.what()) + + return false; + } + } + +} diff --git a/src/koalageddon/cache.hpp b/src/koalageddon/cache.hpp new file mode 100644 index 0000000..9c23471 --- /dev/null +++ b/src/koalageddon/cache.hpp @@ -0,0 +1,11 @@ +#pragma once + +#include + +namespace koalageddon::cache { + + std::optional get_koalageddon_config(); + + bool save_koalageddon_config(const KoalageddonConfig& config); + +} diff --git a/src/koalageddon/koalageddon.cpp b/src/koalageddon/koalageddon.cpp index 3b4402b..98733b7 100644 --- a/src/koalageddon/koalageddon.cpp +++ b/src/koalageddon/koalageddon.cpp @@ -1,19 +1,15 @@ #include #include +#include #include -#include #include #include #include #include #include #include -#include -#include namespace koalageddon { - using namespace koalabox; - KoalageddonConfig config; // NOLINT(cert-err58-cpp) /** @@ -34,7 +30,7 @@ namespace koalageddon { try { // Then try to fetch config from GitHub const String url = "https://raw.githubusercontent.com/acidicoala/public-entitlements/main/koalageddon/v2/steam.json"; - config = http_client::fetch_json(url).get(); + config = koalabox::http_client::fetch_json(url).get(); cache::save_koalageddon_config(config); @@ -46,7 +42,7 @@ namespace koalageddon { try { // Then try to get a cached copy of a previously fetched config. // We expect this unboxing to throw exception if no koalageddon config is present. - config = *cache::get_koalageddon_config(); + config = cache::get_koalageddon_config().value(); return "disk cache"; } catch (const Exception& ex) { @@ -66,10 +62,10 @@ namespace koalageddon { } ).detach(); - dll_monitor::init( + koalabox::dll_monitor::init_listener( {VSTDLIB_DLL, STEAMCLIENT_DLL}, [](const HMODULE& module_handle, const String& name) { try { - if (util::strings_are_equal(name, VSTDLIB_DLL)) { + if (koalabox::util::strings_are_equal(name, VSTDLIB_DLL)) { // VStdLib DLL handles Family Sharing functions globals::vstdlib_module = module_handle; @@ -77,7 +73,7 @@ namespace koalageddon { if (config::instance.unlock_family_sharing) { DETOUR_VSTDLIB(Coroutine_Create) } - } else if (util::strings_are_equal(name, STEAMCLIENT_DLL)) { + } else if (koalabox::util::strings_are_equal(name, STEAMCLIENT_DLL)) { // SteamClient DLL handles unlocking functions globals::steamclient_module = module_handle; @@ -86,7 +82,7 @@ namespace koalageddon { } if (globals::vstdlib_module != nullptr && globals::steamclient_module != nullptr) { - dll_monitor::shutdown(); + koalabox::dll_monitor::shutdown_listener(); } } catch (const Exception& ex) { LOG_ERROR( diff --git a/src/koalageddon/koalageddon.hpp b/src/koalageddon/koalageddon.hpp index b329421..df3e34a 100644 --- a/src/koalageddon/koalageddon.hpp +++ b/src/koalageddon/koalageddon.hpp @@ -1,34 +1,8 @@ #pragma once -#include -#include +#include namespace koalageddon { - // Offset values are interpreted according to pointer arithmetic rules, i.e. - // 1 unit offset represents 4 and 8 bytes in 32-bit and 64-bit architectures respectively. - struct KoalageddonConfig { - uint32_t client_engine_steam_client_internal_ordinal = 12; - uint32_t steam_client_internal_interface_selector_ordinal = 18; - - uint32_t vstdlib_callback_address_offset = 20; - uint32_t vstdlib_callback_data_offset = 0; - uint32_t vstdlib_callback_interceptor_address_offset = 1; - uint32_t vstdlib_callback_name_offset = 4; - - // We do not use *_WITH_DEFAULT macro to ensure that overriding - // the koalageddon config requires definition of all keys - NLOHMANN_DEFINE_TYPE_INTRUSIVE( - KoalageddonConfig, // NOLINT(misc-const-correctness) - - client_engine_steam_client_internal_ordinal, - steam_client_internal_interface_selector_ordinal, - - vstdlib_callback_address_offset, - vstdlib_callback_data_offset, - vstdlib_callback_interceptor_address_offset, - vstdlib_callback_name_offset - ) - }; extern KoalageddonConfig config; diff --git a/src/koalageddon/steamclient.hpp b/src/koalageddon/steamclient.hpp index 412f332..0bc73f3 100644 --- a/src/koalageddon/steamclient.hpp +++ b/src/koalageddon/steamclient.hpp @@ -1,4 +1,4 @@ -#include +#pragma once namespace koalageddon::steamclient { diff --git a/src/koalageddon/types.hpp b/src/koalageddon/types.hpp new file mode 100644 index 0000000..7758f0b --- /dev/null +++ b/src/koalageddon/types.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include + +// Offset values are interpreted according to pointer arithmetic rules, i.e. +// 1 unit offset represents 4 and 8 bytes in 32-bit and 64-bit architectures respectively. +struct KoalageddonConfig { + uint32_t client_engine_steam_client_internal_ordinal = 12; + uint32_t steam_client_internal_interface_selector_ordinal = 18; + uint32_t vstdlib_callback_address_offset = 20; + uint32_t vstdlib_callback_data_offset = 0; + uint32_t vstdlib_callback_interceptor_address_offset = 1; + uint32_t vstdlib_callback_name_offset = 4; + + // We do not use *_WITH_DEFAULT macro to ensure that overriding + // the koalageddon config requires definition of all keys + NLOHMANN_DEFINE_TYPE_INTRUSIVE( + KoalageddonConfig, // NOLINT(misc-const-correctness) + client_engine_steam_client_internal_ordinal, + steam_client_internal_interface_selector_ordinal, + vstdlib_callback_address_offset, + vstdlib_callback_data_offset, + vstdlib_callback_interceptor_address_offset, + vstdlib_callback_name_offset + ) +}; diff --git a/src/koalageddon/vstdlib.hpp b/src/koalageddon/vstdlib.hpp index ef9dc4f..c4c0fa9 100644 --- a/src/koalageddon/vstdlib.hpp +++ b/src/koalageddon/vstdlib.hpp @@ -1,5 +1,4 @@ #include -#include #include namespace koalageddon::vstdlib { diff --git a/src/smoke_api/app_cache.cpp b/src/smoke_api/app_cache.cpp new file mode 100644 index 0000000..7159816 --- /dev/null +++ b/src/smoke_api/app_cache.cpp @@ -0,0 +1,60 @@ +#include +#include +#include +#include + +struct App { + Vector dlc_ids; + + NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(App, dlc_ids) // NOLINT(misc-const-correctness) +}; + +using Apps = Map; + +constexpr auto KEY_APPS = "apps"; + +Apps get_cached_apps() { + try { + const auto cache = koalabox::cache::read_from_cache(KEY_APPS).value(); + + return cache.get(); + } catch (const Exception& e) { + LOG_WARN("{} -> Failed to get cached apps: {}", __func__, e.what()) + + return {}; + } +} + +namespace smoke_api::app_cache { + + Vector get_dlc_ids(AppId_t app_id) { + try { + LOG_DEBUG("{} -> Reading cached DLC IDs for the app: {}", __func__, app_id) + + const auto app = get_cached_apps().at(std::to_string(app_id)); + + return app.dlc_ids; + } catch (const Exception& e) { + return {}; + } + } + + bool save_dlc_ids(AppId_t app_id, const Vector& dlc_ids) { + try { + LOG_DEBUG("{} -> Caching DLC IDs for the app: {}", __func__, app_id) + + auto apps = get_cached_apps(); + + apps[std::to_string(app_id)] = { + .dlc_ids = dlc_ids + }; + + return koalabox::cache::save_to_cache(KEY_APPS, apps); + } catch (const Exception& e) { + LOG_ERROR("{} -> Failed to cache DLC IDs fro the app: {}", __func__, app_id) + + return false; + } + } + +} diff --git a/src/smoke_api/app_cache.hpp b/src/smoke_api/app_cache.hpp new file mode 100644 index 0000000..1fe9411 --- /dev/null +++ b/src/smoke_api/app_cache.hpp @@ -0,0 +1,11 @@ +#pragma once + +#include + +namespace smoke_api::app_cache { + + Vector get_dlc_ids(AppId_t app_id); + + bool save_dlc_ids(AppId_t app_id, const Vector& dlc_ids); + +} diff --git a/src/smoke_api/smoke_api.cpp b/src/smoke_api/smoke_api.cpp index 6f1e16f..8abb5ec 100644 --- a/src/smoke_api/smoke_api.cpp +++ b/src/smoke_api/smoke_api.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -16,65 +17,64 @@ #include #endif +void init_proxy_mode() { + LOG_INFO("🔀 Detected proxy mode") + + globals::steamapi_module = koalabox::loader::load_original_library(paths::get_self_path(), STEAMAPI_DLL); +} + +void init_hook_mode() { + LOG_INFO("🪝 Detected hook mode") + + koalabox::dll_monitor::init_listener( + STEAMCLIENT_DLL, [](const HMODULE& library) { + globals::steamclient_module = library; + + DETOUR_STEAMCLIENT(CreateInterface) + + koalabox::dll_monitor::shutdown_listener(); + } + ); + + // Hooking steam_api has shown itself to be less desirable than steamclient + // for the reasons outlined below: + // + // Calling original in flat functions will actually call the hooked functions + // because the original function redirects the execution to a function taken + // from self pointer, which would have been hooked by SteamInternal_*Interface + // functions. + // + // Furthermore, turns out that many flat functions share the same body, + // which looks like the following snippet: + // + // mov rax, qword ptr ds:[rcx] + // jmp qword ptr ds:[rax+immediate] + // + // This means that we end up inadvertently hooking unintended functions. + // Given that hooking steam_api has no apparent benefits, but has inherent flaws, + // the support for it has been dropped from this project. +} + +bool is_valve_steam(const String& exe_name) { + if (not koalabox::util::strings_are_equal(exe_name, "steam.exe")) { + return false; + } + + const HMODULE steam_handle = koalabox::win_util::get_module_handle_or_throw(nullptr); + const auto manifest = koalabox::win_util::get_module_manifest(steam_handle); + + // Verify that it's steam from valve, and not some other executable coincidentally named steam + + if (!manifest) { + // Steam.exe is expected to have a manifest + return false; + } + + // Steam.exe manifest is expected to contain this string + return manifest->find("valvesoftware.steam.steam") != String::npos; +} + namespace smoke_api { - using namespace koalabox; - - void init_proxy_mode() { - LOG_INFO("🔀 Detected proxy mode") - - globals::steamapi_module = loader::load_original_library(paths::get_self_path(), STEAMAPI_DLL); - } - - void init_hook_mode() { - LOG_INFO("🪝 Detected hook mode") - - dll_monitor::init( - STEAMCLIENT_DLL, [](const HMODULE& library) { - globals::steamclient_module = library; - - DETOUR_STEAMCLIENT(CreateInterface) - - dll_monitor::shutdown(); - } - ); - - // Hooking steam_api has shown itself to be less desirable than steamclient - // for the reasons outlined below: - // - // Calling original in flat functions will actually call the hooked functions - // because the original function redirects the execution to a function taken - // from self pointer, which would have been hooked by SteamInternal_*Interface - // functions. - // - // Furthermore, turns out that many flat functions share the same body, - // which looks like the following snippet: - // - // mov rax, qword ptr ds:[rcx] - // jmp qword ptr ds:[rax+immediate] - // - // This means that we end up inadvertently hooking unintended functions. - // Given that hooking steam_api has no apparent benefits, but has inherent flaws, - // the support for it has been dropped from this project. - } - - bool is_valve_steam(const String& exe_name) { - if (not util::strings_are_equal(exe_name, "steam.exe")) { - return false; - } - - const HMODULE steam_handle = win_util::get_module_handle_or_throw(nullptr); - const auto manifest = win_util::get_module_manifest(steam_handle); - - // Verify that it's steam from valve, and not some other executable coincidentally named steam - - if (!manifest) { - // Steam.exe is expected to have a manifest - return false; - } - - // Steam.exe manifest is expected to contain this string - return manifest->find("valvesoftware.steam.steam") != String::npos; - } void init(HMODULE module_handle) { try { @@ -82,22 +82,23 @@ namespace smoke_api { globals::smokeapi_handle = module_handle; + koalabox::cache::init_cache(paths::get_cache_path()); + config::init(); if (config::instance.logging) { - logger::init_file_logger(paths::get_log_path()); + koalabox::logger::init_file_logger(paths::get_log_path()); } LOG_INFO("🐨 {} v{}", PROJECT_NAME, PROJECT_VERSION) - const auto exe_path = Path(win_util::get_module_file_name_or_throw(nullptr)); + const auto exe_path = Path(koalabox::win_util::get_module_file_name_or_throw(nullptr)); const auto exe_name = exe_path.filename().string(); - const auto exe_bitness = util::is_x64() ? 64 : 32; - LOG_DEBUG(R"(Process name: "{}" [{}-bit])", exe_name, exe_bitness) + LOG_DEBUG(R"(Process name: "{}" [{}-bit])", exe_name, BITNESS) - if (hook::is_hook_mode(globals::smokeapi_handle, STEAMAPI_DLL)) { - hook::init(true); + if (koalabox::hook::is_hook_mode(globals::smokeapi_handle, STEAMAPI_DLL)) { + koalabox::hook::init(true); if (is_valve_steam(exe_name)) { #ifndef _WIN64 @@ -112,14 +113,14 @@ namespace smoke_api { } LOG_INFO("🚀 Initialization complete") } catch (const Exception& ex) { - util::panic(fmt::format("Initialization error: {}", ex.what())); + koalabox::util::panic(fmt::format("Initialization error: {}", ex.what())); } } void shutdown() { try { if (globals::steamapi_module != nullptr) { - win_util::free_library(globals::steamapi_module); + koalabox::win_util::free_library(globals::steamapi_module); } LOG_INFO("💀 Shutdown complete") diff --git a/src/steam_api_exports/steam_api_flat.cpp b/src/steam_api_exports/steam_api_flat.cpp index 92ed316..ac623e2 100644 --- a/src/steam_api_exports/steam_api_flat.cpp +++ b/src/steam_api_exports/steam_api_flat.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/src/steam_api_exports/steam_api_internal.cpp b/src/steam_api_exports/steam_api_internal.cpp index f6858c1..bd63bf3 100644 --- a/src/steam_api_exports/steam_api_internal.cpp +++ b/src/steam_api_exports/steam_api_internal.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/src/steam_functions/steam_functions.hpp b/src/steam_functions/steam_functions.hpp index a99317b..9c44e7a 100644 --- a/src/steam_functions/steam_functions.hpp +++ b/src/steam_functions/steam_functions.hpp @@ -1,8 +1,7 @@ #pragma once #include -#include -#include +#include // TODO: Refactor into multiple headers diff --git a/src/steam_impl/steam_apps.cpp b/src/steam_impl/steam_apps.cpp index bb2d24f..1efb09d 100644 --- a/src/steam_impl/steam_apps.cpp +++ b/src/steam_impl/steam_apps.cpp @@ -1,16 +1,13 @@ #include -#include #include -#include +#include #include #include #include #include -#include +#include namespace steam_apps { - using namespace koalabox; - /// Steamworks may max GetDLCCount value at 64, depending on how much unowned DLCs the user has. /// Despite this limit, some games with more than 64 DLCs still keep using this method. /// This means we have to get extra DLC IDs from local config, remote config, or cache. @@ -45,10 +42,10 @@ namespace steam_apps { try { // TODO: Refactor into api namespace const auto url = fmt::format("https://store.steampowered.com/dlc/{}/ajaxgetdlclist", app_id_str); - const auto json = http_client::fetch_json(url); + const auto json = koalabox::http_client::fetch_json(url); if (json["success"] != 1) { - throw util::exception("Web API responded with 'success' != 1"); + throw koalabox::util::exception("Web API responded with 'success' != 1"); } for (const auto& dlc: json["dlcs"]) { @@ -68,7 +65,7 @@ namespace steam_apps { try { const String url = "https://raw.githubusercontent.com/acidicoala/public-entitlements/main/steam/v1/dlc.json"; - const auto json = http_client::fetch_json(url); + const auto json = koalabox::http_client::fetch_json(url); if (json.contains(app_id_str)) { dlcs = json[app_id_str].get(); @@ -91,7 +88,7 @@ namespace steam_apps { combined_dlcs.insert(github_dlcs.begin(), github_dlcs.end()); // There is no need to insert cached entries if both steam and GitHub requests were successful. if (!total_success) { - const auto cache_dlcs = cache::get_dlc_ids(app_id); + const auto cache_dlcs = smoke_api::app_cache::get_dlc_ids(app_id); combined_dlcs.insert(cached_dlcs.begin(), cached_dlcs.end()); } @@ -99,7 +96,7 @@ namespace steam_apps { cached_dlcs.clear(); cached_dlcs.insert(cached_dlcs.begin(), combined_dlcs.begin(), combined_dlcs.end()); - cache::save_dlc_ids(app_id, cached_dlcs); + smoke_api::app_cache::save_dlc_ids(app_id, cached_dlcs); return total_success; } diff --git a/src/steam_impl/steam_apps.hpp b/src/steam_impl/steam_apps.hpp index 8cb18b0..d282a53 100644 --- a/src/steam_impl/steam_apps.hpp +++ b/src/steam_impl/steam_apps.hpp @@ -1,5 +1,7 @@ -#include -#include +#pragma once + +#include +#include namespace steam_apps { diff --git a/src/steam_impl/steam_client.hpp b/src/steam_impl/steam_client.hpp index 2c7105f..b9d64fb 100644 --- a/src/steam_impl/steam_client.hpp +++ b/src/steam_impl/steam_client.hpp @@ -1,4 +1,6 @@ -#include +#pragma once + +#include namespace steam_client { diff --git a/src/steam_impl/steam_inventory.hpp b/src/steam_impl/steam_inventory.hpp index 82a89d7..ccde607 100644 --- a/src/steam_impl/steam_inventory.hpp +++ b/src/steam_impl/steam_inventory.hpp @@ -1,5 +1,7 @@ -#include -#include +#pragma once + +#include +#include namespace steam_inventory { diff --git a/src/steam_impl/steam_user.hpp b/src/steam_impl/steam_user.hpp index 3a91616..247ad7c 100644 --- a/src/steam_impl/steam_user.hpp +++ b/src/steam_impl/steam_user.hpp @@ -1,5 +1,7 @@ -#include -#include +#pragma once + +#include +#include namespace steam_user { diff --git a/src/steamclient_virtuals/client_app_manager.cpp b/src/steamclient_virtuals/client_app_manager.cpp index 3d41269..f235d8f 100644 --- a/src/steamclient_virtuals/client_app_manager.cpp +++ b/src/steamclient_virtuals/client_app_manager.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include VIRTUAL(bool) IClientAppManager_IsAppDlcInstalled(PARAMS(AppId_t app_id, AppId_t dlc_id)) { diff --git a/src/steamclient_virtuals/client_apps.cpp b/src/steamclient_virtuals/client_apps.cpp index 68d5430..759989a 100644 --- a/src/steamclient_virtuals/client_apps.cpp +++ b/src/steamclient_virtuals/client_apps.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include VIRTUAL(int) IClientApps_GetDLCCount(PARAMS(AppId_t appId)) { diff --git a/src/steamclient_virtuals/client_inventory.cpp b/src/steamclient_virtuals/client_inventory.cpp index 3f66238..e987351 100644 --- a/src/steamclient_virtuals/client_inventory.cpp +++ b/src/steamclient_virtuals/client_inventory.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include