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

@@ -49,8 +49,8 @@ set(SMOKE_API_SOURCES
src/steam_api/virtuals/steam_api_virtuals.hpp
src/steam_api/steam_client.hpp
src/steam_api/steam_client.cpp
src/steam_api/steam_interface.cpp
src/steam_api/steam_interface.hpp
src/steam_api/steam_interfaces.cpp
src/steam_api/steam_interfaces.hpp
src/steamclient/steamclient.cpp
src/main.cpp
)

View File

@@ -6,7 +6,6 @@
#include <koalabox/logger.hpp>
#include <koalabox/path.hpp>
#include <koalabox/paths.hpp>
#include <koalabox/str.hpp>
#include <koalabox/util.hpp>
#include <koalabox/win.hpp>
@@ -115,4 +114,15 @@ namespace smoke_api {
kb::logger::shutdown();
}
AppId_t get_app_id() {
try {
const auto app_id_str = kb::win::get_env_var("SteamAppId");
static auto app_id = std::stoi(app_id_str);
return app_id;
} catch(const std::exception& e) {
LOG_ERROR("Failed to get app id: {}", e.what());
return 0;
}
}
}

View File

@@ -1,6 +1,6 @@
#pragma once
#include <koalabox/win.hpp>
#include "smoke_api/types.hpp"
constexpr auto STEAM_APPS = "STEAMAPPS_INTERFACE_VERSION";
constexpr auto STEAM_CLIENT = "SteamClient";
@@ -15,10 +15,10 @@ constexpr auto STEAM_GAME_SERVER = "SteamGameServer";
namespace smoke_api {
extern HMODULE steamapi_module;
extern bool hook_mode;
void init(HMODULE module_handle);
void shutdown();
AppId_t get_app_id();
}

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,

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))
);