diff --git a/src/Components/Modules/Dvar.cpp b/src/Components/Modules/Dvar.cpp index 247f46d3..cf7b66bd 100644 --- a/src/Components/Modules/Dvar.cpp +++ b/src/Components/Modules/Dvar.cpp @@ -159,6 +159,7 @@ namespace Components else { lastValidName = name; + Friends::UpdateName(); } }); diff --git a/src/Components/Modules/Friends.cpp b/src/Components/Modules/Friends.cpp index 5b2114e9..736019b2 100644 --- a/src/Components/Modules/Friends.cpp +++ b/src/Components/Modules/Friends.cpp @@ -2,6 +2,7 @@ namespace Components { + bool Friends::TriggerUpdate = false; int Friends::InitialState; unsigned int Friends::CurrentFriend; std::recursive_mutex Friends::Mutex; @@ -99,12 +100,19 @@ namespace Components Friends::SortList(); } - void Friends::UpdateState() + void Friends::UpdateState(bool force) { - if(Steam::Proxy::SteamLegacyFriends) + if(force) { - int state = Steam::Proxy::SteamLegacyFriends->GetPersonaState(); - Steam::Proxy::SteamLegacyFriends->SetPersonaState((state == 1 ? 2 : 1)); + if (Steam::Proxy::SteamLegacyFriends) + { + int state = Steam::Proxy::SteamLegacyFriends->GetPersonaState(); + Steam::Proxy::SteamLegacyFriends->SetPersonaState((state == 1 ? 2 : 1)); + } + } + else + { + Friends::TriggerUpdate = true; } } @@ -121,6 +129,12 @@ namespace Components } } + void Friends::UpdateName() + { + Friends::SetPresence("iw4x_name", Steam::SteamFriends()->GetPersonaName()); + Friends::UpdateState(); + } + void Friends::ClearPresence(std::string key) { if (Steam::Proxy::SteamFriends) @@ -263,8 +277,16 @@ namespace Components return buffer; } case 1: - return Utils::String::VA("%s", user.name.data()); - + { + if (user.playerName.empty()) + { + return Utils::String::VA("%s", user.name.data()); + } + else + { + return Utils::String::VA("%s ^7(%s^7)", user.name.data(), user.playerName.data()); + } + } case 2: { if (!user.online) return "Offline"; @@ -362,6 +384,19 @@ namespace Components QuickPatch::OnFrame([]() { + static Utils::Time::Interval interval; + + if(interval.elapsed(5s)) + { + interval.update(); + + if(Friends::TriggerUpdate) + { + Friends::TriggerUpdate = false; + Friends::UpdateState(true); + } + } + if(*reinterpret_cast(0x1AD5690)) // LiveStorage_DoWeHaveStats { Friends::UpdateRank(); @@ -394,7 +429,8 @@ namespace Components Friends::SetPresence("iw4x_guid", Utils::String::VA("%llX", Steam::SteamUser()->GetSteamID().Bits)); Friends::UpdateTimeStamp(); - //Friends::UpdateState(); // Don't update state yet, stats will do that + Friends::UpdateName(); + Friends::UpdateState(); Friends::UpdateFriends(); }); diff --git a/src/Components/Modules/Friends.hpp b/src/Components/Modules/Friends.hpp index e0d23848..dd9a70e8 100644 --- a/src/Components/Modules/Friends.hpp +++ b/src/Components/Modules/Friends.hpp @@ -15,6 +15,7 @@ namespace Components static void UpdateFriends(); static void UpdateRank(); static void UpdateHostname(Network::Address server, std::string hostname); + static void UpdateName(); static void SetPresence(std::string key, std::string value); static void ClearPresence(std::string key); @@ -49,6 +50,7 @@ namespace Components int prestige; }; + static bool TriggerUpdate; static int InitialState; static unsigned int CurrentFriend; static std::recursive_mutex Mutex; @@ -61,7 +63,7 @@ namespace Components static bool IsClientInParty(int controller, int clientNum); static void UpdateUserInfo(SteamID user); - static void UpdateState(); + static void UpdateState(bool force = false); static void SortList(); static void SortIndividualList(std::vector* list);