diff --git a/include/entitycache.hpp b/include/entitycache.hpp index 5211934e..8c6add05 100644 --- a/include/entitycache.hpp +++ b/include/entitycache.hpp @@ -201,7 +201,6 @@ public: bool m_bAnyHitboxVisible{ false }; bool m_bVisCheckComplete{ false }; - k_EItemType m_ItemType() { if (m_Type() == ENTITY_GENERIC) @@ -209,27 +208,20 @@ public: else return ITEM_NONE; }; - - unsigned long m_lSeenTicks{ 0 }; unsigned long m_lLastSeen{ 0 }; - Vector m_vecVOrigin{ 0 }; Vector m_vecVelocity{ 0 }; Vector m_vecAcceleration{ 0 }; - float m_fLastUpdate{ 0.0f }; hitbox_cache::EntityHitboxCache hitboxes; - player_info_s player_info{}; - Averager velocity_averager{ 8 }; + player_info_s *player_info = nullptr; void Reset() { m_bAnyHitboxVisible = false; m_bVisCheckComplete = false; m_lLastSeen = 0; - m_lSeenTicks = 0; - memset(&player_info, 0, sizeof(player_info_s)); + if (player_info) + memset(player_info, 0, sizeof(player_info_s)); m_vecAcceleration.Zero(); - m_vecVOrigin.Zero(); m_vecVelocity.Zero(); - m_fLastUpdate = 0; } bool was_dormant() diff --git a/scripts/migrations b/scripts/migrations index 93d06c5e..cad39ccc 100755 --- a/scripts/migrations +++ b/scripts/migrations @@ -55,7 +55,7 @@ function init() { # function updateRepoURL() { - local URL="https://github.com/STEVE4git/cathook/" + local URL="$(curl --max-time 10 -s -o /dev/null -w %{redirect_url} https://cathook.club/s/ch/git || echo error)" local GIT_REMOTE=$(git config --get remote.origin.url || echo unknown) if [ "$URL" != "error" ] && [ "$GIT_REMOTE" != "$URL" ]; then git remote set-url origin "$URL" && echo -e "\033[1;33m\n\nMigrations: Updated remote URL to new repo! Welcome to $URL!\n\n\033[0m" || : diff --git a/src/PlayerTools.cpp b/src/PlayerTools.cpp index 9c0edf25..8f2e5316 100644 --- a/src/PlayerTools.cpp +++ b/src/PlayerTools.cpp @@ -52,7 +52,7 @@ bool shouldTarget(CachedEntity *entity) // Don't shoot players in truce if (isTruce()) return false; - return shouldTargetSteamId(entity->player_info.friendsID); + return shouldTargetSteamId(entity->player_info->friendsID); } else if (entity->m_Type() == ENTITY_BUILDING) // Don't shoot buildings in truce @@ -75,7 +75,7 @@ bool shouldAlwaysRenderEsp(CachedEntity *entity) { if (entity->m_Type() == ENTITY_PLAYER) { - return shouldAlwaysRenderEspSteamId(entity->player_info.friendsID); + return shouldAlwaysRenderEspSteamId(entity->player_info->friendsID); } return false; @@ -95,9 +95,9 @@ std::optional forceEspColorSteamId(unsigned id) } std::optional forceEspColor(CachedEntity *entity) { - if (entity->m_Type() == ENTITY_PLAYER) + if (entity->m_Type() == ENTITY_PLAYER && entity->player_info) { - return forceEspColorSteamId(entity->player_info.friendsID); + return forceEspColorSteamId(entity->player_info->friendsID); } return std::nullopt; @@ -150,7 +150,7 @@ static CatCommand mark_betrayal("pl_mark_betrayal", "Mark a steamid32 as betraya void onKilledBy(CachedEntity *entity) { - onKilledBy(entity->player_info.friendsID); + onKilledBy(entity->player_info->friendsID); } class PlayerToolsEventListener : public IGameEventListener2 diff --git a/src/entitycache.cpp b/src/entitycache.cpp index 474e2266..f0e6f851 100644 --- a/src/entitycache.cpp +++ b/src/entitycache.cpp @@ -20,8 +20,7 @@ inline void CachedEntity::Update() return; } #endif - m_lSeenTicks = 0; - m_lLastSeen = 0; + m_lLastSeen = 0; hitboxes.InvalidateCache(); m_bVisCheckComplete = false; } @@ -31,10 +30,14 @@ inline CachedEntity::CachedEntity(u_int16_t idx) : m_IDX(idx), hitboxes(hitbox_c #if PROXY_ENTITY != true m_pEntity = nullptr; #endif - m_fLastUpdate = 0.0f; } -CachedEntity::~CachedEntity() +inline CachedEntity::~CachedEntity() { + if (player_info) + { + delete player_info; + player_info = 0; + } } static settings::Float ve_window{ "debug.ve.window", "0" }; static settings::Boolean ve_smooth{ "debug.ve.smooth", "true" }; @@ -75,6 +78,8 @@ void Update() u_int16_t current_ents = g_IEntityList->NumberOfEntities(false); valid_ents.clear(); // Reserving isn't necessary as this doesn't reallocate it player_cache.clear(); + if (g_Settings.bInvalid) + return; if (max >= MAX_ENTITIES) max = MAX_ENTITIES - 1; if (previous_max == max && previous_ent == current_ents) @@ -87,7 +92,7 @@ void Update() valid_ents.emplace_back(&val); if (val.m_Type() == ENTITY_PLAYER) { - GetPlayerInfo(val.m_IDX, &val.player_info); + GetPlayerInfo(val.m_IDX, val.player_info); if (val.m_bAlivePlayer()) [[likely]] { val.hitboxes.UpdateBones(); @@ -104,7 +109,7 @@ void Update() { for (u_int16_t i = 0; i <= max; ++i) { - if (g_Settings.bInvalid || !(g_IEntityList->GetClientEntity(i)) || !(g_IEntityList->GetClientEntity(i)->GetClientClass()->m_ClassID)) + if (!g_IEntityList->GetClientEntity(i) || !g_IEntityList->GetClientEntity(i)->GetClientClass()->m_ClassID) continue; CachedEntity &ent = array.try_emplace(i, CachedEntity{ i }).first->second; ent.Update(); @@ -113,7 +118,9 @@ void Update() valid_ents.emplace_back(&ent); if (ent.m_Type() == ENTITY_PLAYER) { - GetPlayerInfo(ent.m_IDX, &ent.player_info); + if (!ent.player_info) + ent.player_info = new player_info_s; + GetPlayerInfo(ent.m_IDX, ent.player_info); if (ent.m_bAlivePlayer()) [[likely]] { ent.hitboxes.UpdateBones(); diff --git a/src/hacks/Aimbot.cpp b/src/hacks/Aimbot.cpp index c55bbaf4..44aa5a9a 100644 --- a/src/hacks/Aimbot.cpp +++ b/src/hacks/Aimbot.cpp @@ -1199,9 +1199,9 @@ bool Aim(CachedEntity *entity) // Direct shots should just use normal vischeck if (30.0f < abs(z_vel)) { - float time = -1.0f * ((z_vel + fsqrt(z_vel * z_vel + 2.0f * diff * grav)) / grav); + float time = -1.0f * ((z_vel + sqrt(z_vel * z_vel + 2.0f * diff * grav)) / grav); if (!time) - time = -1.0f * ((z_vel * fsqrt(z_vel * z_vel + 2 * (LOCAL_E->hitboxes.GetHitbox(14)->center.z - orig.z) * grav)) / grav); + time = -1.0f * ((z_vel * sqrt(z_vel * z_vel + 2 * (LOCAL_E->hitboxes.GetHitbox(14)->center.z - orig.z) * grav)) / grav); direction_vec *= time; direction_vec.z = z_vel * time + 0.5f * grav * time * time; if (direction_vec.Length() * 1.2f < (orig.DistTo(entity->m_vecOrigin()))) @@ -1213,7 +1213,7 @@ bool Aim(CachedEntity *entity) { float pitch = ang.x * -1.0f; float max_height = -1.0f * direction_vec.z * direction_vec.z * (sin(pitch) * sin(pitch)) / (2.0f * grav); - float time_2 = -1.0f * ((direction_vec.z + fsqrt(direction_vec.z * direction_vec.z + 2.0f * max_height * grav)) / grav); + float time_2 = -1.0f * ((direction_vec.z + sqrt(direction_vec.z * direction_vec.z + 2.0f * max_height * grav)) / grav); if (!time_2) return false; Vector res = direction_vec * time_2 + orig; @@ -1689,15 +1689,13 @@ static void DrawText() return; for (auto const &ent : entity_cache::player_cache) { - if (CE_GOOD(ent)) + + Vector screen; + Vector oscreen; + if (draw::WorldToScreen(cd.aim_position, screen) && draw::WorldToScreen(ent->m_vecOrigin(), oscreen)) { - Vector screen; - Vector oscreen; - if (draw::WorldToScreen(cd.aim_position, screen) && draw::WorldToScreen(ent->m_vecOrigin(), oscreen)) - { - draw::Rectangle(screen.x - 2, screen.y - 2, 4, 4, colors::white); - draw::Line(oscreen.x, oscreen.y, screen.x - oscreen.x, screen.y - oscreen.y, colors::EntityF(ent), 0.5f); - } + draw::Rectangle(screen.x - 2, screen.y - 2, 4, 4, colors::white); + draw::Line(oscreen.x, oscreen.y, screen.x - oscreen.x, screen.y - oscreen.y, colors::EntityF(ent), 0.5f); } } } diff --git a/src/hacks/AntiAntiAim.cpp b/src/hacks/AntiAntiAim.cpp index 783df64d..fddd171c 100644 --- a/src/hacks/AntiAntiAim.cpp +++ b/src/hacks/AntiAntiAim.cpp @@ -18,10 +18,10 @@ static inline void modifyAngles() { for (auto const &player : entity_cache::player_cache) { - - if (CE_BAD(player) || !player->m_bAlivePlayer() || !player->m_bEnemy() || !player->player_info.friendsID) + + if (CE_BAD(player) || !player->m_bAlivePlayer() || !player->m_bEnemy() || !player->player_info->friendsID) continue; - auto &data = resolver_map[player->player_info.friendsID]; + auto &data = resolver_map[player->player_info->friendsID]; auto &angle = CE_VECTOR(player, netvar.m_angEyeAngles); angle.x = data.new_angle.x; angle.y = data.new_angle.y; @@ -142,9 +142,9 @@ static float resolveAnglePitch(float angle, brutedata &brute, CachedEntity *ent) void increaseBruteNum(int idx) { auto ent = ENTITY(idx); - if (CE_BAD(ent) || !ent->player_info.friendsID) + if (CE_BAD(ent) || !ent->player_info->friendsID) return; - auto &data = hacks::shared::anti_anti_aim::resolver_map[ent->player_info.friendsID]; + auto &data = hacks::shared::anti_anti_aim::resolver_map[ent->player_info->friendsID]; if (data.hits_in_a_row >= 4) data.hits_in_a_row = 2; else if (data.hits_in_a_row >= 2) @@ -177,7 +177,7 @@ static void pitchHook(const CRecvProxyData *pData, void *pStruct, void *pOut) auto client_ent = (IClientEntity *) (pStruct); CachedEntity *ent = ENTITY(client_ent->entindex()); if (CE_GOOD(ent)) - *flPitch_out = resolveAnglePitch(flPitch, resolver_map[ent->player_info.friendsID], ent); + *flPitch_out = resolveAnglePitch(flPitch, resolver_map[ent->player_info->friendsID], ent); } static void yawHook(const CRecvProxyData *pData, void *pStruct, void *pOut) @@ -194,7 +194,7 @@ static void yawHook(const CRecvProxyData *pData, void *pStruct, void *pOut) auto client_ent = (IClientEntity *) (pStruct); CachedEntity *ent = ENTITY(client_ent->entindex()); if (CE_GOOD(ent)) - *flYaw_out = resolveAngleYaw(flYaw, resolver_map[ent->player_info.friendsID]); + *flYaw_out = resolveAngleYaw(flYaw, resolver_map[ent->player_info->friendsID]); } // *_ptr points to what we need to modify while *_ProxyFn holds the old value diff --git a/src/hacks/AutoHeal.cpp b/src/hacks/AutoHeal.cpp index ecb95a99..bb569adc 100644 --- a/src/hacks/AutoHeal.cpp +++ b/src/hacks/AutoHeal.cpp @@ -97,9 +97,9 @@ int BulletDangerValue(CachedEntity *patient) return 0; bool any_zoomed_snipers = false; // Find dangerous snipers in other team - for (auto const &ent: entity_cache::player_cache) + for (auto const &ent : entity_cache::player_cache) { - + if (CE_BAD(ent)) continue; if (!ent->m_bAlivePlayer() || !ent->m_bEnemy()) @@ -142,9 +142,9 @@ int FireDangerValue(CachedEntity *patient) uint8_t should_switch = 0; if (auto_vacc_pop_if_pyro) { - for (auto const &ent: entity_cache::player_cache) + for (auto const &ent : entity_cache::player_cache) { - + if (CE_BAD(ent)) continue; if (!ent->m_bEnemy()) @@ -424,12 +424,12 @@ bool IsVaccinator() void UpdateData() { - for (auto const &ent: entity_cache::player_cache) + for (auto const &ent : entity_cache::player_cache) { int i = ent->m_IDX; if (reset_cd[i].test_and_set(10000)) data[i] = {}; - + if (CE_GOOD(ent) && ent->m_bAlivePlayer()) { int health = ent->m_iHealth(); @@ -578,7 +578,7 @@ int BestTarget() int best_score = INT_MIN; if (steamid_only) return best; - for (auto const &ent: entity_cache::player_cache) + for (auto const &ent : entity_cache::player_cache) { int score = HealingPriority(ent->m_IDX); if (score > best_score && score != -1) @@ -619,16 +619,16 @@ static void CreateMove() { CachedEntity *current_ent = ENTITY(CurrentHealingTargetIDX); if (CE_GOOD(current_ent)) - current_id = current_ent->player_info.friendsID; + current_id = current_ent->player_info->friendsID; } if (current_id != steamid) { - for (auto const &ent: entity_cache::player_cache) + for (auto const &ent : entity_cache::player_cache) { int i = ent->m_IDX; - if (!ent->player_info.friendsID) + if (!ent->player_info->friendsID) continue; - if (ent->player_info.friendsID == steamid && CanHeal(i)) + if (ent->player_info->friendsID == steamid && CanHeal(i)) { CurrentHealingTargetIDX = i; healing_steamid = true; diff --git a/src/hacks/FollowBot.cpp b/src/hacks/FollowBot.cpp index 29deaef2..d15d9cfa 100644 --- a/src/hacks/FollowBot.cpp +++ b/src/hacks/FollowBot.cpp @@ -64,10 +64,10 @@ static CatCommand follow_steam("fb_steam", "Follow Steam Id", static CatCommand steam_debug("debug_steamid", "Print steamids", []() { - for (auto const &ent: entity_cache::player_cache) + for (auto const &ent : entity_cache::player_cache) { - - logging::Info("%u", ent->player_info.friendsID); + + logging::Info("%u", ent->player_info->friendsID); } }); @@ -356,15 +356,15 @@ static void cm() // Find a target with the steam id, as it is prioritized if (steamid) { - if (ENTITY(valid_target)->player_info.friendsID != steamid) + if (ENTITY(valid_target)->player_info->friendsID != steamid) { - for (auto const &entity: entity_cache::player_cache) + for (auto const &entity : entity_cache::player_cache) { - + if (!isValidTarget(entity)) continue; // No enemy check, since steamid is very specific - if (steamid != entity->player_info.friendsID) // steamid check + if (steamid != entity->player_info->friendsID) // steamid check continue; if (startFollow(entity, isNavBotCM)) { @@ -387,19 +387,19 @@ static void cm() CSteamID steamid; pc->GetCurrentPartyLeader(steamid); auto accountid = steamid.GetAccountID(); - // if (steamid.GetAccountID() != ENTITY(follow_target)->player_info.friendsID) + // if (steamid.GetAccountID() != ENTITY(follow_target)->player_info->friendsID) // continue; - if (accountid != ENTITY(valid_target)->player_info.friendsID) + if (accountid != ENTITY(valid_target)->player_info->friendsID) { - for (auto const &entity: entity_cache::player_cache) + for (auto const &entity : entity_cache::player_cache) { - + if (!isValidTarget(entity)) continue; if (entity->m_bEnemy()) continue; - if (accountid != entity->player_info.friendsID) + if (accountid != entity->player_info->friendsID) continue; if (startFollow(entity, isNavBotCM)) { @@ -419,9 +419,9 @@ static void cm() { if (!playerlist::IsFriend(ENTITY(valid_target))) { - for (auto const &entity: entity_cache::player_cache) + for (auto const &entity : entity_cache::player_cache) { - + if (!isValidTarget(entity)) continue; if (entity->m_bEnemy()) @@ -452,10 +452,10 @@ static void cm() // Try to get a new target if (!followcart) { - - for (auto const &entity: entity_cache::player_cache) + + for (auto const &entity : entity_cache::player_cache) { - + if (!isValidTarget(entity)) continue; if (!follow_target) diff --git a/src/hacks/MiscPlayerInfo.cpp b/src/hacks/MiscPlayerInfo.cpp index d06e614d..55b0bc6c 100644 --- a/src/hacks/MiscPlayerInfo.cpp +++ b/src/hacks/MiscPlayerInfo.cpp @@ -57,7 +57,7 @@ void Paint() int i = ent->m_IDX; if (CE_BAD(ent)) continue; - if (ent->m_Type() != ENTITY_PLAYER || !ent->player_info.friendsID) + if (ent->m_Type() != ENTITY_PLAYER || !ent->player_info->friendsID) continue; // Update alive state if (g_pPlayerResource->isAlive(i)) @@ -121,7 +121,7 @@ void Paint() if (i == g_IEngine->GetLocalPlayer()) color.b += 0.5f; // tint CAT status people's names too - if (playerlist::AccessData(ent->player_info.friendsID).state == playerlist::k_EState::CAT) + if (playerlist::AccessData(ent->player_info->friendsID).state == playerlist::k_EState::CAT) color.g = 0.8f; // Calculate Player Level @@ -132,9 +132,9 @@ void Paint() level = max(level, 1); // String to draw, {Level} Cat for cathook users, else gotten from std::vector at random. - if (choosen_entry[ent->player_info.friendsID].first == "" || choosen_entry[ent->player_info.friendsID].second != level) - choosen_entry[ent->player_info.friendsID] = { random_mafia_entry(level, ent->player_info.friendsID), level }; - std::string to_display = (playerlist::AccessData(ent->player_info.friendsID).state == playerlist::k_EState::CAT ? format("Lv.", level, " Cat") : format("Lv.", level, " ", choosen_entry[ent->player_info.friendsID].first)); + if (choosen_entry[ent->player_info->friendsID].first == "" || choosen_entry[ent->player_info->friendsID].second != level) + choosen_entry[ent->player_info->friendsID] = { random_mafia_entry(level, ent->player_info->friendsID), level }; + std::string to_display = (playerlist::AccessData(ent->player_info->friendsID).state == playerlist::k_EState::CAT ? format("Lv.", level, " Cat") : format("Lv.", level, " ", choosen_entry[ent->player_info->friendsID].first)); // Clamp to prevent oob color.g -= (float) (g_GlobalVars->curtime - death_timer[i]) / (3.0f); diff --git a/src/hacks/Tracers.cpp b/src/hacks/Tracers.cpp index 6af39546..13f22ab4 100644 --- a/src/hacks/Tracers.cpp +++ b/src/hacks/Tracers.cpp @@ -87,7 +87,7 @@ inline std::optional getColor(CachedEntity *ent) else { - auto state = playerlist::AccessData(ent->player_info.friendsID); + auto state = playerlist::AccessData(ent->player_info->friendsID); if (state.state == playerlist::k_EState::DEFAULT) { if (!ent->m_vecDormantOrigin()) @@ -102,7 +102,7 @@ inline std::optional getColor(CachedEntity *ent) else if (*coloring_mode == 1) return colors::EntityF(ent); } - if (!player_tools::shouldTargetSteamId(ent->player_info.friendsID)) + if (!player_tools::shouldTargetSteamId(ent->player_info->friendsID)) { if (*draw_friendlies == 1) { @@ -115,7 +115,7 @@ inline std::optional getColor(CachedEntity *ent) } if (!ent->m_bEnemy()) return std::nullopt; - return playerlist::Color(ent->player_info.friendsID); + return playerlist::Color(ent->player_info->friendsID); } } @@ -182,12 +182,12 @@ void draw() } else { - for (auto const &ent: entity_cache::player_cache) + for (auto const &ent : entity_cache::player_cache) { // Get and check player - + Vector origin; - int i = ent->m_IDX; + int i = ent->m_IDX; std::optional color = std::nullopt; if (CE_INVALID(ent)) diff --git a/src/helpers.cpp b/src/helpers.cpp index 30c87016..e05ae60b 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -659,7 +659,7 @@ bool didProjectileHit(Vector start_point, Vector end_point, CachedEntity *entity trace_t trace_obj; ray.Init(start_point, end_point, Vector(0, -projectile_size, -projectile_size), Vector(0, projectile_size, projectile_size)); g_ITrace->TraceRay(ray, MASK_SHOT_HULL, &trace::filter_default, &trace_obj); - return (((IClientEntity *) trace_obj.m_pEnt) == RAW_ENT(entity) || (grav_comp ? !trace_obj.DidHit(): false)); + return (((IClientEntity *) trace_obj.m_pEnt) == RAW_ENT(entity) || (grav_comp ? !trace_obj.DidHit() : false)); } // A function to find a weapon by WeaponID @@ -712,9 +712,9 @@ CachedEntity *getClosestEntity(Vector vec) { float distance = FLT_MAX; CachedEntity *best_ent = nullptr; - for (auto const &ent: entity_cache::player_cache) + for (auto const &ent : entity_cache::player_cache) { - + if (CE_VALID(ent) && ent->m_vecDormantOrigin() && ent->m_bAlivePlayer() && ent->m_bEnemy() && vec.DistTo(ent->m_vecOrigin()) < distance) { distance = vec.DistTo(*ent->m_vecDormantOrigin()); @@ -728,9 +728,9 @@ CachedEntity *getClosestNonlocalEntity(Vector vec) { float distance = FLT_MAX; CachedEntity *best_ent = nullptr; - for (auto const &ent: entity_cache::player_cache) + for (auto const &ent : entity_cache::player_cache) { - + if (CE_VALID(ent) && ent->m_IDX != g_pLocalPlayer->entity_idx && ent->m_vecDormantOrigin() && ent->m_bAlivePlayer() && ent->m_bEnemy() && vec.DistTo(ent->m_vecOrigin()) < distance) { distance = vec.DistTo(*ent->m_vecDormantOrigin()); @@ -880,7 +880,6 @@ bool isRapidFire(IClientEntity *wep) return ret || wep->GetClientClass()->m_ClassID == CL_CLASS(CTFMinigun); } - char GetUpperChar(ButtonCode_t button) { switch (button) @@ -1034,7 +1033,7 @@ bool IsEntityVectorVisible(CachedEntity *entity, Vector endpos, bool use_weapon_ g_ITrace->TraceRay(ray, mask, &trace::filter_default, trace); } - return (((IClientEntity *) trace->m_pEnt) == RAW_ENT(entity) || (hit ? false: !trace->DidHit()) ); + return (((IClientEntity *) trace->m_pEnt) == RAW_ENT(entity) || (hit ? false : !trace->DidHit())); } // Get all the corners of a box. Taken from sauce engine. @@ -1181,7 +1180,7 @@ float ProjGravMult(int class_id, float x_speed) return 0.1f; else return 0.5f; - + case CL_CLASS(CTFProjectile_Flare): return 0.25f; case CL_CLASS(CTFProjectile_HealingBolt): @@ -1194,8 +1193,7 @@ float ProjGravMult(int class_id, float x_speed) case CL_CLASS(CTFProjectile_BallOfFire): return 0.0f; default: - return 0.3f; - + return 0.3f; } } weaponmode GetWeaponMode(CachedEntity *ent) @@ -1692,8 +1690,6 @@ float ATTRIB_HOOK_FLOAT(float base_value, const char *search_string, IClientEnti return AttribHookFloat_fn(base_value, search_string, ent, buffer, is_global_const_string); } - - void AimAt(Vector origin, Vector target, CUserCmd *cmd, bool compensate_punch) { cmd->viewangles = GetAimAtAngles(origin, target, compensate_punch ? LOCAL_E : nullptr); @@ -1807,7 +1803,7 @@ CatCommand print_classnames("debug_print_classnames", "Lists classnames currentl []() { // Create a tmp ent for the loop - + // Go through all the entities for (auto const &ent : entity_cache::valid_ents) { @@ -1976,10 +1972,9 @@ int SharedRandomInt(unsigned iseed, const char *sharedname, int iMinVal, int iMa return g_pUniformStream->RandomInt(iMinVal, iMaxVal); } - int GetPlayerForUserID(int userID) { - for (auto const &ent: entity_cache::player_cache) + for (auto const &ent : entity_cache::player_cache) { player_info_s player_info; int i = ent->m_IDX; diff --git a/src/hitrate.cpp b/src/hitrate.cpp index cab210d3..90a2e83e 100644 --- a/src/hitrate.cpp +++ b/src/hitrate.cpp @@ -87,7 +87,7 @@ void OnHit(bool crit, int idx, bool is_sniper) auto ent = ENTITY(idx); if (CE_GOOD(ent)) { - hacks::shared::anti_anti_aim::resolver_map[ent->player_info.friendsID].hits_in_a_row++; + hacks::shared::anti_anti_aim::resolver_map[ent->player_info->friendsID].hits_in_a_row++; resolve_soon[idx] = false; } } diff --git a/src/hooks/GetFriendPersonaName.cpp b/src/hooks/GetFriendPersonaName.cpp index 6ec622f9..92094148 100644 --- a/src/hooks/GetFriendPersonaName.cpp +++ b/src/hooks/GetFriendPersonaName.cpp @@ -37,7 +37,7 @@ bool StolenName() int potential_targets_length = 0; // Go through entities looking for potential targets - for (auto const &ent: entity_cache::player_cache) + for (auto const &ent : entity_cache::player_cache) { // Check if ent is a good target int i = ent->m_IDX; @@ -185,7 +185,7 @@ static InitRoutine init( if (new_val != 0) { std::string new_name = GetNamestealName(g_ISteamUser->GetSteamID()); - if (CE_BAD(LOCAL_E) || new_name.empty() || !strcmp(LOCAL_E->player_info.name, new_name.c_str())) + if (CE_BAD(LOCAL_E) || new_name.empty() || !strcmp(LOCAL_E->player_info->name, new_name.c_str())) return; netvar_name = std::move(new_name); NET_SetConVar setname("name", netvar_name.c_str()); @@ -231,7 +231,7 @@ static void cm() if (CE_BAD(LOCAL_E) || new_name.empty()) return; // Didn't change name - update timer a bit - if (!strcmp(LOCAL_E->player_info.name, new_name.c_str())) + if (!strcmp(LOCAL_E->player_info->name, new_name.c_str())) { set_name.last -= std::chrono::seconds(170); return; diff --git a/src/playerlist.cpp b/src/playerlist.cpp index ae656d2d..645dc52c 100644 --- a/src/playerlist.cpp +++ b/src/playerlist.cpp @@ -132,7 +132,7 @@ rgba_t Color(unsigned steamid) rgba_t Color(CachedEntity *player) { if (CE_GOOD(player)) - return Color(player->player_info.friendsID); + return Color(player->player_info->friendsID); return colors::empty; } #endif @@ -144,8 +144,8 @@ userdata &AccessData(unsigned steamid) // Assume player is non-null userdata &AccessData(CachedEntity *player) { - if (player && player->player_info.friendsID) - return AccessData(player->player_info.friendsID); + if (player && player->player_info->friendsID) + return AccessData(player->player_info->friendsID); return AccessData(0U); } @@ -160,8 +160,8 @@ bool IsDefault(unsigned steamid) bool IsDefault(CachedEntity *entity) { - if (entity && entity->player_info.friendsID) - return IsDefault(entity->player_info.friendsID); + if (entity && entity->player_info->friendsID) + return IsDefault(entity->player_info->friendsID); return true; } @@ -173,8 +173,8 @@ bool IsFriend(unsigned steamid) bool IsFriend(CachedEntity *entity) { - if (entity && entity->player_info.friendsID) - return IsFriend(entity->player_info.friendsID); + if (entity && entity->player_info->friendsID) + return IsFriend(entity->player_info->friendsID); return false; } @@ -238,8 +238,8 @@ bool ChangeState(unsigned int steamid, k_EState state, bool force) bool ChangeState(CachedEntity *entity, k_EState state, bool force) { - if (entity && entity->player_info.friendsID) - return ChangeState(entity->player_info.friendsID, state, force); + if (entity && entity->player_info->friendsID) + return ChangeState(entity->player_info->friendsID, state, force); return false; }