From cd56398a7f27083f5becf827157a5fa5ef288f89 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sat, 18 Feb 2017 17:55:56 +0100 Subject: [PATCH] [Proxy] Wait till logged in with timeout --- src/Steam/Proxy.cpp | 20 ++++++++++++++++++-- src/Steam/Proxy.hpp | 4 ++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/Steam/Proxy.cpp b/src/Steam/Proxy.cpp index 87a81fcb..d0db2eff 100644 --- a/src/Steam/Proxy.cpp +++ b/src/Steam/Proxy.cpp @@ -312,7 +312,8 @@ namespace Steam ShellExecuteA(nullptr, nullptr, steamExe.data(), "-silent", nullptr, 1); - std::this_thread::sleep_for(10s); + ::Utils::Time::Interval interval; + while(!interval.elapsed(15s) && !Proxy::GetActiveUser()) std::this_thread::sleep_for(10ms); } } @@ -323,7 +324,7 @@ namespace Steam SetDllDirectoryA(Proxy::GetSteamDirectory().data()); - if (!Components::Dedicated::IsEnabled() || !Components::ZoneBuilder::IsEnabled()) + if (!Components::Dedicated::IsEnabled() && !Components::ZoneBuilder::IsEnabled()) { Proxy::StartSteamIfNecessary(); @@ -408,6 +409,21 @@ namespace Steam return ""; } + uint32_t Proxy::GetActiveUser() + { + HKEY hRegKey; + uint32_t activeUser = 0; + + if (RegOpenKeyExA(HKEY_CURRENT_USER, STEAM_REGISTRY_PROCESS_PATH, 0, KEY_QUERY_VALUE, &hRegKey) == ERROR_SUCCESS) + { + DWORD dwLength = sizeof(activeUser); + RegQueryValueExA(hRegKey, "ActiveUser", nullptr, nullptr, reinterpret_cast(&activeUser), &dwLength); + RegCloseKey(hRegKey); + } + + return activeUser; + } + void Proxy::SetOverlayNotificationPosition(uint32_t eNotificationPosition) { if (Proxy::Overlay.valid()) diff --git a/src/Steam/Proxy.hpp b/src/Steam/Proxy.hpp index 34672ff1..d3344652 100644 --- a/src/Steam/Proxy.hpp +++ b/src/Steam/Proxy.hpp @@ -185,8 +185,6 @@ namespace Steam static bool Inititalize(); static void Uninititalize(); - static void StartSteamIfNecessary(); - static void SetGame(uint32_t appId); static void RunGame(); @@ -255,7 +253,9 @@ namespace Steam static void RunCallback(int32_t callId, void* data, size_t size); static void UnregisterCalls(); + static void StartSteamIfNecessary(); + static uint32_t GetActiveUser(); static std::string GetSteamDirectory(); }; }