This commit is contained in:
Stephen 2023-02-18 23:50:39 -05:00 committed by LightCat
parent ae2e3feff6
commit 2dc50ca76d
14 changed files with 101 additions and 109 deletions

View File

@ -201,7 +201,6 @@ public:
bool m_bAnyHitboxVisible{ false }; bool m_bAnyHitboxVisible{ false };
bool m_bVisCheckComplete{ false }; bool m_bVisCheckComplete{ false };
k_EItemType m_ItemType() k_EItemType m_ItemType()
{ {
if (m_Type() == ENTITY_GENERIC) if (m_Type() == ENTITY_GENERIC)
@ -209,27 +208,20 @@ public:
else else
return ITEM_NONE; return ITEM_NONE;
}; };
unsigned long m_lSeenTicks{ 0 };
unsigned long m_lLastSeen{ 0 }; unsigned long m_lLastSeen{ 0 };
Vector m_vecVOrigin{ 0 };
Vector m_vecVelocity{ 0 }; Vector m_vecVelocity{ 0 };
Vector m_vecAcceleration{ 0 }; Vector m_vecAcceleration{ 0 };
float m_fLastUpdate{ 0.0f };
hitbox_cache::EntityHitboxCache hitboxes; hitbox_cache::EntityHitboxCache hitboxes;
player_info_s player_info{}; player_info_s *player_info = nullptr;
Averager<float> velocity_averager{ 8 };
void Reset() void Reset()
{ {
m_bAnyHitboxVisible = false; m_bAnyHitboxVisible = false;
m_bVisCheckComplete = false; m_bVisCheckComplete = false;
m_lLastSeen = 0; m_lLastSeen = 0;
m_lSeenTicks = 0; if (player_info)
memset(&player_info, 0, sizeof(player_info_s)); memset(player_info, 0, sizeof(player_info_s));
m_vecAcceleration.Zero(); m_vecAcceleration.Zero();
m_vecVOrigin.Zero();
m_vecVelocity.Zero(); m_vecVelocity.Zero();
m_fLastUpdate = 0;
} }
bool was_dormant() bool was_dormant()

View File

@ -55,7 +55,7 @@ function init() {
# #
function updateRepoURL() { 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) local GIT_REMOTE=$(git config --get remote.origin.url || echo unknown)
if [ "$URL" != "error" ] && [ "$GIT_REMOTE" != "$URL" ]; then 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" || : 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" || :

View File

@ -52,7 +52,7 @@ bool shouldTarget(CachedEntity *entity)
// Don't shoot players in truce // Don't shoot players in truce
if (isTruce()) if (isTruce())
return false; return false;
return shouldTargetSteamId(entity->player_info.friendsID); return shouldTargetSteamId(entity->player_info->friendsID);
} }
else if (entity->m_Type() == ENTITY_BUILDING) else if (entity->m_Type() == ENTITY_BUILDING)
// Don't shoot buildings in truce // Don't shoot buildings in truce
@ -75,7 +75,7 @@ bool shouldAlwaysRenderEsp(CachedEntity *entity)
{ {
if (entity->m_Type() == ENTITY_PLAYER) if (entity->m_Type() == ENTITY_PLAYER)
{ {
return shouldAlwaysRenderEspSteamId(entity->player_info.friendsID); return shouldAlwaysRenderEspSteamId(entity->player_info->friendsID);
} }
return false; return false;
@ -95,9 +95,9 @@ std::optional<colors::rgba_t> forceEspColorSteamId(unsigned id)
} }
std::optional<colors::rgba_t> forceEspColor(CachedEntity *entity) std::optional<colors::rgba_t> 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; return std::nullopt;
@ -150,7 +150,7 @@ static CatCommand mark_betrayal("pl_mark_betrayal", "Mark a steamid32 as betraya
void onKilledBy(CachedEntity *entity) void onKilledBy(CachedEntity *entity)
{ {
onKilledBy(entity->player_info.friendsID); onKilledBy(entity->player_info->friendsID);
} }
class PlayerToolsEventListener : public IGameEventListener2 class PlayerToolsEventListener : public IGameEventListener2

View File

@ -20,8 +20,7 @@ inline void CachedEntity::Update()
return; return;
} }
#endif #endif
m_lSeenTicks = 0; m_lLastSeen = 0;
m_lLastSeen = 0;
hitboxes.InvalidateCache(); hitboxes.InvalidateCache();
m_bVisCheckComplete = false; m_bVisCheckComplete = false;
} }
@ -31,10 +30,14 @@ inline CachedEntity::CachedEntity(u_int16_t idx) : m_IDX(idx), hitboxes(hitbox_c
#if PROXY_ENTITY != true #if PROXY_ENTITY != true
m_pEntity = nullptr; m_pEntity = nullptr;
#endif #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::Float ve_window{ "debug.ve.window", "0" };
static settings::Boolean ve_smooth{ "debug.ve.smooth", "true" }; static settings::Boolean ve_smooth{ "debug.ve.smooth", "true" };
@ -75,6 +78,8 @@ void Update()
u_int16_t current_ents = g_IEntityList->NumberOfEntities(false); u_int16_t current_ents = g_IEntityList->NumberOfEntities(false);
valid_ents.clear(); // Reserving isn't necessary as this doesn't reallocate it valid_ents.clear(); // Reserving isn't necessary as this doesn't reallocate it
player_cache.clear(); player_cache.clear();
if (g_Settings.bInvalid)
return;
if (max >= MAX_ENTITIES) if (max >= MAX_ENTITIES)
max = MAX_ENTITIES - 1; max = MAX_ENTITIES - 1;
if (previous_max == max && previous_ent == current_ents) if (previous_max == max && previous_ent == current_ents)
@ -87,7 +92,7 @@ void Update()
valid_ents.emplace_back(&val); valid_ents.emplace_back(&val);
if (val.m_Type() == ENTITY_PLAYER) 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]] if (val.m_bAlivePlayer()) [[likely]]
{ {
val.hitboxes.UpdateBones(); val.hitboxes.UpdateBones();
@ -104,7 +109,7 @@ void Update()
{ {
for (u_int16_t i = 0; i <= max; ++i) 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; continue;
CachedEntity &ent = array.try_emplace(i, CachedEntity{ i }).first->second; CachedEntity &ent = array.try_emplace(i, CachedEntity{ i }).first->second;
ent.Update(); ent.Update();
@ -113,7 +118,9 @@ void Update()
valid_ents.emplace_back(&ent); valid_ents.emplace_back(&ent);
if (ent.m_Type() == ENTITY_PLAYER) 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]] if (ent.m_bAlivePlayer()) [[likely]]
{ {
ent.hitboxes.UpdateBones(); ent.hitboxes.UpdateBones();

View File

@ -1199,9 +1199,9 @@ bool Aim(CachedEntity *entity)
// Direct shots should just use normal vischeck // Direct shots should just use normal vischeck
if (30.0f < abs(z_vel)) 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) 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 *= time;
direction_vec.z = z_vel * time + 0.5f * grav * time * time; direction_vec.z = z_vel * time + 0.5f * grav * time * time;
if (direction_vec.Length() * 1.2f < (orig.DistTo(entity->m_vecOrigin()))) 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 pitch = ang.x * -1.0f;
float max_height = -1.0f * direction_vec.z * direction_vec.z * (sin(pitch) * sin(pitch)) / (2.0f * grav); 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) if (!time_2)
return false; return false;
Vector res = direction_vec * time_2 + orig; Vector res = direction_vec * time_2 + orig;
@ -1689,15 +1689,13 @@ static void DrawText()
return; return;
for (auto const &ent : entity_cache::player_cache) 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; draw::Rectangle(screen.x - 2, screen.y - 2, 4, 4, colors::white);
Vector oscreen; draw::Line(oscreen.x, oscreen.y, screen.x - oscreen.x, screen.y - oscreen.y, colors::EntityF(ent), 0.5f);
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);
}
} }
} }
} }

View File

@ -18,10 +18,10 @@ static inline void modifyAngles()
{ {
for (auto const &player : entity_cache::player_cache) 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; 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); auto &angle = CE_VECTOR(player, netvar.m_angEyeAngles);
angle.x = data.new_angle.x; angle.x = data.new_angle.x;
angle.y = data.new_angle.y; angle.y = data.new_angle.y;
@ -142,9 +142,9 @@ static float resolveAnglePitch(float angle, brutedata &brute, CachedEntity *ent)
void increaseBruteNum(int idx) void increaseBruteNum(int idx)
{ {
auto ent = ENTITY(idx); auto ent = ENTITY(idx);
if (CE_BAD(ent) || !ent->player_info.friendsID) if (CE_BAD(ent) || !ent->player_info->friendsID)
return; 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) if (data.hits_in_a_row >= 4)
data.hits_in_a_row = 2; data.hits_in_a_row = 2;
else if (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); auto client_ent = (IClientEntity *) (pStruct);
CachedEntity *ent = ENTITY(client_ent->entindex()); CachedEntity *ent = ENTITY(client_ent->entindex());
if (CE_GOOD(ent)) 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) 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); auto client_ent = (IClientEntity *) (pStruct);
CachedEntity *ent = ENTITY(client_ent->entindex()); CachedEntity *ent = ENTITY(client_ent->entindex());
if (CE_GOOD(ent)) 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 // *_ptr points to what we need to modify while *_ProxyFn holds the old value

View File

@ -97,9 +97,9 @@ int BulletDangerValue(CachedEntity *patient)
return 0; return 0;
bool any_zoomed_snipers = false; bool any_zoomed_snipers = false;
// Find dangerous snipers in other team // 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)) if (CE_BAD(ent))
continue; continue;
if (!ent->m_bAlivePlayer() || !ent->m_bEnemy()) if (!ent->m_bAlivePlayer() || !ent->m_bEnemy())
@ -142,9 +142,9 @@ int FireDangerValue(CachedEntity *patient)
uint8_t should_switch = 0; uint8_t should_switch = 0;
if (auto_vacc_pop_if_pyro) 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)) if (CE_BAD(ent))
continue; continue;
if (!ent->m_bEnemy()) if (!ent->m_bEnemy())
@ -424,12 +424,12 @@ bool IsVaccinator()
void UpdateData() void UpdateData()
{ {
for (auto const &ent: entity_cache::player_cache) for (auto const &ent : entity_cache::player_cache)
{ {
int i = ent->m_IDX; int i = ent->m_IDX;
if (reset_cd[i].test_and_set(10000)) if (reset_cd[i].test_and_set(10000))
data[i] = {}; data[i] = {};
if (CE_GOOD(ent) && ent->m_bAlivePlayer()) if (CE_GOOD(ent) && ent->m_bAlivePlayer())
{ {
int health = ent->m_iHealth(); int health = ent->m_iHealth();
@ -578,7 +578,7 @@ int BestTarget()
int best_score = INT_MIN; int best_score = INT_MIN;
if (steamid_only) if (steamid_only)
return best; return best;
for (auto const &ent: entity_cache::player_cache) for (auto const &ent : entity_cache::player_cache)
{ {
int score = HealingPriority(ent->m_IDX); int score = HealingPriority(ent->m_IDX);
if (score > best_score && score != -1) if (score > best_score && score != -1)
@ -619,16 +619,16 @@ static void CreateMove()
{ {
CachedEntity *current_ent = ENTITY(CurrentHealingTargetIDX); CachedEntity *current_ent = ENTITY(CurrentHealingTargetIDX);
if (CE_GOOD(current_ent)) if (CE_GOOD(current_ent))
current_id = current_ent->player_info.friendsID; current_id = current_ent->player_info->friendsID;
} }
if (current_id != steamid) 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; int i = ent->m_IDX;
if (!ent->player_info.friendsID) if (!ent->player_info->friendsID)
continue; continue;
if (ent->player_info.friendsID == steamid && CanHeal(i)) if (ent->player_info->friendsID == steamid && CanHeal(i))
{ {
CurrentHealingTargetIDX = i; CurrentHealingTargetIDX = i;
healing_steamid = true; healing_steamid = true;

View File

@ -64,10 +64,10 @@ static CatCommand follow_steam("fb_steam", "Follow Steam Id",
static CatCommand steam_debug("debug_steamid", "Print steamids", 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 // Find a target with the steam id, as it is prioritized
if (steamid) 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)) if (!isValidTarget(entity))
continue; continue;
// No enemy check, since steamid is very specific // 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; continue;
if (startFollow(entity, isNavBotCM)) if (startFollow(entity, isNavBotCM))
{ {
@ -387,19 +387,19 @@ static void cm()
CSteamID steamid; CSteamID steamid;
pc->GetCurrentPartyLeader(steamid); pc->GetCurrentPartyLeader(steamid);
auto accountid = steamid.GetAccountID(); auto accountid = steamid.GetAccountID();
// if (steamid.GetAccountID() != ENTITY(follow_target)->player_info.friendsID) // if (steamid.GetAccountID() != ENTITY(follow_target)->player_info->friendsID)
// continue; // 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)) if (!isValidTarget(entity))
continue; continue;
if (entity->m_bEnemy()) if (entity->m_bEnemy())
continue; continue;
if (accountid != entity->player_info.friendsID) if (accountid != entity->player_info->friendsID)
continue; continue;
if (startFollow(entity, isNavBotCM)) if (startFollow(entity, isNavBotCM))
{ {
@ -419,9 +419,9 @@ static void cm()
{ {
if (!playerlist::IsFriend(ENTITY(valid_target))) 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)) if (!isValidTarget(entity))
continue; continue;
if (entity->m_bEnemy()) if (entity->m_bEnemy())
@ -452,10 +452,10 @@ static void cm()
// Try to get a new target // Try to get a new target
if (!followcart) if (!followcart)
{ {
for (auto const &entity: entity_cache::player_cache) for (auto const &entity : entity_cache::player_cache)
{ {
if (!isValidTarget(entity)) if (!isValidTarget(entity))
continue; continue;
if (!follow_target) if (!follow_target)

View File

@ -57,7 +57,7 @@ void Paint()
int i = ent->m_IDX; int i = ent->m_IDX;
if (CE_BAD(ent)) if (CE_BAD(ent))
continue; continue;
if (ent->m_Type() != ENTITY_PLAYER || !ent->player_info.friendsID) if (ent->m_Type() != ENTITY_PLAYER || !ent->player_info->friendsID)
continue; continue;
// Update alive state // Update alive state
if (g_pPlayerResource->isAlive(i)) if (g_pPlayerResource->isAlive(i))
@ -121,7 +121,7 @@ void Paint()
if (i == g_IEngine->GetLocalPlayer()) if (i == g_IEngine->GetLocalPlayer())
color.b += 0.5f; color.b += 0.5f;
// tint CAT status people's names too // 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; color.g = 0.8f;
// Calculate Player Level // Calculate Player Level
@ -132,9 +132,9 @@ void Paint()
level = max(level, 1); level = max(level, 1);
// String to draw, {Level} Cat for cathook users, else gotten from std::vector at random. // 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) 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 }; 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)); 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 // Clamp to prevent oob
color.g -= (float) (g_GlobalVars->curtime - death_timer[i]) / (3.0f); color.g -= (float) (g_GlobalVars->curtime - death_timer[i]) / (3.0f);

View File

@ -87,7 +87,7 @@ inline std::optional<rgba_t> getColor(CachedEntity *ent)
else 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 (state.state == playerlist::k_EState::DEFAULT)
{ {
if (!ent->m_vecDormantOrigin()) if (!ent->m_vecDormantOrigin())
@ -102,7 +102,7 @@ inline std::optional<rgba_t> getColor(CachedEntity *ent)
else if (*coloring_mode == 1) else if (*coloring_mode == 1)
return colors::EntityF(ent); return colors::EntityF(ent);
} }
if (!player_tools::shouldTargetSteamId(ent->player_info.friendsID)) if (!player_tools::shouldTargetSteamId(ent->player_info->friendsID))
{ {
if (*draw_friendlies == 1) if (*draw_friendlies == 1)
{ {
@ -115,7 +115,7 @@ inline std::optional<rgba_t> getColor(CachedEntity *ent)
} }
if (!ent->m_bEnemy()) if (!ent->m_bEnemy())
return std::nullopt; return std::nullopt;
return playerlist::Color(ent->player_info.friendsID); return playerlist::Color(ent->player_info->friendsID);
} }
} }
@ -182,12 +182,12 @@ void draw()
} }
else else
{ {
for (auto const &ent: entity_cache::player_cache) for (auto const &ent : entity_cache::player_cache)
{ {
// Get and check player // Get and check player
Vector origin; Vector origin;
int i = ent->m_IDX; int i = ent->m_IDX;
std::optional<rgba_t> color = std::nullopt; std::optional<rgba_t> color = std::nullopt;
if (CE_INVALID(ent)) if (CE_INVALID(ent))

View File

@ -659,7 +659,7 @@ bool didProjectileHit(Vector start_point, Vector end_point, CachedEntity *entity
trace_t trace_obj; trace_t trace_obj;
ray.Init(start_point, end_point, Vector(0, -projectile_size, -projectile_size), Vector(0, projectile_size, projectile_size)); 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); 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 // A function to find a weapon by WeaponID
@ -712,9 +712,9 @@ CachedEntity *getClosestEntity(Vector vec)
{ {
float distance = FLT_MAX; float distance = FLT_MAX;
CachedEntity *best_ent = nullptr; 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) 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()); distance = vec.DistTo(*ent->m_vecDormantOrigin());
@ -728,9 +728,9 @@ CachedEntity *getClosestNonlocalEntity(Vector vec)
{ {
float distance = FLT_MAX; float distance = FLT_MAX;
CachedEntity *best_ent = nullptr; 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) 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()); distance = vec.DistTo(*ent->m_vecDormantOrigin());
@ -880,7 +880,6 @@ bool isRapidFire(IClientEntity *wep)
return ret || wep->GetClientClass()->m_ClassID == CL_CLASS(CTFMinigun); return ret || wep->GetClientClass()->m_ClassID == CL_CLASS(CTFMinigun);
} }
char GetUpperChar(ButtonCode_t button) char GetUpperChar(ButtonCode_t button)
{ {
switch (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); 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. // 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; return 0.1f;
else else
return 0.5f; return 0.5f;
case CL_CLASS(CTFProjectile_Flare): case CL_CLASS(CTFProjectile_Flare):
return 0.25f; return 0.25f;
case CL_CLASS(CTFProjectile_HealingBolt): case CL_CLASS(CTFProjectile_HealingBolt):
@ -1194,8 +1193,7 @@ float ProjGravMult(int class_id, float x_speed)
case CL_CLASS(CTFProjectile_BallOfFire): case CL_CLASS(CTFProjectile_BallOfFire):
return 0.0f; return 0.0f;
default: default:
return 0.3f; return 0.3f;
} }
} }
weaponmode GetWeaponMode(CachedEntity *ent) 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); return AttribHookFloat_fn(base_value, search_string, ent, buffer, is_global_const_string);
} }
void AimAt(Vector origin, Vector target, CUserCmd *cmd, bool compensate_punch) void AimAt(Vector origin, Vector target, CUserCmd *cmd, bool compensate_punch)
{ {
cmd->viewangles = GetAimAtAngles(origin, target, compensate_punch ? LOCAL_E : nullptr); 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 // Create a tmp ent for the loop
// Go through all the entities // Go through all the entities
for (auto const &ent : entity_cache::valid_ents) 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); return g_pUniformStream->RandomInt(iMinVal, iMaxVal);
} }
int GetPlayerForUserID(int userID) 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; player_info_s player_info;
int i = ent->m_IDX; int i = ent->m_IDX;

View File

@ -87,7 +87,7 @@ void OnHit(bool crit, int idx, bool is_sniper)
auto ent = ENTITY(idx); auto ent = ENTITY(idx);
if (CE_GOOD(ent)) 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; resolve_soon[idx] = false;
} }
} }

View File

@ -37,7 +37,7 @@ bool StolenName()
int potential_targets_length = 0; int potential_targets_length = 0;
// Go through entities looking for potential targets // 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 // Check if ent is a good target
int i = ent->m_IDX; int i = ent->m_IDX;
@ -185,7 +185,7 @@ static InitRoutine init(
if (new_val != 0) if (new_val != 0)
{ {
std::string new_name = GetNamestealName(g_ISteamUser->GetSteamID()); 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; return;
netvar_name = std::move(new_name); netvar_name = std::move(new_name);
NET_SetConVar setname("name", netvar_name.c_str()); NET_SetConVar setname("name", netvar_name.c_str());
@ -231,7 +231,7 @@ static void cm()
if (CE_BAD(LOCAL_E) || new_name.empty()) if (CE_BAD(LOCAL_E) || new_name.empty())
return; return;
// Didn't change name - update timer a bit // 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); set_name.last -= std::chrono::seconds(170);
return; return;

View File

@ -132,7 +132,7 @@ rgba_t Color(unsigned steamid)
rgba_t Color(CachedEntity *player) rgba_t Color(CachedEntity *player)
{ {
if (CE_GOOD(player)) if (CE_GOOD(player))
return Color(player->player_info.friendsID); return Color(player->player_info->friendsID);
return colors::empty; return colors::empty;
} }
#endif #endif
@ -144,8 +144,8 @@ userdata &AccessData(unsigned steamid)
// Assume player is non-null // Assume player is non-null
userdata &AccessData(CachedEntity *player) userdata &AccessData(CachedEntity *player)
{ {
if (player && player->player_info.friendsID) if (player && player->player_info->friendsID)
return AccessData(player->player_info.friendsID); return AccessData(player->player_info->friendsID);
return AccessData(0U); return AccessData(0U);
} }
@ -160,8 +160,8 @@ bool IsDefault(unsigned steamid)
bool IsDefault(CachedEntity *entity) bool IsDefault(CachedEntity *entity)
{ {
if (entity && entity->player_info.friendsID) if (entity && entity->player_info->friendsID)
return IsDefault(entity->player_info.friendsID); return IsDefault(entity->player_info->friendsID);
return true; return true;
} }
@ -173,8 +173,8 @@ bool IsFriend(unsigned steamid)
bool IsFriend(CachedEntity *entity) bool IsFriend(CachedEntity *entity)
{ {
if (entity && entity->player_info.friendsID) if (entity && entity->player_info->friendsID)
return IsFriend(entity->player_info.friendsID); return IsFriend(entity->player_info->friendsID);
return false; 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) bool ChangeState(CachedEntity *entity, k_EState state, bool force)
{ {
if (entity && entity->player_info.friendsID) if (entity && entity->player_info->friendsID)
return ChangeState(entity->player_info.friendsID, state, force); return ChangeState(entity->player_info->friendsID, state, force);
return false; return false;
} }