Moved get_app_id()

This commit is contained in:
acidicoala
2025-09-04 19:01:16 +05:00
parent 4581c36913
commit bdab9b574f
10 changed files with 34 additions and 41 deletions

View File

@@ -1,6 +1,6 @@
#include <koalabox/logger.hpp>
#include "steam_api/steam_interface.hpp"
#include "steam_api/steam_interfaces.hpp"
#include "steam_client.hpp"
namespace steam_client {
@@ -14,7 +14,7 @@ namespace steam_client {
LOG_DEBUG("{} -> '{}' @ {}", function_name, interface_version, interface);
steam_interface::hook_virtuals(interface, interface_version);
steam_interfaces::hook_virtuals(interface, interface_version);
return interface;
} catch(const std::exception& e) {

View File

@@ -7,7 +7,7 @@
#include <koalabox/logger.hpp>
#include <koalabox/win.hpp>
#include "steam_api/steam_interface.hpp"
#include "steam_api/steam_interfaces.hpp"
#include "smoke_api/smoke_api.hpp"
#include "virtuals/steam_api_virtuals.hpp"
@@ -135,24 +135,9 @@ namespace {
}
}
namespace steam_interface {
namespace steam_interfaces {
namespace kb = koalabox;
AppId_t get_app_id_or_throw() {
const auto app_id_str = kb::win::get_env_var("SteamAppId");
return std::stoi(app_id_str);
}
AppId_t get_app_id() {
try {
static const auto app_id = get_app_id_or_throw();
return app_id;
} catch(const std::exception& e) {
LOG_ERROR("Failed to get app id: {}", e.what());
return 0;
}
}
/**
* @param interface_ptr Pointer to the interface
* @param version_string Example: 'SteamClient020'

View File

@@ -2,9 +2,8 @@
#include "smoke_api/types.hpp"
namespace steam_interface {
AppId_t get_app_id_or_throw();
AppId_t get_app_id();
namespace steam_interfaces {
void hook_virtuals(void* interface_ptr, const std::string& version_string);
}

View File

@@ -1,13 +1,13 @@
#include <koalabox/logger.hpp>
#include "smoke_api/smoke_api.hpp"
#include "smoke_api/interfaces/steam_apps.hpp"
#include "steam_api/steam_interface.hpp"
#include "steam_api/virtuals/steam_api_virtuals.hpp"
VIRTUAL(bool) ISteamApps_BIsSubscribedApp(PARAMS(const AppId_t dlc_id)) noexcept {
return smoke_api::steam_apps::IsDlcUnlocked(
__func__,
steam_interface::get_app_id(),
smoke_api::get_app_id(),
dlc_id,
SWAPPED_CALL_CLOSURE(ISteamApps_BIsSubscribedApp, ARGS(dlc_id))
);
@@ -16,7 +16,7 @@ VIRTUAL(bool) ISteamApps_BIsSubscribedApp(PARAMS(const AppId_t dlc_id)) noexcept
VIRTUAL(bool) ISteamApps_BIsDlcInstalled(PARAMS(const AppId_t dlc_id)) noexcept {
return smoke_api::steam_apps::IsDlcUnlocked(
__func__,
steam_interface::get_app_id(),
smoke_api::get_app_id(),
dlc_id,
SWAPPED_CALL_CLOSURE(ISteamApps_BIsDlcInstalled, ARGS(dlc_id))
);
@@ -25,7 +25,7 @@ VIRTUAL(bool) ISteamApps_BIsDlcInstalled(PARAMS(const AppId_t dlc_id)) noexcept
VIRTUAL(int) ISteamApps_GetDLCCount(PARAMS()) noexcept {
return smoke_api::steam_apps::GetDLCCount(
__func__,
steam_interface::get_app_id(),
smoke_api::get_app_id(),
SWAPPED_CALL_CLOSURE(ISteamApps_GetDLCCount, ARGS())
);
}
@@ -41,7 +41,7 @@ VIRTUAL(bool) ISteamApps_BGetDLCDataByIndex(
) noexcept {
return smoke_api::steam_apps::GetDLCDataByIndex(
__func__,
steam_interface::get_app_id(),
smoke_api::get_app_id(),
iDLC,
p_dlc_id,
pbAvailable,
@@ -52,8 +52,8 @@ VIRTUAL(bool) ISteamApps_BGetDLCDataByIndex(
ARGS(iDLC, p_dlc_id, pbAvailable, pchName, cchNameBufferSize)
),
SWAPPED_CALL_CLOSURE(
ISteamApps_BIsSubscribedApp,
ARGS(*p_dlc_id)
)
ISteamApps_BIsSubscribedApp,
ARGS(*p_dlc_id)
)
);
}

View File

@@ -1,7 +1,7 @@
#include <koalabox/logger.hpp>
#include "smoke_api/smoke_api.hpp"
#include "smoke_api/interfaces/steam_user.hpp"
#include "steam_api/steam_interface.hpp"
#include "steam_api/virtuals/steam_api_virtuals.hpp"
VIRTUAL(EUserHasLicenseForAppResult) ISteamGameServer_UserHasLicenseForApp(
@@ -9,7 +9,7 @@ VIRTUAL(EUserHasLicenseForAppResult) ISteamGameServer_UserHasLicenseForApp(
) noexcept {
return smoke_api::steam_user::UserHasLicenseForApp(
__func__,
steam_interface::get_app_id(),
smoke_api::get_app_id(),
dlc_id,
SWAPPED_CALL_CLOSURE(ISteamGameServer_UserHasLicenseForApp, ARGS(steamID, dlc_id))
);

View File

@@ -1,7 +1,6 @@
#include <koalabox/logger.hpp>
#include "smoke_api/interfaces/steam_http.hpp"
#include "steam_api/steam_interface.hpp"
#include "steam_api/virtuals/steam_api_virtuals.hpp"
VIRTUAL(bool) ISteamHTTP_GetHTTPResponseBodyData(

View File

@@ -1,7 +1,7 @@
#include <koalabox/logger.hpp>
#include "smoke_api/smoke_api.hpp"
#include "smoke_api/interfaces/steam_user.hpp"
#include "steam_api/steam_interface.hpp"
#include "steam_api/virtuals/steam_api_virtuals.hpp"
VIRTUAL(EUserHasLicenseForAppResult) ISteamUser_UserHasLicenseForApp(
@@ -9,7 +9,7 @@ VIRTUAL(EUserHasLicenseForAppResult) ISteamUser_UserHasLicenseForApp(
) noexcept {
return smoke_api::steam_user::UserHasLicenseForApp(
__func__,
steam_interface::get_app_id(),
smoke_api::get_app_id(),
dlc_id,
SWAPPED_CALL_CLOSURE(ISteamUser_UserHasLicenseForApp, ARGS(steamID, dlc_id))
);