* set these env vars for a more accurate emulation:

- `SteamAppUser`
  - `SteamUser`
  - `SteamClientLaunch`
  - `SteamEnv`
  - `SteamPath`
This commit is contained in:
otavepto 2024-04-13 17:35:10 +02:00
parent 0f6b32c248
commit 484fc2a982
7 changed files with 47 additions and 15 deletions

View File

@ -1,6 +1,12 @@
* **[Clompress]** corrected Turkish translation
* increase run callbacks background thread polling time to `~200ms`
* changed the overlay title to give proper credits to its author
* set these env vars for a more accurate emulation:
- `SteamAppUser`
- `SteamUser`
- `SteamClientLaunch`
- `SteamEnv`
- `SteamPath`
---

View File

@ -83,7 +83,25 @@ Steam_Client::Steam_Client()
auto appid_str = std::to_string(appid);
set_env_variable("SteamAppId", appid_str);
set_env_variable("SteamGameId", appid_str);
set_env_variable("SteamOverlayGameId", appid_str);
set_env_variable("SteamOverlayGameId", appid_str);
}
{
const char *user_name = settings_client->get_local_name();
if (user_name) {
set_env_variable("SteamAppUser", user_name);
set_env_variable("SteamUser", user_name);
}
}
set_env_variable("SteamClientLaunch", "1");
set_env_variable("SteamEnv", "1");
{
std::string steam_path(get_env_variable("SteamPath"));
if (steam_path.empty()) {
set_env_variable("SteamPath", get_full_program_path());
}
}
// client

View File

@ -56,7 +56,7 @@ HTTPRequestHandle Steam_HTTP::CreateHTTPRequest( EHTTPMethod eHTTPRequestMethod,
request.url = url;
if (url_index) {
if (url.back() == '/') url += "index.html";
std::string file_path = Local_Storage::get_game_settings_path() + "http/" + Local_Storage::sanitize_string(url.substr(url_index));
std::string file_path = Local_Storage::get_game_settings_path() + "http" + PATH_SEPARATOR + Local_Storage::sanitize_string(url.substr(url_index));
request.target_filepath = file_path;
unsigned long long file_size = file_size_(file_path);
if (file_size) {
@ -312,7 +312,7 @@ void Steam_HTTP::online_http_request(Steam_Http_Request *request, SteamAPICall_t
fclose(hfile);
headers.clear();
PRINT_DEBUG("CURL for '%s' error code (0 == OK 0): [%i]", request->url.c_str(), (int)res_curl);
PRINT_DEBUG("CURL error code for '%s' [%i] (OK == 0)", request->url.c_str(), (int)res_curl);
unsigned int file_size = file_size_(request->target_filepath);
if (file_size) {
@ -401,7 +401,7 @@ bool Steam_HTTP::DeferHTTPRequest( HTTPRequestHandle hRequest )
// the specified request to the head of the queue. Returns false on invalid handle, or if the request is not yet sent.
bool Steam_HTTP::PrioritizeHTTPRequest( HTTPRequestHandle hRequest )
{
PRINT_DEBUG("Steam_HTTP::PrioritizeHTTPRequest");
PRINT_DEBUG("%u", hRequest);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
Steam_Http_Request *request = get_request(hRequest);
@ -440,7 +440,7 @@ bool Steam_HTTP::GetHTTPResponseHeaderSize( HTTPRequestHandle hRequest, const ch
// BGetHTTPResponseHeaderSize to check for the presence of the header and to find out the size buffer needed.
bool Steam_HTTP::GetHTTPResponseHeaderValue( HTTPRequestHandle hRequest, const char *pchHeaderName, uint8 *pHeaderValueBuffer, uint32 unBufferSize )
{
PRINT_DEBUG_ENTRY();
PRINT_DEBUG("'%s'", pchHeaderName);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (!pchHeaderName) return false;
@ -464,7 +464,7 @@ bool Steam_HTTP::GetHTTPResponseHeaderValue( HTTPRequestHandle hRequest, const c
// handle is invalid.
bool Steam_HTTP::GetHTTPResponseBodySize( HTTPRequestHandle hRequest, uint32 *unBodySize )
{
PRINT_DEBUG_ENTRY();
PRINT_DEBUG("%u", hRequest);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
Steam_Http_Request *request = get_request(hRequest);
@ -525,7 +525,7 @@ bool Steam_HTTP::GetHTTPStreamingResponseBodyData( HTTPRequestHandle hRequest, u
// callback and finishing using the response.
bool Steam_HTTP::ReleaseHTTPRequest( HTTPRequestHandle hRequest )
{
PRINT_DEBUG_ENTRY();
PRINT_DEBUG("%u", hRequest);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
auto c = std::begin(requests);
@ -547,7 +547,7 @@ bool Steam_HTTP::ReleaseHTTPRequest( HTTPRequestHandle hRequest )
// zero for the duration of the request as the size is unknown until the connection closes.
bool Steam_HTTP::GetHTTPDownloadProgressPct( HTTPRequestHandle hRequest, float *pflPercentOut )
{
PRINT_DEBUG_ENTRY();
PRINT_DEBUG("%u", hRequest);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
Steam_Http_Request *request = get_request(hRequest);
@ -564,7 +564,7 @@ bool Steam_HTTP::GetHTTPDownloadProgressPct( HTTPRequestHandle hRequest, float *
// parameter will set the content-type header for the request so the server may know how to interpret the body.
bool Steam_HTTP::SetHTTPRequestRawPostBody( HTTPRequestHandle hRequest, const char *pchContentType, uint8 *pubBody, uint32 unBodyLen )
{
PRINT_DEBUG("%s", pchContentType);
PRINT_DEBUG("%u '%s'", hRequest, pchContentType);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
Steam_Http_Request *request = get_request(hRequest);
@ -635,7 +635,7 @@ bool Steam_HTTP::SetHTTPRequestCookieContainer( HTTPRequestHandle hRequest, HTTP
// Set the extra user agent info for a request, this doesn't clobber the normal user agent, it just adds the extra info on the end
bool Steam_HTTP::SetHTTPRequestUserAgentInfo( HTTPRequestHandle hRequest, const char *pchUserAgentInfo )
{
PRINT_DEBUG_ENTRY();
PRINT_DEBUG("%u '%s'", hRequest, pchUserAgentInfo);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
Steam_Http_Request *request = get_request(hRequest);

View File

@ -378,7 +378,7 @@ size_t pe_helpers::get_pe_size(HMODULE hModule)
static std::wstring path_w{};
static std::string path_a{};
const std::string pe_helpers::get_current_exe_path()
const std::string& pe_helpers::get_current_exe_path()
{
if (path_a.empty()) {
get_current_exe_path_w();
@ -387,7 +387,7 @@ const std::string pe_helpers::get_current_exe_path()
return path_a;
}
const std::wstring pe_helpers::get_current_exe_path_w()
const std::wstring& pe_helpers::get_current_exe_path_w()
{
static std::recursive_mutex path_mtx{};
if (path_w.empty()) {

View File

@ -40,9 +40,9 @@ DWORD loadlib_remote(HANDLE hProcess, const std::wstring &lib_fullpath, const ch
size_t get_pe_size(HMODULE hModule);
const std::string get_current_exe_path();
const std::string& get_current_exe_path();
const std::wstring get_current_exe_path_w();
const std::wstring& get_current_exe_path_w();
bool ends_with_i(PUNICODE_STRING target, const std::wstring &query);

View File

@ -214,7 +214,7 @@ if [ ! -z "${STEAM_RUNTIME}" ]; then
)
fi
SteamAppPath="${EXE_RUN_DIR}" SteamAppId=$APP_ID SteamGameId=$APP_ID SteamOverlayGameId=$APP_ID "$TARGET_EXE" "${EXE_COMMAND_LINE[@]}"
SteamAppPath="${EXE_RUN_DIR}" SteamAppId=$APP_ID SteamGameId=$APP_ID SteamOverlayGameId=$APP_ID SteamAppUser='client_player' SteamUser='client_player' SteamClientLaunch='1' SteamEnv='1' SteamPath="$script_dir" "$TARGET_EXE" "${EXE_COMMAND_LINE[@]}"
popd

View File

@ -326,6 +326,14 @@ void set_steam_env_vars(const std::wstring &AppId)
SetEnvironmentVariableW(L"SteamAppId", AppId.c_str());
SetEnvironmentVariableW(L"SteamGameId", AppId.c_str());
SetEnvironmentVariableW(L"SteamOverlayGameId", AppId.c_str());
// these 2 wil be overridden by the emu
SetEnvironmentVariableW(L"SteamAppUser", L"cold_player");
SetEnvironmentVariableW(L"SteamUser", L"cold_player");
SetEnvironmentVariableW(L"SteamClientLaunch", L"1");
SetEnvironmentVariableW(L"SteamEnv", L"1");
SetEnvironmentVariableW(L"SteamPath", pe_helpers::get_current_exe_path_w().c_str());
}