[Friends] Fix fps drops

This commit is contained in:
momo5502 2017-01-31 20:58:12 +01:00
parent 9b462469da
commit 29b3acfacb
2 changed files with 21 additions and 3 deletions

View File

@ -354,7 +354,7 @@ namespace Components
void Friends::UpdateTimeStamp() 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) bool Friends::IsOnline(unsigned __int64 timeStamp)
@ -362,7 +362,7 @@ namespace Components
if (!Steam::Proxy::SteamUtils) return false; if (!Steam::Proxy::SteamUtils) return false;
static const unsigned __int64 duration = std::chrono::duration_cast<std::chrono::seconds>(5min).count(); static const unsigned __int64 duration = std::chrono::duration_cast<std::chrono::seconds>(5min).count();
return ((Steam::Proxy::SteamUtils->GetServerRealTime() - timeStamp) < duration); return ((Steam::SteamUtils()->GetServerRealTime() - timeStamp) < duration);
} }
void Friends::StoreFriendsList() void Friends::StoreFriendsList()
@ -386,6 +386,8 @@ namespace Components
Friends::Friends() Friends::Friends()
{ {
if (Dedicated::IsEnabled() ||ZoneBuilder::IsEnabled()) return;
// Callback to update user information // Callback to update user information
Steam::Proxy::RegisterCallback(336, [](void* data) Steam::Proxy::RegisterCallback(336, [](void* data)
{ {
@ -505,6 +507,8 @@ namespace Components
Friends::~Friends() Friends::~Friends()
{ {
if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled()) return;
Friends::StoreFriendsList(); Friends::StoreFriendsList();
Steam::Proxy::UnregisterCallback(336); Steam::Proxy::UnregisterCallback(336);

View File

@ -21,7 +21,21 @@ namespace Steam
unsigned int Utils::GetServerRealTime() unsigned int Utils::GetServerRealTime()
{ {
return 0; static ::Utils::Value<unsigned int> timeDelta;
if(!timeDelta.isValid())
{
unsigned int steamTime = static_cast<unsigned int>(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() const char* Utils::GetIPCountry()