[Friends] Transmit ingame name

This commit is contained in:
momo5502 2017-01-31 17:04:54 +01:00
parent 538724f67e
commit 8dd86043dc
3 changed files with 47 additions and 8 deletions

View File

@ -159,6 +159,7 @@ namespace Components
else
{
lastValidName = name;
Friends::UpdateName();
}
});

View File

@ -2,6 +2,7 @@
namespace Components
{
bool Friends::TriggerUpdate = false;
int Friends::InitialState;
unsigned int Friends::CurrentFriend;
std::recursive_mutex Friends::Mutex;
@ -99,14 +100,21 @@ namespace Components
Friends::SortList();
}
void Friends::UpdateState()
void Friends::UpdateState(bool force)
{
if(Steam::Proxy::SteamLegacyFriends)
if(force)
{
if (Steam::Proxy::SteamLegacyFriends)
{
int state = Steam::Proxy::SteamLegacyFriends->GetPersonaState();
Steam::Proxy::SteamLegacyFriends->SetPersonaState((state == 1 ? 2 : 1));
}
}
else
{
Friends::TriggerUpdate = true;
}
}
void Friends::UpdateHostname(Network::Address server, std::string hostname)
{
@ -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:
{
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<bool*>(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();
});

View File

@ -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<Friend>* list);