[Proxy] Wait till logged in with timeout

This commit is contained in:
momo5502 2017-02-18 17:55:56 +01:00
parent 1764708d6f
commit cd56398a7f
2 changed files with 20 additions and 4 deletions

View File

@ -312,7 +312,8 @@ namespace Steam
ShellExecuteA(nullptr, nullptr, steamExe.data(), "-silent", nullptr, 1); 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()); SetDllDirectoryA(Proxy::GetSteamDirectory().data());
if (!Components::Dedicated::IsEnabled() || !Components::ZoneBuilder::IsEnabled()) if (!Components::Dedicated::IsEnabled() && !Components::ZoneBuilder::IsEnabled())
{ {
Proxy::StartSteamIfNecessary(); Proxy::StartSteamIfNecessary();
@ -408,6 +409,21 @@ namespace Steam
return ""; 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<BYTE*>(&activeUser), &dwLength);
RegCloseKey(hRegKey);
}
return activeUser;
}
void Proxy::SetOverlayNotificationPosition(uint32_t eNotificationPosition) void Proxy::SetOverlayNotificationPosition(uint32_t eNotificationPosition)
{ {
if (Proxy::Overlay.valid()) if (Proxy::Overlay.valid())

View File

@ -185,8 +185,6 @@ namespace Steam
static bool Inititalize(); static bool Inititalize();
static void Uninititalize(); static void Uninititalize();
static void StartSteamIfNecessary();
static void SetGame(uint32_t appId); static void SetGame(uint32_t appId);
static void RunGame(); static void RunGame();
@ -255,7 +253,9 @@ namespace Steam
static void RunCallback(int32_t callId, void* data, size_t size); static void RunCallback(int32_t callId, void* data, size_t size);
static void UnregisterCalls(); static void UnregisterCalls();
static void StartSteamIfNecessary();
static uint32_t GetActiveUser();
static std::string GetSteamDirectory(); static std::string GetSteamDirectory();
}; };
} }