diff --git a/src/Components/Modules/Friends.cpp b/src/Components/Modules/Friends.cpp index 4b5dfcaf..932313cc 100644 --- a/src/Components/Modules/Friends.cpp +++ b/src/Components/Modules/Friends.cpp @@ -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(rankIcon.size()); - result.append(&size, 1); + buffer[4] = static_cast(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; } diff --git a/src/Components/Modules/Friends.hpp b/src/Components/Modules/Friends.hpp index 203be799..b4abf082 100644 --- a/src/Components/Modules/Friends.hpp +++ b/src/Components/Modules/Friends.hpp @@ -35,6 +35,8 @@ namespace Components Network::Address server; std::string statusName; bool online; + int experience; + int prestige; }; static unsigned int CurrentFriend; diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index e53fa8a6..fbe31b93 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -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); diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 053e5414..ae0c44f5 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -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;