[Friends] Optimize sorting
This commit is contained in:
parent
d31ff2e180
commit
5798de30be
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
|
bool Friends::TriggerSort = false;
|
||||||
bool Friends::TriggerUpdate = false;
|
bool Friends::TriggerUpdate = false;
|
||||||
|
|
||||||
int Friends::InitialState;
|
int Friends::InitialState;
|
||||||
unsigned int Friends::CurrentFriend;
|
unsigned int Friends::CurrentFriend;
|
||||||
std::recursive_mutex Friends::Mutex;
|
std::recursive_mutex Friends::Mutex;
|
||||||
@ -15,15 +17,18 @@ namespace Components
|
|||||||
const Friends::Friend* friend1 = static_cast<const Friends::Friend*>(first);
|
const Friends::Friend* friend1 = static_cast<const Friends::Friend*>(first);
|
||||||
const Friends::Friend* friend2 = static_cast<const Friends::Friend*>(second);
|
const Friends::Friend* friend2 = static_cast<const Friends::Friend*>(second);
|
||||||
|
|
||||||
std::string name1 = Utils::String::ToLower(Colors::Strip(friend1->name));
|
return friend1->cleanName.compare(friend2->cleanName);
|
||||||
std::string name2 = Utils::String::ToLower(Colors::Strip(friend2->name));
|
|
||||||
|
|
||||||
return name1.compare(name2);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Friends::SortList()
|
void Friends::SortList(bool force)
|
||||||
{
|
{
|
||||||
|
if(!force)
|
||||||
|
{
|
||||||
|
Friends::TriggerSort = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::lock_guard<std::recursive_mutex> _(Friends::Mutex);
|
std::lock_guard<std::recursive_mutex> _(Friends::Mutex);
|
||||||
|
|
||||||
std::vector<Friends::Friend> connectedList;
|
std::vector<Friends::Friend> connectedList;
|
||||||
@ -68,6 +73,7 @@ namespace Components
|
|||||||
|
|
||||||
entry->name = Steam::Proxy::SteamFriends->GetFriendPersonaName(user);
|
entry->name = Steam::Proxy::SteamFriends->GetFriendPersonaName(user);
|
||||||
entry->online = Steam::Proxy::SteamFriends->GetFriendPersonaState(user) != 0;
|
entry->online = Steam::Proxy::SteamFriends->GetFriendPersonaState(user) != 0;
|
||||||
|
entry->cleanName = Utils::String::ToLower(Colors::Strip(entry->name));
|
||||||
|
|
||||||
std::string guid = Steam::Proxy::SteamFriends->GetFriendRichPresence(user, "iw4x_guid");
|
std::string guid = Steam::Proxy::SteamFriends->GetFriendRichPresence(user, "iw4x_guid");
|
||||||
std::string name = Steam::Proxy::SteamFriends->GetFriendRichPresence(user, "iw4x_name");
|
std::string name = Steam::Proxy::SteamFriends->GetFriendRichPresence(user, "iw4x_name");
|
||||||
@ -426,10 +432,19 @@ namespace Components
|
|||||||
QuickPatch::OnFrame([]()
|
QuickPatch::OnFrame([]()
|
||||||
{
|
{
|
||||||
static Utils::Time::Interval interval;
|
static Utils::Time::Interval interval;
|
||||||
|
static Utils::Time::Interval sortInterval;
|
||||||
|
static Utils::Time::Interval stateInterval;
|
||||||
|
|
||||||
if(interval.elapsed(5s))
|
if (interval.elapsed(2min))
|
||||||
{
|
{
|
||||||
interval.update();
|
interval.update();
|
||||||
|
Friends::UpdateTimeStamp();
|
||||||
|
Friends::UpdateState();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(stateInterval.elapsed(5s))
|
||||||
|
{
|
||||||
|
stateInterval.update();
|
||||||
|
|
||||||
if(Friends::TriggerUpdate)
|
if(Friends::TriggerUpdate)
|
||||||
{
|
{
|
||||||
@ -438,6 +453,17 @@ namespace Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(sortInterval.elapsed(3s))
|
||||||
|
{
|
||||||
|
stateInterval.update();
|
||||||
|
|
||||||
|
if (Friends::TriggerSort)
|
||||||
|
{
|
||||||
|
Friends::TriggerSort = false;
|
||||||
|
Friends::SortList(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(*reinterpret_cast<bool*>(0x1AD5690)) // LiveStorage_DoWeHaveStats
|
if(*reinterpret_cast<bool*>(0x1AD5690)) // LiveStorage_DoWeHaveStats
|
||||||
{
|
{
|
||||||
Friends::UpdateRank();
|
Friends::UpdateRank();
|
||||||
@ -475,18 +501,6 @@ namespace Components
|
|||||||
|
|
||||||
Friends::UpdateFriends();
|
Friends::UpdateFriends();
|
||||||
});
|
});
|
||||||
|
|
||||||
QuickPatch::OnFrame([]()
|
|
||||||
{
|
|
||||||
static Utils::Time::Interval interval;
|
|
||||||
|
|
||||||
if(interval.elapsed(2min))
|
|
||||||
{
|
|
||||||
interval.update();
|
|
||||||
Friends::UpdateTimeStamp();
|
|
||||||
Friends::UpdateState();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Friends::~Friends()
|
Friends::~Friends()
|
||||||
|
@ -42,6 +42,7 @@ namespace Components
|
|||||||
SteamID guid;
|
SteamID guid;
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string playerName;
|
std::string playerName;
|
||||||
|
std::string cleanName;
|
||||||
Network::Address server;
|
Network::Address server;
|
||||||
std::string serverName;
|
std::string serverName;
|
||||||
bool online;
|
bool online;
|
||||||
@ -50,6 +51,7 @@ namespace Components
|
|||||||
int prestige;
|
int prestige;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool TriggerSort;
|
||||||
static bool TriggerUpdate;
|
static bool TriggerUpdate;
|
||||||
static int InitialState;
|
static int InitialState;
|
||||||
static unsigned int CurrentFriend;
|
static unsigned int CurrentFriend;
|
||||||
@ -65,7 +67,7 @@ namespace Components
|
|||||||
static void UpdateUserInfo(SteamID user);
|
static void UpdateUserInfo(SteamID user);
|
||||||
static void UpdateState(bool force = false);
|
static void UpdateState(bool force = false);
|
||||||
|
|
||||||
static void SortList();
|
static void SortList(bool force = false);
|
||||||
static void SortIndividualList(std::vector<Friend>* list);
|
static void SortIndividualList(std::vector<Friend>* list);
|
||||||
|
|
||||||
static unsigned int GetFriendCount();
|
static unsigned int GetFriendCount();
|
||||||
|
Loading…
Reference in New Issue
Block a user