From 84b477200606038304f64012d2e9f98ffefbb613 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Wed, 14 Sep 2022 02:39:55 +0200 Subject: [PATCH] Refresh server list when the browser is activated --- r5dev/gameui/IBrowser.cpp | 18 +++++++++++++++--- r5dev/gameui/IBrowser.h | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/r5dev/gameui/IBrowser.cpp b/r5dev/gameui/IBrowser.cpp index 2620d3eb..971f6972 100644 --- a/r5dev/gameui/IBrowser.cpp +++ b/r5dev/gameui/IBrowser.cpp @@ -43,9 +43,6 @@ CBrowser::CBrowser(void) { memset(m_szServerAddressBuffer, '\0', sizeof(m_szServerAddressBuffer)); - std::thread refresh(&CBrowser::RefreshServerList, this); - refresh.detach(); - m_pszBrowserTitle = "Server Browser"; m_rLockedIconBlob = GetModuleResource(IDB_PNG2); } @@ -136,6 +133,21 @@ void CBrowser::RunTask() UpdateHostingStatus(); timer.Start(); } + + if (m_bActivate) + { + if (m_bQueryListNonRecursive) + { + std::thread refresh(&CBrowser::RefreshServerList, g_pBrowser); + refresh.detach(); + + m_bQueryListNonRecursive = false; + } + } + else // Refresh server list the next time 'm_bActivate' evaluates to true. + { + m_bQueryListNonRecursive = true; + } } //----------------------------------------------------------------------------- diff --git a/r5dev/gameui/IBrowser.h b/r5dev/gameui/IBrowser.h index b906a243..917c3de8 100644 --- a/r5dev/gameui/IBrowser.h +++ b/r5dev/gameui/IBrowser.h @@ -42,6 +42,7 @@ public: private: bool m_bInitialized = false; + bool m_bQueryListNonRecursive = false; // When set, refreshes the server list once the next frame. char m_szServerAddressBuffer[256] = { '\0' }; char m_szServerEncKeyBuffer[30] = { '\0' }; float m_flFadeAlpha = 0.f;