Set the appid env variables.

merge-requests/48/head
Mr_Goldberg 2022-05-29 15:45:39 -04:00
parent d2ef266f81
commit 03426b217d
No known key found for this signature in database
GPG Key ID: 8597D87419DEF278
3 changed files with 18 additions and 0 deletions

View File

@ -41,6 +41,11 @@ std::string get_env_variable(std::string name)
return utf8_encode(env_variable); return utf8_encode(env_variable);
} }
bool set_env_variable(std::string name, std::string value)
{
return SetEnvironmentVariableW(utf8_decode(name).c_str(), utf8_decode(value).c_str());
}
#else #else
static int fd = -1; static int fd = -1;
@ -81,6 +86,11 @@ std::string get_env_variable(std::string name)
return std::string(env); return std::string(env);
} }
bool set_env_variable(std::string name, std::string value)
{
return setenv(name.c_str(), value.c_str(), 1) == 0;
}
#endif #endif
std::recursive_mutex global_mutex; std::recursive_mutex global_mutex;

View File

@ -25,6 +25,7 @@
extern std::recursive_mutex global_mutex; extern std::recursive_mutex global_mutex;
std::string get_env_variable(std::string name); std::string get_env_variable(std::string name);
bool set_env_variable(std::string name, std::string value);
bool check_timedout(std::chrono::high_resolution_clock::time_point old, double timeout); bool check_timedout(std::chrono::high_resolution_clock::time_point old, double timeout);
class CCallbackMgr class CCallbackMgr

View File

@ -60,6 +60,11 @@ Steam_Client::Steam_Client()
PRINT_DEBUG("steam client init: id: %llu server id: %llu appid: %u port: %u \n", settings_client->get_local_steam_id().ConvertToUint64(), settings_server->get_local_steam_id().ConvertToUint64(), appid, settings_server->get_port()); PRINT_DEBUG("steam client init: id: %llu server id: %llu appid: %u port: %u \n", settings_client->get_local_steam_id().ConvertToUint64(), settings_server->get_local_steam_id().ConvertToUint64(), appid, settings_server->get_port());
if (appid) {
set_env_variable("SteamAppId", std::to_string(appid));
set_env_variable("SteamGameId", std::to_string(appid));
}
steam_overlay = new Steam_Overlay(settings_client, callback_results_client, callbacks_client, run_every_runcb, network); steam_overlay = new Steam_Overlay(settings_client, callback_results_client, callbacks_client, run_every_runcb, network);
steam_user = new Steam_User(settings_client, local_storage, network, callback_results_client, callbacks_client); steam_user = new Steam_User(settings_client, local_storage, network, callback_results_client, callbacks_client);
@ -159,6 +164,8 @@ void Steam_Client::setAppID(uint32 appid)
settings_server->set_game_id(CGameID(appid)); settings_server->set_game_id(CGameID(appid));
local_storage->setAppId(appid); local_storage->setAppId(appid);
network->setAppID(appid); network->setAppID(appid);
set_env_variable("SteamAppId", std::to_string(appid));
set_env_variable("SteamGameId", std::to_string(appid));
} }