From 9bf1934083ee9725745f67a3fde89d8050dfe5ae Mon Sep 17 00:00:00 2001 From: momo5502 Date: Tue, 31 Jan 2017 15:35:34 +0100 Subject: [PATCH] [Friends] Use correct duration cast to determine online state --- src/Components/Modules/Friends.cpp | 7 +++++-- src/Components/Modules/Friends.hpp | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Components/Modules/Friends.cpp b/src/Components/Modules/Friends.cpp index 4f31add0..b4de705a 100644 --- a/src/Components/Modules/Friends.cpp +++ b/src/Components/Modules/Friends.cpp @@ -305,9 +305,12 @@ namespace Components Friends::SetPresence("iw4x_playing", Utils::String::VA("%d", Steam::Proxy::SteamUtils->GetServerRealTime())); } - bool Friends::IsOnline(unsigned int ts) + bool Friends::IsOnline(unsigned __int64 timeStamp) { - return (Steam::Proxy::SteamUtils && ((Steam::Proxy::SteamUtils->GetServerRealTime() - ts) <= 5 * 60)); // % minutes + if (!Steam::Proxy::SteamUtils) return false; + static const unsigned __int64 duration = std::chrono::duration_cast(5min).count(); + + return ((Steam::Proxy::SteamUtils->GetServerRealTime() - timeStamp) < duration); } Friends::Friends() diff --git a/src/Components/Modules/Friends.hpp b/src/Components/Modules/Friends.hpp index cf598c56..e0d23848 100644 --- a/src/Components/Modules/Friends.hpp +++ b/src/Components/Modules/Friends.hpp @@ -72,6 +72,6 @@ namespace Components static void UpdateTimeStamp(); - static bool IsOnline(unsigned int ts); + static bool IsOnline(unsigned __int64 timeStamp); }; }