From 68a65696e546c749a5b692a95ce8549546e7907c Mon Sep 17 00:00:00 2001 From: otavepto Date: Tue, 23 Apr 2024 02:13:51 +0200 Subject: [PATCH] don't use global appdata path in matchmaking + matchmaking_servers, instead used current/active save directory, in case we're using local_save_path --- dll/dll/steam_matchmaking.h | 14 ++++++++------ dll/dll/steam_matchmaking_servers.h | 7 ++++--- dll/steam_client.cpp | 4 ++-- dll/steam_matchmaking_servers.cpp | 9 +++++---- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/dll/dll/steam_matchmaking.h b/dll/dll/steam_matchmaking.h index 4b5c02ad..629d8f2d 100644 --- a/dll/dll/steam_matchmaking.h +++ b/dll/dll/steam_matchmaking.h @@ -73,6 +73,7 @@ public ISteamMatchmaking008, public ISteamMatchmaking { class Settings *settings{}; + class Local_Storage *local_storage{}; class Networking *network{}; class SteamCallResults *callback_results{}; class SteamCallBacks *callbacks{}; @@ -305,9 +306,10 @@ static void steam_matchmaking_run_every_runcb(void *object) steam_matchmaking->RunCallbacks(); } -Steam_Matchmaking(class Settings *settings, class Networking *network, class SteamCallResults *callback_results, class SteamCallBacks *callbacks, class RunEveryRunCB *run_every_runcb) +Steam_Matchmaking(class Settings *settings, class Local_Storage *local_storage, class Networking *network, class SteamCallResults *callback_results, class SteamCallBacks *callbacks, class RunEveryRunCB *run_every_runcb) { this->settings = settings; + this->local_storage = local_storage; this->network = network; this->run_every_runcb = run_every_runcb; this->network->setCallback(CALLBACK_ID_LOBBY, settings->get_local_steam_id(), &Steam_Matchmaking::steam_matchmaking_callback, this); @@ -346,7 +348,7 @@ static Lobby_Member *get_lobby_member(Lobby *lobby, CSteamID user_id) int GetFavoriteGameCount() { PRINT_DEBUG_ENTRY(); - std::string file_path = Local_Storage::get_user_appdata_path() + "7" + PATH_SEPARATOR + Local_Storage::remote_storage_folder + PATH_SEPARATOR + "serverbrowser_favorites.txt"; + std::string file_path = local_storage->get_current_save_directory() + "7" + PATH_SEPARATOR + Local_Storage::remote_storage_folder + PATH_SEPARATOR + "serverbrowser_favorites.txt"; unsigned long long file_size = file_size_(file_path); if (file_size) { std::string list{}; @@ -381,11 +383,11 @@ int AddFavoriteGame( AppId_t nAppID, uint32 nIP, uint16 nConnPort, uint16 nQuery unsigned long long file_size; if (unFlags == 1) { - file_path = Local_Storage::get_user_appdata_path() + "7" + PATH_SEPARATOR + Local_Storage::remote_storage_folder + PATH_SEPARATOR + "serverbrowser_favorites.txt"; + file_path = local_storage->get_current_save_directory() + "7" + PATH_SEPARATOR + Local_Storage::remote_storage_folder + PATH_SEPARATOR + "serverbrowser_favorites.txt"; file_size = file_size_(file_path); } else if (unFlags == 2) { - file_path = Local_Storage::get_user_appdata_path() + "7" + PATH_SEPARATOR + Local_Storage::remote_storage_folder + PATH_SEPARATOR + "serverbrowser_history.txt"; + file_path = local_storage->get_current_save_directory() + "7" + PATH_SEPARATOR + Local_Storage::remote_storage_folder + PATH_SEPARATOR + "serverbrowser_history.txt"; file_size = file_size_(file_path); } else { @@ -454,11 +456,11 @@ bool RemoveFavoriteGame( AppId_t nAppID, uint32 nIP, uint16 nConnPort, uint16 nQ unsigned long long file_size; if (unFlags == 1) { - file_path = Local_Storage::get_user_appdata_path() + "7" + PATH_SEPARATOR + Local_Storage::remote_storage_folder + "serverbrowser_favorites.txt"; + file_path = local_storage->get_current_save_directory() + "7" + PATH_SEPARATOR + Local_Storage::remote_storage_folder + "serverbrowser_favorites.txt"; file_size = file_size_(file_path); } else if (unFlags == 2) { - file_path = Local_Storage::get_user_appdata_path() + "7" + PATH_SEPARATOR + Local_Storage::remote_storage_folder + "serverbrowser_history.txt"; + file_path = local_storage->get_current_save_directory() + "7" + PATH_SEPARATOR + Local_Storage::remote_storage_folder + "serverbrowser_history.txt"; file_size = file_size_(file_path); } else { diff --git a/dll/dll/steam_matchmaking_servers.h b/dll/dll/steam_matchmaking_servers.h index ea56c40f..61cd12a3 100644 --- a/dll/dll/steam_matchmaking_servers.h +++ b/dll/dll/steam_matchmaking_servers.h @@ -58,8 +58,9 @@ struct Steam_Matchmaking_Request { class Steam_Matchmaking_Servers : public ISteamMatchmakingServers, public ISteamMatchmakingServers001 { - class Settings *settings; - class Networking *network; + class Settings *settings{}; + class Local_Storage *local_storage{}; + class Networking *network{}; std::vector gameservers; std::vector gameservers_friends; @@ -68,7 +69,7 @@ public ISteamMatchmakingServers001 HServerListRequest RequestServerList(AppId_t iApp, ISteamMatchmakingServerListResponse *pRequestServersResponse, EMatchMakingType type); void RequestOldServerList(AppId_t iApp, ISteamMatchmakingServerListResponse001 *pRequestServersResponse, EMatchMakingType type); public: - Steam_Matchmaking_Servers(class Settings *settings, class Networking *network); + Steam_Matchmaking_Servers(class Settings *settings, class Local_Storage *local_storage, class Networking *network); ~Steam_Matchmaking_Servers(); // Request a new list of servers of a particular type. These calls each correspond to one of the EMatchMakingType values. diff --git a/dll/steam_client.cpp b/dll/steam_client.cpp index 16756313..c6ef3fe7 100644 --- a/dll/steam_client.cpp +++ b/dll/steam_client.cpp @@ -119,8 +119,8 @@ Steam_Client::Steam_Client() ugc_bridge = new Ugc_Remote_Storage_Bridge(settings_client); - steam_matchmaking = new Steam_Matchmaking(settings_client, network, callback_results_client, callbacks_client, run_every_runcb); - steam_matchmaking_servers = new Steam_Matchmaking_Servers(settings_client, network); + steam_matchmaking = new Steam_Matchmaking(settings_client, local_storage, network, callback_results_client, callbacks_client, run_every_runcb); + steam_matchmaking_servers = new Steam_Matchmaking_Servers(settings_client, local_storage, network); steam_user_stats = new Steam_User_Stats(settings_client, network, local_storage, callback_results_client, callbacks_client, run_every_runcb, steam_overlay); steam_apps = new Steam_Apps(settings_client, callback_results_client, callbacks_client); steam_networking = new Steam_Networking(settings_client, network, callbacks_client, run_every_runcb); diff --git a/dll/steam_matchmaking_servers.cpp b/dll/steam_matchmaking_servers.cpp index 643edd88..e69813e3 100644 --- a/dll/steam_matchmaking_servers.cpp +++ b/dll/steam_matchmaking_servers.cpp @@ -26,9 +26,10 @@ static void network_callback(void *object, Common_Message *msg) obj->Callback(msg); } -Steam_Matchmaking_Servers::Steam_Matchmaking_Servers(class Settings *settings, class Networking *network) +Steam_Matchmaking_Servers::Steam_Matchmaking_Servers(class Settings *settings, class Local_Storage *local_storage, class Networking *network) { this->settings = settings; + this->local_storage = local_storage; this->network = network; this->network->setCallback(CALLBACK_ID_GAMESERVER, (uint64) 0, &network_callback, this); } @@ -88,13 +89,13 @@ HServerListRequest Steam_Matchmaking_Servers::RequestServerList(AppId_t iApp, IS std::string file_path; unsigned long long file_size; if (type == eInternetServer || type == eSpectatorServer) { - file_path = Local_Storage::get_user_appdata_path() + "7" + PATH_SEPARATOR + Local_Storage::remote_storage_folder + PATH_SEPARATOR + "serverbrowser.txt"; + file_path = local_storage->get_current_save_directory() + "7" + PATH_SEPARATOR + Local_Storage::remote_storage_folder + PATH_SEPARATOR + "serverbrowser.txt"; file_size = file_size_(file_path); } else if (type == eFavoritesServer) { - file_path = Local_Storage::get_user_appdata_path() + "7" + PATH_SEPARATOR + Local_Storage::remote_storage_folder + PATH_SEPARATOR + "serverbrowser_favorites.txt"; + file_path = local_storage->get_current_save_directory() + "7" + PATH_SEPARATOR + Local_Storage::remote_storage_folder + PATH_SEPARATOR + "serverbrowser_favorites.txt"; file_size = file_size_(file_path); } else if (type == eHistoryServer) { - file_path = Local_Storage::get_user_appdata_path() + "7" + PATH_SEPARATOR + Local_Storage::remote_storage_folder + PATH_SEPARATOR + "serverbrowser_history.txt"; + file_path = local_storage->get_current_save_directory() + "7" + PATH_SEPARATOR + Local_Storage::remote_storage_folder + PATH_SEPARATOR + "serverbrowser_history.txt"; file_size = file_size_(file_path); }