From 794469c4cf103ccdfd9644d8b18fb7b45fbfcad6 Mon Sep 17 00:00:00 2001 From: Mr_Goldberg Date: Sat, 1 Jun 2019 13:11:27 -0400 Subject: [PATCH] Create lobby even if the run callbacks function is never run. --- dll/steam_client.cpp | 15 ++++++++------- dll/steam_client.h | 2 +- dll/steam_friends.h | 1 + dll/steam_matchmaking.h | 8 ++++++-- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/dll/steam_client.cpp b/dll/steam_client.cpp index be7c378e..2e5c5ca3 100644 --- a/dll/steam_client.cpp +++ b/dll/steam_client.cpp @@ -19,21 +19,22 @@ #include -static void network_thread(Networking *network) +static void background_thread(Steam_Client *client) { - PRINT_DEBUG("network thread starting\n"); + PRINT_DEBUG("background thread starting\n"); while (1) { std::this_thread::sleep_for(std::chrono::seconds(1)); global_mutex.lock(); - if (!network->isAlive()) { + if (!client->network->isAlive()) { global_mutex.unlock(); //delete network; - PRINT_DEBUG("network thread exit\n"); + PRINT_DEBUG("background thread exit\n"); return; } - PRINT_DEBUG("network thread run\n"); - network->Run(); + PRINT_DEBUG("background thread run\n"); + client->network->Run(); + client->steam_matchmaking->RunBackground(); global_mutex.unlock(); } } @@ -1672,7 +1673,7 @@ void Steam_Client::UnregisterCallResult( class CCallbackBase *pCallback, SteamAP void Steam_Client::RunCallbacks(bool runClientCB, bool runGameserverCB) { std::lock_guard lock(global_mutex); - if (!network_keepalive.joinable()) network_keepalive = std::thread(network_thread, network); + if (!background_keepalive.joinable()) background_keepalive = std::thread(background_thread, this); network->Run(); PRINT_DEBUG("Steam_Client::RunCallbacks steam_matchmaking_servers\n"); diff --git a/dll/steam_client.h b/dll/steam_client.h index 0f208ea8..08803e65 100644 --- a/dll/steam_client.h +++ b/dll/steam_client.h @@ -115,7 +115,7 @@ public: bool user_logged_in = false; bool server_init = false; - std::thread network_keepalive; + std::thread background_keepalive; Steam_Client(); ~Steam_Client(); diff --git a/dll/steam_friends.h b/dll/steam_friends.h index e63f63db..039b5a17 100644 --- a/dll/steam_friends.h +++ b/dll/steam_friends.h @@ -462,6 +462,7 @@ CSteamID GetFriendFromSourceByIndex( CSteamID steamIDSource, int iFriend ) bool IsUserInSource( CSteamID steamIDUser, CSteamID steamIDSource ) { PRINT_DEBUG("Steam_Friends::IsUserInSource %llu %llu\n", steamIDUser.ConvertToUint64(), steamIDSource.ConvertToUint64()); + std::lock_guard lock(global_mutex); if (steamIDUser == settings->get_local_steam_id()) { if (settings->get_lobby() == steamIDSource) { return true; diff --git a/dll/steam_matchmaking.h b/dll/steam_matchmaking.h index 1c65a279..e822da71 100644 --- a/dll/steam_matchmaking.h +++ b/dll/steam_matchmaking.h @@ -1115,8 +1115,7 @@ bool SetLinkedLobby( CSteamID steamIDLobby, CSteamID steamIDLobbyDependent ) return false; } - -void RunCallbacks() +void RunBackground() { remove_lobbies(); Create_pending_lobbies(); @@ -1125,6 +1124,11 @@ void RunCallbacks() send_lobby_data(); last_sent_lobbies = std::chrono::high_resolution_clock::now(); } +} + +void RunCallbacks() +{ + RunBackground(); if (searching) { PRINT_DEBUG("Searching for lobbies %zu\n", lobbies.size());