[Friends] Correctly display the rank

This commit is contained in:
momo5502 2017-01-26 12:42:42 +01:00
parent 5f737f0d36
commit 0f91c50ffc
4 changed files with 24 additions and 12 deletions

View File

@ -27,6 +27,8 @@ namespace Components
userInfo.online = Steam::Proxy::SteamFriends->GetFriendPersonaState(user) != 0;
userInfo.name = Steam::Proxy::SteamFriends->GetFriendPersonaName(user);
userInfo.statusName = Steam::Proxy::SteamFriends->GetFriendRichPresence(user, "iw4x_status");
userInfo.prestige = Utils::Cryptography::Rand::GenerateInt() % (10 + 1);
userInfo.experience = Utils::Cryptography::Rand::GenerateInt() % (2516000 + 1);
//if (!userInfo.online) return;
@ -100,25 +102,25 @@ namespace Components
case 0:
{
static char buffer[0x100];
ZeroMemory(buffer, sizeof(buffer));
std::string rankIcon = "rank_prestige9";
std::string result = "^\x02";
Game::Material* rankIcon = nullptr;
int rank = Game::CL_GetRankForXP(user.experience);
Game::CL_GetRankIcon(rank, user.prestige, &rankIcon);
char size = 0x30;
buffer[0] = '^';
buffer[1] = 2;
// Icon size
result.append(&size, 1);
result.append(&size, 1);
char size = 0x30;
buffer[2] = size; // Width
buffer[3] = size; // Height
// Icon name length
size = static_cast<char>(rankIcon.size());
result.append(&size, 1);
buffer[4] = static_cast<char>(strlen(rankIcon->name));
result.append(rankIcon);
result.append(" 70");
std::memcpy(buffer, result.data(), std::min(result.size() + 1, sizeof(buffer)));
buffer[sizeof(buffer) - 1] = 0;
strcat_s(buffer, rankIcon->name);
strcat_s(buffer, Utils::String::VA(" %i", rank));
return buffer;
}

View File

@ -35,6 +35,8 @@ namespace Components
Network::Address server;
std::string statusName;
bool online;
int experience;
int prestige;
};
static unsigned int CurrentFriend;

View File

@ -14,6 +14,8 @@ namespace Game
CL_ConnectFromParty_t CL_ConnectFromParty = CL_ConnectFromParty_t(0x433D30);
CL_DownloadsComplete_t CL_DownloadsComplete = CL_DownloadsComplete_t(0x42CE90);
CL_DrawStretchPicPhysical_t CL_DrawStretchPicPhysical = CL_DrawStretchPicPhysical_t(0x4FC120);
CL_GetRankForXP_t CL_GetRankForXP = CL_GetRankForXP_t(0x4FF8A0);
CL_GetRankIcon_t CL_GetRankIcon = CL_GetRankIcon_t(0x4A7B30);
CL_HandleRelayPacket_t CL_HandleRelayPacket = CL_HandleRelayPacket_t(0x5A8C70);
CL_ResetViewport_t CL_ResetViewport = CL_ResetViewport_t(0x4A8830);
CL_SelectStringTableEntryInDvar_f_t CL_SelectStringTableEntryInDvar_f = CL_SelectStringTableEntryInDvar_f_t(0x4A4560);

View File

@ -29,6 +29,12 @@ namespace Game
typedef void(_cdecl * CL_DrawStretchPicPhysical_t)(float x, float y, float w, float h, float xScale, float yScale, float xay, float yay, const float *color, Game::Material* material);
extern CL_DrawStretchPicPhysical_t CL_DrawStretchPicPhysical;
typedef int(_cdecl* CL_GetRankForXP_t)(int xp);
extern CL_GetRankForXP_t CL_GetRankForXP;
typedef void(__cdecl * CL_GetRankIcon_t)(int level, int prestige, Material** material);
extern CL_GetRankIcon_t CL_GetRankIcon;
typedef void(__cdecl * CL_HandleRelayPacket_t)(Game::msg_t* msg, int client);
extern CL_HandleRelayPacket_t CL_HandleRelayPacket;