diff --git a/src/Components/Modules/Friends.cpp b/src/Components/Modules/Friends.cpp index 2fbe52ad..ead47cff 100644 --- a/src/Components/Modules/Friends.cpp +++ b/src/Components/Modules/Friends.cpp @@ -354,7 +354,7 @@ namespace Components void Friends::UpdateTimeStamp() { - Friends::SetPresence("iw4x_playing", Utils::String::VA("%d", Steam::Proxy::SteamUtils->GetServerRealTime())); + Friends::SetPresence("iw4x_playing", Utils::String::VA("%d", Steam::SteamUtils()->GetServerRealTime())); } bool Friends::IsOnline(unsigned __int64 timeStamp) @@ -362,7 +362,7 @@ namespace Components if (!Steam::Proxy::SteamUtils) return false; static const unsigned __int64 duration = std::chrono::duration_cast(5min).count(); - return ((Steam::Proxy::SteamUtils->GetServerRealTime() - timeStamp) < duration); + return ((Steam::SteamUtils()->GetServerRealTime() - timeStamp) < duration); } void Friends::StoreFriendsList() @@ -386,6 +386,8 @@ namespace Components Friends::Friends() { + if (Dedicated::IsEnabled() ||ZoneBuilder::IsEnabled()) return; + // Callback to update user information Steam::Proxy::RegisterCallback(336, [](void* data) { @@ -505,6 +507,8 @@ namespace Components Friends::~Friends() { + if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled()) return; + Friends::StoreFriendsList(); Steam::Proxy::UnregisterCallback(336); diff --git a/src/Steam/Interfaces/SteamUtils.cpp b/src/Steam/Interfaces/SteamUtils.cpp index 66fda75e..2cef4a6b 100644 --- a/src/Steam/Interfaces/SteamUtils.cpp +++ b/src/Steam/Interfaces/SteamUtils.cpp @@ -21,7 +21,21 @@ namespace Steam unsigned int Utils::GetServerRealTime() { - return 0; + static ::Utils::Value timeDelta; + + if(!timeDelta.isValid()) + { + unsigned int steamTime = static_cast(time(nullptr)); + + if(Steam::Proxy::SteamUtils) + { + steamTime = Steam::Proxy::SteamUtils->GetServerRealTime(); + } + + timeDelta.set(steamTime - (Game::Sys_Milliseconds() / 1000)); + } + + return timeDelta.get() + (Game::Sys_Milliseconds() / 1000); } const char* Utils::GetIPCountry()