diff --git a/CHANGELOG.md b/CHANGELOG.md index 3452c0ef..f5908f4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` --- diff --git a/dll/steam_client.cpp b/dll/steam_client.cpp index 73bdeffc..b96aca26 100644 --- a/dll/steam_client.cpp +++ b/dll/steam_client.cpp @@ -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 diff --git a/dll/steam_http.cpp b/dll/steam_http.cpp index 349d12ed..59ad4cfc 100644 --- a/dll/steam_http.cpp +++ b/dll/steam_http.cpp @@ -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 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 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 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 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 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 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 lock(global_mutex); Steam_Http_Request *request = get_request(hRequest); diff --git a/helpers/pe_helpers.cpp b/helpers/pe_helpers.cpp index 5bc31875..efb79c4f 100644 --- a/helpers/pe_helpers.cpp +++ b/helpers/pe_helpers.cpp @@ -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()) { diff --git a/helpers/pe_helpers/pe_helpers.hpp b/helpers/pe_helpers/pe_helpers.hpp index 66a1339f..649702e2 100644 --- a/helpers/pe_helpers/pe_helpers.hpp +++ b/helpers/pe_helpers/pe_helpers.hpp @@ -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); diff --git a/tools/steamclient_loader/linux/steamclient_loader.sh b/tools/steamclient_loader/linux/steamclient_loader.sh index bd740ab3..73b42077 100644 --- a/tools/steamclient_loader/linux/steamclient_loader.sh +++ b/tools/steamclient_loader/linux/steamclient_loader.sh @@ -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 diff --git a/tools/steamclient_loader/win/ColdClientLoader.cpp b/tools/steamclient_loader/win/ColdClientLoader.cpp index bb85314b..87c93601 100644 --- a/tools/steamclient_loader/win/ColdClientLoader.cpp +++ b/tools/steamclient_loader/win/ColdClientLoader.cpp @@ -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()); }