mirror of
https://github.com/acidicoala/SmokeAPI.git
synced 2026-01-24 13:32:51 -05:00
Refactored version check
This commit is contained in:
2
KoalaBox
2
KoalaBox
Submodule KoalaBox updated: 26c9a26337...997b5db2ee
@@ -20,8 +20,8 @@
|
||||
"logging": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"x-packaged-default": true,
|
||||
"description": "Enables logging to SmokeAPI.log.log file.",
|
||||
"x-packaged-default": true,
|
||||
"x-valid-values": "`true` or `false`."
|
||||
},
|
||||
"log_steam_http": {
|
||||
|
||||
@@ -59,6 +59,7 @@ namespace {
|
||||
bool is_hook_mode;
|
||||
|
||||
void check_for_updates() {
|
||||
try {
|
||||
const auto latest_release_url = std::format(
|
||||
"https://api.github.com/repos/acidicoala/{}/releases/latest",
|
||||
PROJECT_NAME
|
||||
@@ -77,6 +78,9 @@ namespace {
|
||||
|
||||
LOG_WARN("New version {} available: {}", latest_tag, release_page);
|
||||
}
|
||||
} catch(const std::exception& e) {
|
||||
LOG_ERROR("{} -> Unexpected error: {}", __func__, e.what());
|
||||
}
|
||||
}
|
||||
|
||||
std::set<std::string> find_steamclient_versions(void* steamapi_handle) {
|
||||
@@ -134,7 +138,9 @@ namespace {
|
||||
static const auto CreateInterface$ = KB_LIB_GET_FUNC(steamclient_handle, CreateInterface);
|
||||
|
||||
if(auto* steamapi_handle = kb::lib::get_lib_handle(STEAM_API_MODULE)) {
|
||||
if(steamapi_handle != original_steamapi_handle) {
|
||||
if(original_steamapi_handle == nullptr) { // hook mode on Windows
|
||||
original_steamapi_handle = steamapi_handle;
|
||||
} else if(steamapi_handle != original_steamapi_handle) {
|
||||
LOG_WARN(
|
||||
"{} -> steamapi_handle ({}) != original_steamapi_handle ({})",
|
||||
__func__, steamapi_handle, original_steamapi_handle
|
||||
@@ -287,12 +293,6 @@ namespace smoke_api {
|
||||
kb::win::check_self_duplicates();
|
||||
#endif
|
||||
|
||||
#ifdef KB_DEBUG
|
||||
// TODO: Add config option to toggle this and show native OS notification
|
||||
// The real reason behind this is for automatic testing of HTTPs dependencies
|
||||
std::thread(check_for_updates).detach();
|
||||
#endif
|
||||
|
||||
// We need to hook functions in either mode
|
||||
kb::hook::init(true);
|
||||
|
||||
@@ -313,6 +313,14 @@ namespace smoke_api {
|
||||
}
|
||||
}
|
||||
|
||||
void post_init() {
|
||||
#ifdef KB_DEBUG
|
||||
// TODO: Add config option to toggle this and show native OS notification
|
||||
// The real reason behind this is for automatic testing of HTTPs dependencies
|
||||
std::thread(check_for_updates).detach();
|
||||
#endif
|
||||
}
|
||||
|
||||
void shutdown() {
|
||||
try {
|
||||
static bool shutdown_complete = false;
|
||||
|
||||
@@ -4,6 +4,14 @@
|
||||
|
||||
namespace smoke_api {
|
||||
void init(void* self_module_handle);
|
||||
|
||||
/**
|
||||
* Post-initialization procedures that must be done after the module is finished loading.
|
||||
* Reason being that on Windows we should not start new threads while being in DllMain callback,
|
||||
* otherwise we would run into deadlocks/race-conditions/undefined behavior.
|
||||
*/
|
||||
void post_init();
|
||||
|
||||
void shutdown();
|
||||
|
||||
AppId_t get_app_id();
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <koalabox/logger.hpp>
|
||||
|
||||
#include "smoke_api/steamclient/steamclient.hpp"
|
||||
#include "smoke_api/smoke_api.hpp"
|
||||
#include "smoke_api/types.hpp"
|
||||
|
||||
#include "steam_api/steam_client.hpp"
|
||||
@@ -16,6 +17,9 @@ C_DECL(void*) CreateInterface(const char* interface_version, create_interface_re
|
||||
static std::mutex section;
|
||||
const std::lock_guard lock(section);
|
||||
|
||||
static std::once_flag once_flag;
|
||||
std::call_once(once_flag, smoke_api::post_init);
|
||||
|
||||
return steam_client::GetGenericInterface(
|
||||
__func__,
|
||||
interface_version,
|
||||
|
||||
Reference in New Issue
Block a user