don't use global appdata path in matchmaking + matchmaking_servers, instead used current/active save directory, in case we're using local_save_path

This commit is contained in:
otavepto 2024-04-23 02:13:51 +02:00
parent 425baa4e2a
commit 68a65696e5
4 changed files with 19 additions and 15 deletions

View File

@ -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 {

View File

@ -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 <struct Steam_Matchmaking_Servers_Gameserver> gameservers;
std::vector <struct Steam_Matchmaking_Servers_Gameserver_Friends> 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.

View File

@ -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);

View File

@ -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);
}