diff --git a/include/entitycache.hpp b/include/entitycache.hpp index fb937066..01d437f5 100644 --- a/include/entitycache.hpp +++ b/include/entitycache.hpp @@ -21,6 +21,7 @@ #include #include "playerresource.h" #include "globals.h" +#include "classinfo.hpp" struct matrix3x4_t; @@ -116,25 +117,52 @@ public: }; int m_iMaxHealth() { - if (m_Type == ENTITY_PLAYER) + if (m_Type() == ENTITY_PLAYER) return g_pPlayerResource->GetMaxHealth(this); - else if (m_Type == ENTITY_BUILDING) + else if (m_Type() == ENTITY_BUILDING) return NET_INT(RAW_ENT(this), netvar.iBuildingMaxHealth); else return 0.0f; }; int m_iHealth() { - if (m_Type == ENTITY_PLAYER) + if (m_Type() == ENTITY_PLAYER) return NET_INT(RAW_ENT(this), netvar.iHealth); - else if (m_Type == ENTITY_BUILDING) + else if (m_Type() == ENTITY_BUILDING) return NET_INT(RAW_ENT(this), netvar.iBuildingHealth); else return 0.0f; }; // Entity fields start here - EntityType m_Type{ ENTITY_GENERIC }; + EntityType m_Type() + { + EntityType ret = ENTITY_GENERIC; + int classid = m_iClassID(); + if (classid == CL_CLASS(CTFPlayer)) + ret = ENTITY_PLAYER; + else if (classid == CL_CLASS(CTFGrenadePipebombProjectile) || + classid == CL_CLASS(CTFProjectile_Cleaver) || + classid == CL_CLASS(CTFProjectile_Jar) || + classid == CL_CLASS(CTFProjectile_JarMilk) || + classid == CL_CLASS(CTFProjectile_Arrow) || + classid == CL_CLASS(CTFProjectile_EnergyBall) || + classid == CL_CLASS(CTFProjectile_EnergyRing) || + classid == CL_CLASS(CTFProjectile_GrapplingHook) || + classid == CL_CLASS(CTFProjectile_HealingBolt) || + classid == CL_CLASS(CTFProjectile_Rocket) || + classid == CL_CLASS(CTFProjectile_SentryRocket) || + classid == CL_CLASS(CTFProjectile_BallOfFire) || + classid == CL_CLASS(CTFProjectile_Flare)) + ret = ENTITY_PROJECTILE; + else if (classid == CL_CLASS(CObjectTeleporter) || + classid == CL_CLASS(CObjectSentrygun) || + classid == CL_CLASS(CObjectDispenser)) + ret = ENTITY_BUILDING; + else + ret = ENTITY_GENERIC; + return ret; + }; float m_flDistance() { @@ -146,17 +174,29 @@ public: bool m_bCritProjectile() { - if (m_Type == EntityType::ENTITY_PROJECTILE) + if (m_Type() == EntityType::ENTITY_PROJECTILE) return IsProjectileACrit(this); else return false; }; - bool m_bGrenadeProjectile{ false }; + bool m_bGrenadeProjectile() + { + return m_iClassID() == CL_CLASS(CTFGrenadePipebombProjectile) || + m_iClassID() == CL_CLASS(CTFProjectile_Cleaver) || + m_iClassID() == CL_CLASS(CTFProjectile_Jar) || + m_iClassID() == CL_CLASS(CTFProjectile_JarMilk); + }; bool m_bAnyHitboxVisible{ false }; bool m_bVisCheckComplete{ false }; - k_EItemType m_ItemType{ ITEM_NONE }; + k_EItemType m_ItemType() + { + if (m_Type() == ENTITY_GENERIC) + return g_ItemManager.GetItemType(this); + else + return ITEM_NONE; + }; unsigned long m_lSeenTicks{ 0 }; unsigned long m_lLastSeen{ 0 }; diff --git a/src/entitycache.cpp b/src/entitycache.cpp index 12e80822..f4cc6b03 100644 --- a/src/entitycache.cpp +++ b/src/entitycache.cpp @@ -11,7 +11,7 @@ bool IsProjectileACrit(CachedEntity *ent) { - if (ent->m_bGrenadeProjectile) + if (ent->m_bGrenadeProjectile()) return CE_BYTE(ent, netvar.Grenade_bCritical); return CE_BYTE(ent, netvar.Rocket_bCritical); } @@ -29,13 +29,10 @@ CachedEntity::CachedEntity() void CachedEntity::Reset() { - m_Type = ENTITY_GENERIC; - m_bGrenadeProjectile = false; - m_bAnyHitboxVisible = false; - m_bVisCheckComplete = false; - m_ItemType = ITEM_NONE; - m_lLastSeen = 0; - m_lSeenTicks = 0; + m_bAnyHitboxVisible = false; + m_bVisCheckComplete = false; + m_lLastSeen = 0; + m_lSeenTicks = 0; memset(&player_info, 0, sizeof(player_info_s)); m_vecAcceleration.Zero(); m_vecVOrigin.Zero(); @@ -67,105 +64,15 @@ void CachedEntity::Update() #endif bool dormant = raw->IsDormant(); bool dormant_state_changed = dormant != was_dormant(); - /*float simtime = CE_FLOAT(this, netvar.m_flSimulationTime); - float deltat = (simtime - m_fLastUpdate); - if (ve_smooth) { - // - if (dormant_state_changed) { - velocity_averager.reset(0); - velocity_is_valid = false; - } - if (size_t(int(ve_averager_size)) != velocity_averager.size()) { - velocity_averager.resize(size_t(int(ve_averager_size))); - velocity_averager.reset(0); - } - } - if (!dormant && deltat > (float)ve_window) { - ICollideable* ca = RAW_ENT(this)->GetCollideable(); - Vector origin = m_vecOrigin; - if (ca) { - origin = ca->GetCollisionOrigin(); - } - Vector delta = origin - m_vecVOrigin; - Vector velnew = delta / deltat; - m_vecAcceleration = velnew - m_vecVelocity; - if (ve_smooth) { - if (velocity_is_valid) { - static Vector zero {0.0f, 0.0f, 0.0f}; - float length = velnew.Length(); - velocity_averager.push(length); - Vector normalized = (length ? (velnew / length) : zero); - m_vecVelocity = normalized * velocity_averager.average(); - //m_vecVelocity = velocity_averager.average(); - } else { - EstimateAbsVelocity(RAW_ENT(this), m_vecVelocity); - //velocity_averager.push(m_vecVelocity); - velocity_is_valid = true; - } - } else - m_vecVelocity = velnew; - m_vecVOrigin = origin; - m_fLastUpdate = simtime; - }*/ - - m_ItemType = ITEM_NONE; m_lSeenTicks = 0; m_lLastSeen = 0; hitboxes.Update(); - m_bGrenadeProjectile = false; - m_bVisCheckComplete = false; + m_bVisCheckComplete = false; - if (m_iClassID() == RCC_PLAYER) - { - m_Type = EntityType::ENTITY_PLAYER; - } - else if (m_iClassID() == CL_CLASS(CTFGrenadePipebombProjectile) || - m_iClassID() == CL_CLASS(CTFProjectile_Cleaver) || - m_iClassID() == CL_CLASS(CTFProjectile_Jar) || - m_iClassID() == CL_CLASS(CTFProjectile_JarMilk)) - { - m_Type = EntityType::ENTITY_PROJECTILE; - m_bGrenadeProjectile = true; - } - else if (m_iClassID() == CL_CLASS(CObjectTeleporter) || - m_iClassID() == CL_CLASS(CObjectSentrygun) || - m_iClassID() == CL_CLASS(CObjectDispenser)) - { - m_Type = EntityType::ENTITY_BUILDING; - } - else if (m_iClassID() == CL_CLASS(CTFProjectile_Arrow) || - m_iClassID() == CL_CLASS(CTFProjectile_EnergyBall) || - m_iClassID() == CL_CLASS(CTFProjectile_EnergyRing) || - m_iClassID() == CL_CLASS(CTFProjectile_GrapplingHook) || - m_iClassID() == CL_CLASS(CTFProjectile_HealingBolt) || - m_iClassID() == CL_CLASS(CTFProjectile_Rocket) || - m_iClassID() == CL_CLASS(CTFProjectile_SentryRocket) || - m_iClassID() == CL_CLASS(CTFProjectile_BallOfFire) || - m_iClassID() == CL_CLASS(CTFProjectile_Flare)) - { - m_Type = EntityType::ENTITY_PROJECTILE; - } - else - { - m_ItemType = g_ItemManager.GetItemType(this); - m_Type = EntityType::ENTITY_GENERIC; - } - // TODO temporary! - /*m_bCritProjectile = false; - m_bIsVisible = false; - m_iTeam = 0; - m_bEnemy = false; - m_bAlivePlayer = false; - m_pPlayerInfo = 0; - m_iHealth = 0; - m_iMaxHealth = 0; - m_lLastSeen = 0; - m_lSeenTicks = 0;*/ - - if (m_Type == EntityType::ENTITY_PLAYER) + if (m_Type() == EntityType::ENTITY_PLAYER) g_IEngine->GetPlayerInfo(m_IDX, &player_info); } @@ -192,7 +99,7 @@ bool CachedEntity::IsVisible() return true; } - if (m_Type == ENTITY_PLAYER && fast_vischeck) + if (m_Type() == ENTITY_PLAYER && fast_vischeck) { for (int i = 0; i < 4; i++) { @@ -232,6 +139,8 @@ CachedEntity array[MAX_ENTITIES]{}; void Update() { + PROF_SECTION(CACHE_UPDATE) + { max = g_IEntityList->GetHighestEntityIndex(); if (max >= MAX_ENTITIES) max = MAX_ENTITIES - 1; @@ -239,6 +148,7 @@ void Update() { array[i].Update(); } + } } void Invalidate() diff --git a/src/hacks/Aimbot.cpp b/src/hacks/Aimbot.cpp index 2523488b..90c108e4 100644 --- a/src/hacks/Aimbot.cpp +++ b/src/hacks/Aimbot.cpp @@ -206,12 +206,11 @@ void CreateMove() CachedEntity *target_entity = RetrieveBestTarget(aimkey_status); if (CE_BAD(target_entity) || !foundTarget) { - hacks::shared::backtrack::dontbacktrack = true; + hacks::shared::backtrack::dontbacktrack = true; target_entity = hacks::shared::backtrack::BestTarget(); if (CE_BAD(target_entity)) return; } - if (!g_IEntityList->GetClientEntity(target_entity->m_IDX)) return; if (!target_entity->hitboxes.GetHitbox( @@ -465,7 +464,7 @@ bool IsTargetStateGood(CachedEntity *entity) PROF_SECTION(PT_aimbot_targetstatecheck); // Checks for Players - if (entity->m_Type == ENTITY_PLAYER) + if (entity->m_Type() == ENTITY_PLAYER) { // Local player check if (entity == LOCAL_E) @@ -589,7 +588,7 @@ bool IsTargetStateGood(CachedEntity *entity) // Check for buildings } - else if (entity->m_Type == ENTITY_BUILDING) + else if (entity->m_Type() == ENTITY_BUILDING) { // Enabled check if (!(buildings_other || buildings_sentry)) @@ -862,7 +861,7 @@ const Vector &PredictEntity(CachedEntity *entity) return result; // Players - if ((entity->m_Type == ENTITY_PLAYER)) + if ((entity->m_Type() == ENTITY_PLAYER)) { // If using projectiles, predict a vector if (projectile_mode && @@ -889,7 +888,7 @@ const Vector &PredictEntity(CachedEntity *entity) } // Buildings } - else if (entity->m_Type == ENTITY_BUILDING) + else if (entity->m_Type() == ENTITY_BUILDING) { result = GetBuildingPosition(entity); // Other diff --git a/src/hacks/AntiAim.cpp b/src/hacks/AntiAim.cpp index 96ec6205..86c3501a 100644 --- a/src/hacks/AntiAim.cpp +++ b/src/hacks/AntiAim.cpp @@ -260,20 +260,21 @@ bool ShouldAA(CUserCmd *cmd) return false; if (cmd->buttons & IN_USE) return false; + int classid = LOCAL_W->m_iClassID(); if ((cmd->buttons & IN_ATTACK) && !(IsTF2() && - g_pLocalPlayer->weapon()->m_iClassID() == CL_CLASS(CTFCompoundBow)) && + classid == CL_CLASS(CTFCompoundBow)) && CanShoot()) { return false; } if ((cmd->buttons & IN_ATTACK2) && - g_pLocalPlayer->weapon()->m_iClassID() == CL_CLASS(CTFLunchBox)) + classid == CL_CLASS(CTFLunchBox)) return false; switch (GetWeaponMode()) { case weapon_projectile: - if (g_pLocalPlayer->weapon()->m_iClassID() == CL_CLASS(CTFCompoundBow)) + if (classid == CL_CLASS(CTFCompoundBow)) { if (!(cmd->buttons & IN_ATTACK)) { diff --git a/src/hacks/AntiDisguise.cpp b/src/hacks/AntiDisguise.cpp index e6763ea1..128805ea 100644 --- a/src/hacks/AntiDisguise.cpp +++ b/src/hacks/AntiDisguise.cpp @@ -28,7 +28,7 @@ void Draw() ent = ENTITY(i); if (CE_BAD(ent)) continue; - if (ent->m_Type == ENTITY_PLAYER) + if (ent->m_Type() == ENTITY_PLAYER) { if (CE_INT(ent, netvar.iClass) == tf_class::tf_spy) { @@ -44,7 +44,7 @@ void Draw() ent = ENTITY(i); if (CE_BAD(ent)) continue; - if (ent->m_Type == ENTITY_PLAYER) + if (ent->m_Type() == ENTITY_PLAYER) { if (CE_INT(ent, netvar.iClass) == tf_class::tf_spy) { diff --git a/src/hacks/AutoBackstab.cpp b/src/hacks/AutoBackstab.cpp index e8d781b2..d5b37180 100644 --- a/src/hacks/AutoBackstab.cpp +++ b/src/hacks/AutoBackstab.cpp @@ -58,7 +58,7 @@ void CreateMove() CachedEntity *pEnt = ENTITY(i); if (!CE_GOOD(pEnt)) continue; - if (pEnt->m_Type != ENTITY_PLAYER) + if (pEnt->m_Type() != ENTITY_PLAYER) continue; if (!pEnt->m_bAlivePlayer()) continue; @@ -67,13 +67,9 @@ void CreateMove() if (LOCAL_E->m_iTeam() == pEnt->m_iTeam()) continue; scr = 4096.0f - pEnt->m_vecOrigin().DistTo(LOCAL_E->m_vecOrigin()); - if (pEnt->m_vecOrigin().DistTo(LOCAL_E->m_vecOrigin()) > 90.0f) - continue; scr -= abs(g_pLocalPlayer->v_Eye.y - NET_VECTOR(pEnt, netvar.m_angEyeAngles).y); - if ((scr > scr_best) && - LOCAL_E->m_vecOrigin().DistTo(pEnt->m_vecOrigin()) < - (int) value) + if (scr > scr_best) { scr_best = scr; ent = pEnt; @@ -92,10 +88,9 @@ void CreateMove() Vector vecToTarget; int tick = hacks::shared::backtrack::Besttick(ent); - vecToTarget = hacks::shared::backtrack::headPositions - [ent->m_IDX][tick] - .origin - - GetWorldSpaceCenter(LOCAL_E); + vecToTarget = + hacks::shared::backtrack::headPositions[ent->m_IDX][tick].origin - + GetWorldSpaceCenter(LOCAL_E); vecToTarget.z = 0.0f; vecToTarget.NormalizeInPlace(); @@ -103,12 +98,12 @@ void CreateMove() bool isbehind = flDot > -0.1; if (isbehind && - hacks::shared::backtrack::headPositions - [ent->m_IDX][tick] - .origin.DistTo(g_pLocalPlayer->v_Eye) <= - re::C_TFWeaponBaseMelee::GetSwingRange(LOCAL_W)) { - hacks::shared::backtrack::dontbacktrack = true; - hacks::shared::backtrack::Backtrack(ent, tick); + hacks::shared::backtrack::headPositions[ent->m_IDX][tick] + .origin.DistTo(g_pLocalPlayer->v_Eye) <= + re::C_TFWeaponBaseMelee::GetSwingRange(LOCAL_W)) + { + hacks::shared::backtrack::dontbacktrack = true; + hacks::shared::backtrack::Backtrack(ent, tick); g_pUserCmd->buttons |= IN_ATTACK; } } diff --git a/src/hacks/AutoDetonator.cpp b/src/hacks/AutoDetonator.cpp index 8a5305aa..5ca87539 100644 --- a/src/hacks/AutoDetonator.cpp +++ b/src/hacks/AutoDetonator.cpp @@ -52,7 +52,7 @@ bool IsTarget(CachedEntity *ent) return false; // Player specific - if (ent->m_Type == ENTITY_PLAYER) + if (ent->m_Type() == ENTITY_PLAYER) { // Dont detonate on dead players if (!ent->m_bAlivePlayer()) diff --git a/src/hacks/AutoHeal.cpp b/src/hacks/AutoHeal.cpp index c35a1302..0665b5ee 100644 --- a/src/hacks/AutoHeal.cpp +++ b/src/hacks/AutoHeal.cpp @@ -193,7 +193,7 @@ int BlastDangerValue(CachedEntity *patient) continue; if (!ent->m_bEnemy()) continue; - if (ent->m_Type != ENTITY_PROJECTILE) + if (ent->m_Type() != ENTITY_PROJECTILE) continue; if (patient->m_vecOrigin().DistTo(ent->m_vecOrigin()) > (int) auto_vacc_proj_danger_range) @@ -323,7 +323,7 @@ static CatCommand heal_steamid( CachedEntity *ent = ENTITY(i); if (CE_BAD(ent)) continue; - if (ent->m_Type != ENTITY_PLAYER) + if (ent->m_Type() != ENTITY_PLAYER) continue; if (ent->player_info.friendsID == strtol(args.Arg(1), nullptr, 10)) { @@ -580,7 +580,7 @@ bool CanHeal(int idx) return false; if (CE_BAD(ent)) return false; - if (ent->m_Type != ENTITY_PLAYER) + if (ent->m_Type() != ENTITY_PLAYER) return false; if (g_IEngine->GetLocalPlayer() == idx) return false; diff --git a/src/hacks/AutoReflect.cpp b/src/hacks/AutoReflect.cpp index 98b7b804..0547f86c 100644 --- a/src/hacks/AutoReflect.cpp +++ b/src/hacks/AutoReflect.cpp @@ -160,7 +160,7 @@ void CreateMove() bool ShouldReflect(CachedEntity *ent) { // Check if the entity is a projectile - if (ent->m_Type != ENTITY_PROJECTILE) + if (ent->m_Type() != ENTITY_PROJECTILE) return false; if (!teammates) @@ -174,7 +174,7 @@ bool ShouldReflect(CachedEntity *ent) if (!dodgeball) { // If projectile is already deflected, don't deflect it again. - if (CE_INT(ent, (ent->m_bGrenadeProjectile + if (CE_INT(ent, (ent->m_bGrenadeProjectile() ? /* NetVar for grenades */ netvar.Grenade_iDeflected : diff --git a/src/hacks/AutoSticky.cpp b/src/hacks/AutoSticky.cpp index 6f96dbf5..65360dc1 100644 --- a/src/hacks/AutoSticky.cpp +++ b/src/hacks/AutoSticky.cpp @@ -57,7 +57,7 @@ bool IsTarget(CachedEntity *ent) return false; // Player specific - if (ent->m_Type == ENTITY_PLAYER) + if (ent->m_Type() == ENTITY_PLAYER) { // Dont detonate on dead players if (!ent->m_bAlivePlayer()) @@ -86,7 +86,7 @@ bool IsTarget(CachedEntity *ent) // Building specific } - else if (ent->m_Type == ENTITY_BUILDING) + else if (ent->m_Type() == ENTITY_BUILDING) { return buildings; } diff --git a/src/hacks/Backtrack.cpp b/src/hacks/Backtrack.cpp index 5497ef91..f3017830 100644 --- a/src/hacks/Backtrack.cpp +++ b/src/hacks/Backtrack.cpp @@ -77,10 +77,10 @@ void Init() } } std::pair backtracked; -void setbesttick(CachedEntity* ent, int tick) +void setbesttick(CachedEntity *ent, int tick) { - backtracked.first = ent->m_IDX; - backtracked.second = tick; + backtracked.first = ent->m_IDX; + backtracked.second = tick; } bool disabled = true; int BestTick = 0; @@ -114,7 +114,7 @@ void Run() } if (pEntity->m_iTeam() == LOCAL_E->m_iTeam()) continue; - if (pEntity->m_Type != ENTITY_PLAYER) + if (pEntity->m_Type() != ENTITY_PLAYER) continue; if (!pEntity->hitboxes.GetHitbox(0)) continue; @@ -125,21 +125,23 @@ void Run() BacktrackData{ g_pUserCmd->tick_count, hitboxpos, min, max, pEntity->m_vecOrigin() }; } - CachedEntity *target = BestTarget(); - if (CE_BAD(target)) - return; - int tick = Besttick(target); - setbesttick(target, tick); + if ((g_pUserCmd->buttons & IN_ATTACK || g_pUserCmd->buttons & IN_ATTACK2) && !dontbacktrack && CanShoot()) + { + CachedEntity *target = BestTarget(); + if (CE_BAD(target)) + return; + int tick = Besttick(target); Backtrack(target, tick); + } dontbacktrack = false; } int Besttick(CachedEntity *ent) { - float tempFOV = 9999; - float bestFOV = 40.0f; - int bestTick = 0; + float tempFOV = 9999; + float bestFOV = 40.0f; + int bestTick = 0; for (int t = 0; t < ticks; ++t) { if (!IsVectorVisible(g_pLocalPlayer->v_Eye, @@ -183,14 +185,14 @@ CachedEntity *BestTarget() if (iBestTarget != -1) return ENTITY(iBestTarget); else - return nullptr; + return nullptr; } void Backtrack(CachedEntity *ent, int tick) { if (CE_GOOD(ent)) { - backtracked.first = ent->m_IDX; - backtracked.second = tick; + backtracked.first = ent->m_IDX; + backtracked.second = tick; g_pUserCmd->tick_count = headPositions[ent->m_IDX][tick].tickcount; } } diff --git a/src/hacks/ESP.cpp b/src/hacks/ESP.cpp index 786c0d48..f17d3417 100644 --- a/src/hacks/ESP.cpp +++ b/src/hacks/ESP.cpp @@ -358,7 +358,7 @@ void CreateMove() { for (int j = 0; j < 18; ++j) hitboxcache[i][j] = ent->hitboxes.GetHitbox(j); - if (draw_bones && ent->m_Type == ENTITY_PLAYER) + if (draw_bones && ent->m_Type() == ENTITY_PLAYER) { modelcache[i] = RAW_ENT(ent)->GetModel(); if (modelcache[i]) @@ -446,7 +446,7 @@ void _FASTCALL emoji(CachedEntity *ent) // Emoji esp if (emoji_esp) { - if (ent->m_Type == ENTITY_PLAYER) + if (ent->m_Type() == ENTITY_PLAYER) { if (emoji_ok) @@ -523,6 +523,8 @@ void _FASTCALL ProcessEntityPT(CachedEntity *ent) if (CE_BAD(ent)) return; + int classid = ent->m_iClassID(); + EntityType type = ent->m_Type(); // Grab esp data ESPData &ent_data = data[ent->m_IDX]; @@ -547,7 +549,7 @@ void _FASTCALL ProcessEntityPT(CachedEntity *ent) transparent = true; // Bone esp - if (draw_bones && ent->m_Type == ENTITY_PLAYER) + if (draw_bones && type == ENTITY_PLAYER) { const model_t *model = modelcache[ent->m_IDX]; if (model) @@ -558,7 +560,7 @@ void _FASTCALL ProcessEntityPT(CachedEntity *ent) } // Tracers - if (tracers && ent->m_Type == ENTITY_PLAYER) + if (tracers && type == ENTITY_PLAYER) { // Grab the screen resolution and save to some vars @@ -581,7 +583,7 @@ void _FASTCALL ProcessEntityPT(CachedEntity *ent) } // Sightline esp - if (sightlines && ent->m_Type == ENTITY_PLAYER) + if (sightlines && type == ENTITY_PLAYER) { // Logic for using the enum to sort out snipers @@ -686,7 +688,7 @@ void _FASTCALL ProcessEntityPT(CachedEntity *ent) // Box esp if (box_esp || box_3d_player || box_3d_building) { - switch (ent->m_Type) + switch (type) { case ENTITY_PLAYER: if (vischeck && !ent->IsVisible()) @@ -723,7 +725,7 @@ void _FASTCALL ProcessEntityPT(CachedEntity *ent) { // We only want health bars on players and buildings - if (ent->m_Type == ENTITY_PLAYER || ent->m_Type == ENTITY_BUILDING) + if (type == ENTITY_PLAYER || type == ENTITY_BUILDING) { // Get collidable from the cache @@ -739,7 +741,7 @@ void _FASTCALL ProcessEntityPT(CachedEntity *ent) // Get health values int health = 0; int healthmax = 0; - switch (ent->m_Type) + switch (type) { case ENTITY_PLAYER: health = CE_INT(ent, netvar.iHealth); @@ -755,7 +757,7 @@ void _FASTCALL ProcessEntityPT(CachedEntity *ent) rgba_t hp = colors::Transparent( colors::Health(health, healthmax), fg.a); rgba_t border = - ((ent->m_iClassID() == RCC_PLAYER) && + ((classid == RCC_PLAYER) && IsPlayerInvisible(ent)) ? colors::FromRGBA8(160, 160, 160, fg.a * 255.0f) : colors::Transparent(colors::black, fg.a); @@ -781,7 +783,7 @@ void _FASTCALL ProcessEntityPT(CachedEntity *ent) bool origin_is_zero = true; // Only get collidable for players and buildings - if (ent->m_Type == ENTITY_PLAYER || ent->m_Type == ENTITY_BUILDING) + if (type == ENTITY_PLAYER || type == ENTITY_BUILDING) { // Get collidable from the cache @@ -883,7 +885,7 @@ void _FASTCALL ProcessEntityPT(CachedEntity *ent) // TODO Add Rotation matix // TODO Currently crashes, needs null check somewhere // Draw Hitboxes - /*if (draw_hitbox && ent->m_Type == ENTITY_PLAYER) { + /*if (draw_hitbox && type == ENTITY_PLAYER) { PROF_SECTION(PT_esp_drawhitbboxes); // Loop through hitboxes @@ -936,12 +938,13 @@ void _FASTCALL ProcessEntity(CachedEntity *ent) if (CE_BAD(ent)) return; // CE_BAD check to prevent crashes + int classid = ent->m_iClassID(); // Entity esp if (entity_info) { AddEntityString(ent, format(RAW_ENT(ent)->GetClientClass()->m_pNetworkName, - " [", ent->m_iClassID(), "]")); + " [", classid, "]")); if (entity_id) { AddEntityString(ent, std::to_string(ent->m_IDX)); @@ -959,13 +962,13 @@ void _FASTCALL ProcessEntity(CachedEntity *ent) ESPData &espdata = data[ent->m_IDX]; // Projectile esp - if (ent->m_Type == ENTITY_PROJECTILE && proj_esp && + if (ent->m_Type() == ENTITY_PROJECTILE && proj_esp && (ent->m_bEnemy() || (teammates && !proj_enemy))) { // Rockets - if (ent->m_iClassID() == CL_CLASS(CTFProjectile_Rocket) || - ent->m_iClassID() == CL_CLASS(CTFProjectile_SentryRocket)) + if (classid == CL_CLASS(CTFProjectile_Rocket) || + classid == CL_CLASS(CTFProjectile_SentryRocket)) { if (proj_rockets) { @@ -977,7 +980,7 @@ void _FASTCALL ProcessEntity(CachedEntity *ent) // Pills/Stickys } - else if (ent->m_iClassID() == CL_CLASS(CTFGrenadePipebombProjectile)) + else if (classid == CL_CLASS(CTFGrenadePipebombProjectile)) { // Switch based on pills/stickys switch (CE_INT(ent, netvar.iPipeType)) @@ -999,7 +1002,7 @@ void _FASTCALL ProcessEntity(CachedEntity *ent) // Huntsman } - else if (ent->m_iClassID() == CL_CLASS(CTFProjectile_Arrow)) + else if (classid == CL_CLASS(CTFProjectile_Arrow)) { if ((int) proj_arrows != 2 || ent->m_bCritProjectile()) { @@ -1016,27 +1019,27 @@ void _FASTCALL ProcessEntity(CachedEntity *ent) if (CE_BYTE(ent, netvar.hOwner) == (unsigned char) -1) { int string_count_backup = data[ent->m_IDX].string_count; - if (ent->m_iClassID() == CL_CLASS(CWeapon_SLAM)) + if (classid == CL_CLASS(CWeapon_SLAM)) AddEntityString(ent, "SLAM"); - else if (ent->m_iClassID() == CL_CLASS(CWeapon357)) + else if (classid == CL_CLASS(CWeapon357)) AddEntityString(ent, ".357"); - else if (ent->m_iClassID() == CL_CLASS(CWeaponAR2)) + else if (classid == CL_CLASS(CWeaponAR2)) AddEntityString(ent, "AR2"); - else if (ent->m_iClassID() == CL_CLASS(CWeaponAlyxGun)) + else if (classid == CL_CLASS(CWeaponAlyxGun)) AddEntityString(ent, "Alyx Gun"); - else if (ent->m_iClassID() == CL_CLASS(CWeaponAnnabelle)) + else if (classid == CL_CLASS(CWeaponAnnabelle)) AddEntityString(ent, "Annabelle"); - else if (ent->m_iClassID() == CL_CLASS(CWeaponBinoculars)) + else if (classid == CL_CLASS(CWeaponBinoculars)) AddEntityString(ent, "Binoculars"); - else if (ent->m_iClassID() == CL_CLASS(CWeaponBugBait)) + else if (classid == CL_CLASS(CWeaponBugBait)) AddEntityString(ent, "Bug Bait"); - else if (ent->m_iClassID() == CL_CLASS(CWeaponCrossbow)) + else if (classid == CL_CLASS(CWeaponCrossbow)) AddEntityString(ent, "Crossbow"); - else if (ent->m_iClassID() == CL_CLASS(CWeaponShotgun)) + else if (classid == CL_CLASS(CWeaponShotgun)) AddEntityString(ent, "Shotgun"); - else if (ent->m_iClassID() == CL_CLASS(CWeaponSMG1)) + else if (classid == CL_CLASS(CWeaponSMG1)) AddEntityString(ent, "SMG"); - else if (ent->m_iClassID() == CL_CLASS(CWeaponRPG)) + else if (classid == CL_CLASS(CWeaponRPG)) AddEntityString(ent, "RPG"); if (string_count_backup != data[ent->m_IDX].string_count) { @@ -1046,14 +1049,15 @@ void _FASTCALL ProcessEntity(CachedEntity *ent) } } + int itemtype = ent->m_ItemType(); // Tank esp - if (ent->m_iClassID() == CL_CLASS(CTFTankBoss) && tank) + if (classid == CL_CLASS(CTFTankBoss) && tank) { AddEntityString(ent, "Tank"); // Dropped weapon esp } - else if (ent->m_iClassID() == CL_CLASS(CTFDroppedWeapon) && item_esp && + else if (classid == CL_CLASS(CTFDroppedWeapon) && item_esp && item_dropped_weapons) { AddEntityString( @@ -1061,7 +1065,7 @@ void _FASTCALL ProcessEntity(CachedEntity *ent) // MVM Money esp } - else if (ent->m_iClassID() == CL_CLASS(CCurrencyPack) && item_money) + else if (classid == CL_CLASS(CCurrencyPack) && item_money) { if (CE_BYTE(ent, netvar.bDistributed)) { @@ -1077,68 +1081,69 @@ void _FASTCALL ProcessEntity(CachedEntity *ent) // Other item esp } - else if (ent->m_ItemType != ITEM_NONE && item_esp) + else if (itemtype != ITEM_NONE && item_esp) { // Health pack esp - if (item_health_packs && (ent->m_ItemType >= ITEM_HEALTH_SMALL && - ent->m_ItemType <= ITEM_HEALTH_LARGE || - ent->m_ItemType == ITEM_HL_BATTERY)) + if (item_health_packs && (itemtype >= ITEM_HEALTH_SMALL && + itemtype <= ITEM_HEALTH_LARGE || + itemtype == ITEM_HL_BATTERY)) { - if (ent->m_ItemType == ITEM_HEALTH_SMALL) + if (itemtype == ITEM_HEALTH_SMALL) AddEntityString(ent, "[+]"); - if (ent->m_ItemType == ITEM_HEALTH_MEDIUM) + if (itemtype == ITEM_HEALTH_MEDIUM) AddEntityString(ent, "[++]"); - if (ent->m_ItemType == ITEM_HEALTH_LARGE) + if (itemtype == ITEM_HEALTH_LARGE) AddEntityString(ent, "[+++]"); - if (ent->m_ItemType == ITEM_HL_BATTERY) + if (itemtype == ITEM_HL_BATTERY) AddEntityString(ent, "[Z]"); // TF2C Adrenaline esp } - else if (item_adrenaline && ent->m_ItemType == ITEM_TF2C_PILL) + else if (item_adrenaline && itemtype == ITEM_TF2C_PILL) { AddEntityString(ent, "[a]"); // Ammo pack esp } - else if (item_ammo_packs && ent->m_ItemType >= ITEM_AMMO_SMALL && - ent->m_ItemType <= ITEM_AMMO_LARGE) + else if (item_ammo_packs && itemtype >= ITEM_AMMO_SMALL && + itemtype <= ITEM_AMMO_LARGE) { - if (ent->m_ItemType == ITEM_AMMO_SMALL) + if (itemtype == ITEM_AMMO_SMALL) AddEntityString(ent, "{i}"); - if (ent->m_ItemType == ITEM_AMMO_MEDIUM) + if (itemtype == ITEM_AMMO_MEDIUM) AddEntityString(ent, "{ii}"); - if (ent->m_ItemType == ITEM_AMMO_LARGE) + if (itemtype == ITEM_AMMO_LARGE) AddEntityString(ent, "{iii}"); // Powerup esp } - else if (item_powerups && ent->m_ItemType >= ITEM_POWERUP_FIRST && - ent->m_ItemType <= ITEM_POWERUP_LAST) + else if (item_powerups && itemtype >= ITEM_POWERUP_FIRST && + itemtype <= ITEM_POWERUP_LAST) { AddEntityString( - ent, format(powerups[ent->m_ItemType - ITEM_POWERUP_FIRST], + ent, format(powerups[itemtype - ITEM_POWERUP_FIRST], " PICKUP")); // TF2C weapon spawner esp } - else if (item_weapon_spawners && ent->m_ItemType >= ITEM_TF2C_W_FIRST && - ent->m_ItemType <= ITEM_TF2C_W_LAST) + else if (item_weapon_spawners && + itemtype >= ITEM_TF2C_W_FIRST && + itemtype <= ITEM_TF2C_W_LAST) { AddEntityString( ent, - format(tf2c_weapon_names[ent->m_ItemType - ITEM_TF2C_W_FIRST], + format(tf2c_weapon_names[itemtype - ITEM_TF2C_W_FIRST], " SPAWNER")); if (CE_BYTE(ent, netvar.bRespawning)) AddEntityString(ent, "-- RESPAWNING --"); // Halloween spell esp } - else if (item_spellbooks && (ent->m_ItemType == ITEM_SPELL || - ent->m_ItemType == ITEM_SPELL_RARE)) + else if (item_spellbooks && (itemtype == ITEM_SPELL || + itemtype == ITEM_SPELL_RARE)) { - if (ent->m_ItemType == ITEM_SPELL) + if (itemtype == ITEM_SPELL) { AddEntityString(ent, "Spell", colors::green); } @@ -1151,7 +1156,7 @@ void _FASTCALL ProcessEntity(CachedEntity *ent) // Building esp } - else if (ent->m_Type == ENTITY_BUILDING && buildings) + else if (ent->m_Type() == ENTITY_BUILDING && buildings) { // Check if enemy building @@ -1169,9 +1174,9 @@ void _FASTCALL ProcessEntity(CachedEntity *ent) if (show_name || show_class) { const std::string &name = - (ent->m_iClassID() == CL_CLASS(CObjectTeleporter) + (classid == CL_CLASS(CObjectTeleporter) ? "Teleporter" - : (ent->m_iClassID() == CL_CLASS(CObjectSentrygun) + : (classid == CL_CLASS(CObjectSentrygun) ? "Sentry Gun" : "Dispenser")); int level = CE_INT(ent, netvar.iUpgradeLevel); @@ -1190,7 +1195,7 @@ void _FASTCALL ProcessEntity(CachedEntity *ent) // Player esp } - else if (ent->m_Type == ENTITY_PLAYER && ent->m_bAlivePlayer()) + else if (ent->m_Type() == ENTITY_PLAYER && ent->m_bAlivePlayer()) { // Local player handling diff --git a/src/hacks/FollowBot.cpp b/src/hacks/FollowBot.cpp index 28c51bd2..9ed301ca 100644 --- a/src/hacks/FollowBot.cpp +++ b/src/hacks/FollowBot.cpp @@ -87,7 +87,7 @@ void WorldTick() auto entity = ENTITY(i); if (CE_BAD(entity)) // Exist + dormant continue; - if (entity->m_Type != ENTITY_PLAYER) + if (entity->m_Type() != ENTITY_PLAYER) continue; if ((int) follow_steam + 18 != entity->player_info.friendsID) // steamid check @@ -114,7 +114,7 @@ void WorldTick() if (CE_BAD(entity)) // Exist + dormant continue; if (!followcart) - if (entity->m_Type != ENTITY_PLAYER) + if (entity->m_Type() != ENTITY_PLAYER) continue; if (entity == LOCAL_E) // Follow self lol continue; @@ -137,7 +137,7 @@ void WorldTick() model == lagexploit::pointarr[3] || model == lagexploit::pointarr[4])) follow_target = entity->m_IDX; - if (entity->m_Type != ENTITY_PLAYER) + if (entity->m_Type() != ENTITY_PLAYER) continue; if (follow_target && ENTITY(follow_target)->m_flDistance() > diff --git a/src/hacks/LagExploit.cpp b/src/hacks/LagExploit.cpp index de5445b1..eadaf21d 100644 --- a/src/hacks/LagExploit.cpp +++ b/src/hacks/LagExploit.cpp @@ -101,7 +101,7 @@ void CreateMove() return; if (exticks > 0) exticks--; - + int classid = LOCAL_W->m_iClassID(); if (!exticks) { // Infinite pickups (health and ammo) @@ -138,9 +138,9 @@ void CreateMove() // Lag for health if (LOCAL_E->m_iHealth() < LOCAL_E->m_iMaxHealth() && - (e->m_ItemType == ITEM_HEALTH_SMALL || - e->m_ItemType == ITEM_HEALTH_MEDIUM || - e->m_ItemType == ITEM_HEALTH_LARGE)) + (e->m_ItemType() == ITEM_HEALTH_SMALL || + e->m_ItemType() == ITEM_HEALTH_MEDIUM || + e->m_ItemType() == ITEM_HEALTH_LARGE)) { AddExploitTicks(3); } @@ -149,9 +149,9 @@ void CreateMove() // LOCAL_E->m_iMaxAmmo That is pseudocode but checking each // weapon for ammo + engie for metal would be ideal if (CE_INT(g_pLocalPlayer->weapon(), netvar.m_iAmmo) < 5 && - (e->m_ItemType == ITEM_AMMO_SMALL || - e->m_ItemType == ITEM_AMMO_MEDIUM || - e->m_ItemType == ITEM_AMMO_LARGE)) + (e->m_ItemType() == ITEM_AMMO_SMALL || + e->m_ItemType() == ITEM_AMMO_MEDIUM || + e->m_ItemType() == ITEM_AMMO_LARGE)) { AddExploitTicks(3); } @@ -301,11 +301,11 @@ void CreateMove() amount = 2 * 90; } else if (CanShoot() && bIsHolding && !bWasHolding && - g_pLocalPlayer->weapon()->m_iClassID() != + classid != CL_CLASS(CTFFlareGun)) amount = 1 * 90; else if (CanShoot() && bIsHolding && !bWasHolding && - g_pLocalPlayer->weapon()->m_iClassID() == + classid == CL_CLASS(CTFFlareGun)) amount = 2 * 90; else if (bWasHolding && !bIsHolding) @@ -321,11 +321,11 @@ void CreateMove() if (not g_pLocalPlayer->holding_sniper_rifle) { if (CanShoot() && bIsHolding && !bWasHolding && - g_pLocalPlayer->weapon()->m_iClassID() != + classid != CL_CLASS(CTFFlareGun)) amount = 1 * 90; else if (CanShoot() && bIsHolding && !bWasHolding && - g_pLocalPlayer->weapon()->m_iClassID() == + classid == CL_CLASS(CTFFlareGun)) amount = 2 * 90; else if (bWasHolding && !bIsHolding) @@ -372,8 +372,8 @@ void CreateMove() // Thanks Wheaties For help! if (stickyspam) { - if (g_pLocalPlayer->weapon()->m_iClassID() == (CL_CLASS(CTFCannon)) || - g_pLocalPlayer->weapon()->m_iClassID() == + if (classid == (CL_CLASS(CTFCannon)) || + classid == (CL_CLASS(CTFPipebombLauncher))) { static bool bSwitch = false; @@ -387,7 +387,7 @@ void CreateMove() } static int charge = 0; if (g_pLocalPlayer->bAttackLastTick && infinitecharge && - g_pLocalPlayer->weapon()->m_iClassID() == + classid == (CL_CLASS(CTFPipebombLauncher)) && (g_pUserCmd->buttons & IN_ATTACK) && CE_BYTE(LOCAL_W, netvar.m_flChargeLevel)) @@ -400,10 +400,10 @@ void CreateMove() charge = 0; if (instant_weapon_switch && not HasCondition(LOCAL_E)) { - if (lastwep != g_pLocalPlayer->weapon()->m_iClassID()) + if (lastwep != classid) { amount = 4 * 66; - lastwep = g_pLocalPlayer->weapon()->m_iClassID(); + lastwep = classid; } } // SHOUTOUTS TO BLACKFIRE @@ -420,11 +420,11 @@ void CreateMove() // than 0.1f // Get a new nextattack(2) if (!nextattack || i < 0.1f || - g_pLocalPlayer->weapon()->m_iClassID() != lastwep) + classid != lastwep) nextattack = CE_FLOAT(g_pLocalPlayer->weapon(), netvar.flNextPrimaryAttack); if (!nextattack2 || i2 < 0.1f || - g_pLocalPlayer->weapon()->m_iClassID() != lastwep) + classid != lastwep) nextattack2 = CE_FLOAT(g_pLocalPlayer->weapon(), netvar.flNextSecondaryAttack); // If the next attack (2) time would exceed 75 seconds, set it to 75 to @@ -487,7 +487,7 @@ void CreateMove() if (CE_BAD(snoiper)) return; // Only works with knife out obviously - if (g_pLocalPlayer->weapon()->m_iClassID() == CL_CLASS(CTFKnife)) + if (classid == CL_CLASS(CTFKnife)) { if (!i) i = 3; @@ -500,7 +500,7 @@ void CreateMove() if (i > 0.1f) i -= 1.0f; // Set last weapon classid - lastwep = g_pLocalPlayer->weapon()->m_iClassID(); + lastwep = classid; } // if Jarate spam active if (piss) @@ -512,11 +512,11 @@ void CreateMove() // Get nextattack when it's invalid or the player selected another // weapon (which is a tick, not a time like 1 second, but servertime + 1 // second) - if (!nextattack || g_pLocalPlayer->weapon()->m_iClassID() != lastwep) + if (!nextattack || classid != lastwep) nextattack = CE_FLOAT(g_pLocalPlayer->weapon(), netvar.flNextPrimaryAttack); // Set last weapon since it's not needed anymore this cycle - lastwep = g_pLocalPlayer->weapon()->m_iClassID(); + lastwep = classid; // Check if holding JARAAATE if (CE_INT(g_pLocalPlayer->weapon(), netvar.iItemDefinitionIndex) == 58) { diff --git a/src/hacks/Misc.cpp b/src/hacks/Misc.cpp index 7e6d0736..a2d0b3d4 100644 --- a/src/hacks/Misc.cpp +++ b/src/hacks/Misc.cpp @@ -403,7 +403,7 @@ void DrawText() CachedEntity *ent = ENTITY(i); player_info_s info; if (!CE_BAD(ent) && ent != LOCAL_E && - ent->m_Type == ENTITY_PLAYER && + ent->m_Type() == ENTITY_PLAYER && (CE_INT(ent, netvar.hObserverTarget) & 0xFFF) == LOCAL_E->m_IDX && CE_INT(ent, netvar.iObserverMode) >= 4 && @@ -503,7 +503,7 @@ void DrawText() for (int i = 0; i < HIGHEST_ENTITY; i++) { CachedEntity* e = ENTITY(i); if (CE_GOOD(e)) { - if (e->m_Type == EntityType::ENTITY_PROJECTILE) { + if (e->m_Type() == EntityType::ENTITY_PROJECTILE) { //logging::Info("Entity %i [%s]: V %.2f (X: %.2f, Y: %.2f, Z: %.2f) ACC %.2f (X: %.2f, Y: %.2f, Z: %.2f)", i, RAW_ENT(e)->GetClientClass()->GetName(), e->m_vecVelocity.Length(), diff --git a/src/hacks/Radar.cpp b/src/hacks/Radar.cpp index 296f17df..f61ae810 100644 --- a/src/hacks/Radar.cpp +++ b/src/hacks/Radar.cpp @@ -124,7 +124,7 @@ void DrawEntity(int x, int y, CachedEntity *ent) if (CE_GOOD(ent)) { - if (ent->m_Type == ENTITY_PLAYER) + if (ent->m_Type() == ENTITY_PLAYER) { if (CE_BYTE(ent, netvar.iLifeState)) return; // DEAD. not big surprise. @@ -172,7 +172,7 @@ void DrawEntity(int x, int y, CachedEntity *ent) ((float) icon_size - 2.0f) * healthp, 2, clr); } } - else if (ent->m_Type == ENTITY_BUILDING) + else if (ent->m_Type() == ENTITY_BUILDING) { /*if (ent->m_iClassID() == CL_CLASS(CObjectDispenser)) { const int& team = CE_INT(ent, netvar.iTeamNum); @@ -194,11 +194,11 @@ void DrawEntity(int x, int y, CachedEntity *ent) } }*/ } - else if (ent->m_Type == ENTITY_GENERIC) + else if (ent->m_Type() == ENTITY_GENERIC) { - if (show_healthpacks && (ent->m_ItemType == ITEM_HEALTH_LARGE || - ent->m_ItemType == ITEM_HEALTH_MEDIUM || - ent->m_ItemType == ITEM_HEALTH_SMALL)) + if (show_healthpacks && (ent->m_ItemType() == ITEM_HEALTH_LARGE || + ent->m_ItemType() == ITEM_HEALTH_MEDIUM || + ent->m_ItemType() == ITEM_HEALTH_SMALL)) { const auto &wtr = WorldToRadar(ent->m_vecOrigin().x, ent->m_vecOrigin().y); @@ -207,9 +207,9 @@ void DrawEntity(int x, int y, CachedEntity *ent) tx_items[1].sprite.draw(x + wtr.first + sz, y + wtr.second + sz, sz2, sz2, colors::white); } - else if (show_ammopacks && (ent->m_ItemType == ITEM_AMMO_LARGE || - ent->m_ItemType == ITEM_AMMO_MEDIUM || - ent->m_ItemType == ITEM_AMMO_SMALL)) + else if (show_ammopacks && (ent->m_ItemType() == ITEM_AMMO_LARGE || + ent->m_ItemType() == ITEM_AMMO_MEDIUM || + ent->m_ItemType() == ITEM_AMMO_SMALL)) { const auto &wtr = WorldToRadar(ent->m_vecOrigin().x, ent->m_vecOrigin().y); @@ -256,13 +256,13 @@ void Draw() continue; if (i == g_IEngine->GetLocalPlayer()) continue; - if (ent->m_Type == ENTITY_PLAYER) + if (ent->m_Type() == ENTITY_PLAYER) { if (!ent->m_bEnemy() && !show_teammates) continue; } if (!enemies_over_teammates || !show_teammates || - ent->m_Type != ENTITY_PLAYER) + ent->m_Type() != ENTITY_PLAYER) DrawEntity(x, y, ent); else { diff --git a/src/hacks/Trigger.cpp b/src/hacks/Trigger.cpp index 9fd6331a..279898c2 100644 --- a/src/hacks/Trigger.cpp +++ b/src/hacks/Trigger.cpp @@ -85,7 +85,7 @@ bool CanBacktrack(CachedEntity *entity) { if (CE_BAD(entity)) return false; - if (entity->m_Type != ENTITY_PLAYER) + if (entity->m_Type() != ENTITY_PLAYER) return false; int tick = hacks::shared::backtrack::Besttick(entity); auto min = hacks::shared::backtrack::headPositions[entity->m_IDX][tick].min; @@ -117,7 +117,7 @@ bool CanBacktrack(CachedEntity *entity) return false; if (CheckLineBox(minz, maxz, g_pLocalPlayer->v_Eye, forward, hit)) { - hacks::shared::backtrack::dontbacktrack = true; + hacks::shared::backtrack::dontbacktrack = true; hacks::shared::backtrack::Backtrack(entity, tick); return true; } @@ -266,7 +266,7 @@ bool IsTargetStateGood(CachedEntity *entity) { // Check for Players - if (entity->m_Type == ENTITY_PLAYER) + if (entity->m_Type() == ENTITY_PLAYER) { // Check if target is The local player if (entity == LOCAL_E) @@ -377,7 +377,7 @@ bool IsTargetStateGood(CachedEntity *entity) // Check for buildings } - else if (entity->m_Type == ENTITY_BUILDING) + else if (entity->m_Type() == ENTITY_BUILDING) { // Check if building aimbot is enabled if (!(buildings_other || buildings_sentry)) diff --git a/src/helpers.cpp b/src/helpers.cpp index 4222bd0e..d0af3f05 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -149,11 +149,12 @@ const char *GetBuildingName(CachedEntity *ent) { if (!ent) return "[NULL]"; - if (ent->m_iClassID() == CL_CLASS(CObjectSentrygun)) + int classid = ent->m_iClassID(); + if (classid == CL_CLASS(CObjectSentrygun)) return "Sentry"; - if (ent->m_iClassID() == CL_CLASS(CObjectDispenser)) + if (classid == CL_CLASS(CObjectDispenser)) return "Dispenser"; - if (ent->m_iClassID() == CL_CLASS(CObjectTeleporter)) + if (classid == CL_CLASS(CObjectTeleporter)) return "Teleporter"; return "[NULL]"; } @@ -513,11 +514,12 @@ Vector GetBuildingPosition(CachedEntity *ent) { Vector res; res = ent->m_vecOrigin(); - if (ent->m_iClassID() == CL_CLASS(CObjectDispenser)) + int classid = ent->m_iClassID(); + if (classid == CL_CLASS(CObjectDispenser)) res.z += 30; - if (ent->m_iClassID() == CL_CLASS(CObjectTeleporter)) + if (classid == CL_CLASS(CObjectTeleporter)) res.z += 8; - if (ent->m_iClassID() == CL_CLASS(CObjectSentrygun)) + if (classid == CL_CLASS(CObjectSentrygun)) { switch (CE_INT(ent, netvar.iUpgradeLevel)) { @@ -574,7 +576,7 @@ void Patch(void *address, void *patch, size_t length) bool IsProjectileCrit(CachedEntity *ent) { - if (ent->m_bGrenadeProjectile) + if (ent->m_bGrenadeProjectile()) return CE_BYTE(ent, netvar.Grenade_bCritical); return CE_BYTE(ent, netvar.Rocket_bCritical); } @@ -595,6 +597,7 @@ weaponmode GetWeaponMode() weapon = (ENTITY(weapon_handle & 0xFFF)); if (CE_BAD(weapon)) return weaponmode::weapon_invalid; + int classid = weapon->m_iClassID(); slot = re::C_BaseCombatWeapon::GetSlot(RAW_ENT(weapon)); if (slot == 2) return weaponmode::weapon_melee; @@ -602,34 +605,34 @@ weaponmode GetWeaponMode() { return weaponmode::weapon_pda; } - else if (weapon->m_iClassID() == CL_CLASS(CTFLunchBox) || - weapon->m_iClassID() == CL_CLASS(CTFLunchBox_Drink) || - weapon->m_iClassID() == CL_CLASS(CTFBuffItem)) + else if (classid == CL_CLASS(CTFLunchBox) || + classid == CL_CLASS(CTFLunchBox_Drink) || + classid == CL_CLASS(CTFBuffItem)) { return weaponmode::weapon_consumable; } - else if (weapon->m_iClassID() == CL_CLASS(CTFRocketLauncher_DirectHit) || - weapon->m_iClassID() == CL_CLASS(CTFRocketLauncher) || - weapon->m_iClassID() == CL_CLASS(CTFGrenadeLauncher) || - weapon->m_iClassID() == CL_CLASS(CTFPipebombLauncher) || - weapon->m_iClassID() == CL_CLASS(CTFCompoundBow) || - weapon->m_iClassID() == CL_CLASS(CTFBat_Wood) || - weapon->m_iClassID() == CL_CLASS(CTFBat_Giftwrap) || - weapon->m_iClassID() == CL_CLASS(CTFFlareGun) || - weapon->m_iClassID() == CL_CLASS(CTFFlareGun_Revenge) || - weapon->m_iClassID() == CL_CLASS(CTFSyringeGun) || - weapon->m_iClassID() == CL_CLASS(CTFCrossbow) || - weapon->m_iClassID() == CL_CLASS(CTFShotgunBuildingRescue) || - weapon->m_iClassID() == CL_CLASS(CTFDRGPomson)) + else if (classid == CL_CLASS(CTFRocketLauncher_DirectHit) || + classid == CL_CLASS(CTFRocketLauncher) || + classid == CL_CLASS(CTFGrenadeLauncher) || + classid == CL_CLASS(CTFPipebombLauncher) || + classid == CL_CLASS(CTFCompoundBow) || + classid == CL_CLASS(CTFBat_Wood) || + classid == CL_CLASS(CTFBat_Giftwrap) || + classid == CL_CLASS(CTFFlareGun) || + classid == CL_CLASS(CTFFlareGun_Revenge) || + classid == CL_CLASS(CTFSyringeGun) || + classid == CL_CLASS(CTFCrossbow) || + classid == CL_CLASS(CTFShotgunBuildingRescue) || + classid == CL_CLASS(CTFDRGPomson)) { return weaponmode::weapon_projectile; } - else if (weapon->m_iClassID() == CL_CLASS(CTFJar) || - weapon->m_iClassID() == CL_CLASS(CTFJarMilk)) + else if (classid == CL_CLASS(CTFJar) || + classid == CL_CLASS(CTFJarMilk)) { return weaponmode::weapon_throwable; } - else if (weapon->m_iClassID() == CL_CLASS(CWeaponMedigun)) + else if (classid == CL_CLASS(CWeaponMedigun)) { return weaponmode::weapon_medigun; } @@ -667,15 +670,16 @@ bool GetProjectileData(CachedEntity *weapon, float &speed, float &gravity) rgrav = 0.0f; typedef float(GetProjectileData)(IClientEntity *); - if (weapon->m_iClassID() == CL_CLASS(CTFRocketLauncher_DirectHit)) + int classid = weapon->m_iClassID(); + if (classid == CL_CLASS(CTFRocketLauncher_DirectHit)) { rspeed = 1980.0f; } - else if (weapon->m_iClassID() == CL_CLASS(CTFRocketLauncher)) + else if (classid == CL_CLASS(CTFRocketLauncher)) { rspeed = 1100.0f; } - else if (weapon->m_iClassID() == CL_CLASS(CTFGrenadeLauncher)) + else if (classid == CL_CLASS(CTFGrenadeLauncher)) { IF_GAME(IsTF2()) { @@ -688,7 +692,7 @@ bool GetProjectileData(CachedEntity *weapon, float &speed, float &gravity) rgrav = 0.5f; } } - else if (weapon->m_iClassID() == CL_CLASS(CTFCompoundBow)) + else if (classid == CL_CLASS(CTFCompoundBow)) { float chargetime = g_GlobalVars->curtime - CE_FLOAT(weapon, netvar.flChargeBeginTime); @@ -698,36 +702,36 @@ bool GetProjectileData(CachedEntity *weapon, float &speed, float &gravity) -0.40000001) + 0.5); } - else if (weapon->m_iClassID() == CL_CLASS(CTFBat_Wood)) + else if (classid == CL_CLASS(CTFBat_Wood)) { rspeed = 3000.0f; rgrav = 0.5f; } - else if (weapon->m_iClassID() == CL_CLASS(CTFFlareGun)) + else if (classid == CL_CLASS(CTFFlareGun)) { rspeed = 2000.0f; rgrav = 0.25f; } - else if (weapon->m_iClassID() == CL_CLASS(CTFSyringeGun)) + else if (classid == CL_CLASS(CTFSyringeGun)) { rgrav = 0.2f; rspeed = 990.0f; } - else if (weapon->m_iClassID() == CL_CLASS(CTFCrossbow)) + else if (classid == CL_CLASS(CTFCrossbow)) { rgrav = 0.2f; rspeed = 2400.0f; } - else if (weapon->m_iClassID() == CL_CLASS(CTFShotgunBuildingRescue)) + else if (classid == CL_CLASS(CTFShotgunBuildingRescue)) { rgrav = 0.2f; rspeed = 2400.0f; } - else if (weapon->m_iClassID() == CL_CLASS(CTFDRGPomson)) + else if (classid == CL_CLASS(CTFDRGPomson)) { rspeed = 1200.0f; } - else if (weapon->m_iClassID() == CL_CLASS(CTFWeaponFlameBall)) + else if (classid == CL_CLASS(CTFWeaponFlameBall)) { // ?? rspeed = 2500.0f; @@ -816,7 +820,7 @@ void WhatIAmLookingAt(int *result_eindex, Vector *result_pos) bool IsSentryBuster(CachedEntity *entity) { - return (entity->m_Type == EntityType::ENTITY_PLAYER && + return (entity->m_Type() == EntityType::ENTITY_PLAYER && CE_INT(entity, netvar.iClass) == tf_class::tf_demoman && g_pPlayerResource->GetMaxHealth(entity) == 2500); } diff --git a/src/hooks/CreateMove.cpp b/src/hooks/CreateMove.cpp index 039a8ead..488b1608 100644 --- a/src/hooks/CreateMove.cpp +++ b/src/hooks/CreateMove.cpp @@ -524,9 +524,8 @@ DEFINE_HOOKED_METHOD(CreateMove, bool, void *this_, float input_sample_time, ch->SendNetMsg(senddata); ch->Transmit(); } - if (serverlag_amount || - (votelogger::active && - !votelogger::antikick.check(antikick_time * 1000))) + if (serverlag_amount || (votelogger::active && + !votelogger::antikick.check(antikick_time * 1000))) { if (adjust && !votelogger::active) { @@ -546,7 +545,7 @@ DEFINE_HOOKED_METHOD(CreateMove, bool, void *this_, float input_sample_time, } } else if (votelogger::active && - !votelogger::antikick.test_and_set(antikick_time * 1000)) + !votelogger::antikick.check(antikick_time * 1000)) { static int additionallag = 1; if (ch->GetAvgData(FLOW_INCOMING) == prevflow) diff --git a/src/hooks/GetFriendPersonaName.cpp b/src/hooks/GetFriendPersonaName.cpp index 7f11a376..7a9d9fea 100644 --- a/src/hooks/GetFriendPersonaName.cpp +++ b/src/hooks/GetFriendPersonaName.cpp @@ -37,7 +37,7 @@ bool StolenName() continue; if (ent == LOCAL_E) continue; - if (!ent->m_Type == ENTITY_PLAYER) + if (!ent->m_Type() == ENTITY_PLAYER) continue; if (ent->m_bEnemy()) continue; diff --git a/src/prediction.cpp b/src/prediction.cpp index 97b85656..0d86afe7 100644 --- a/src/prediction.cpp +++ b/src/prediction.cpp @@ -216,7 +216,7 @@ Vector ProjectilePrediction_Engine(CachedEntity *ent, int hb, float speed, Vector current = origin; int maxsteps = 40; bool onground = false; - if (ent->m_Type == ENTITY_PLAYER) + if (ent->m_Type() == ENTITY_PLAYER) { if (CE_INT(ent, netvar.iFlags) & FL_ONGROUND) onground = true; @@ -326,7 +326,7 @@ Vector ProjectilePrediction(CachedEntity *ent, int hb, float speed, float DistanceToGround(CachedEntity *ent) { - if (ent->m_Type == ENTITY_PLAYER) + if (ent->m_Type() == ENTITY_PLAYER) { if (CE_INT(ent, netvar.iFlags) & FL_ONGROUND) return 0; diff --git a/src/projlogging.cpp b/src/projlogging.cpp index 52b26837..d66c1acf 100755 --- a/src/projlogging.cpp +++ b/src/projlogging.cpp @@ -18,7 +18,7 @@ void Update() CachedEntity *ent = ENTITY(i); if (CE_BAD(ent)) continue; - if (ent->m_Type == ENTITY_PROJECTILE) + if (ent->m_Type() == ENTITY_PROJECTILE) { int owner = CE_INT(ent, 0x894) & 0xFFF; if (owner != LOCAL_W->m_IDX) diff --git a/src/targethelper.cpp b/src/targethelper.cpp index ed64386c..55d8ae6c 100644 --- a/src/targethelper.cpp +++ b/src/targethelper.cpp @@ -23,7 +23,7 @@ int GetScoreForEntity(CachedEntity *entity) if (!entity) return 0; // TODO - if (entity->m_Type == ENTITY_BUILDING) + if (entity->m_Type() == ENTITY_BUILDING) { if (entity->m_iClassID() == CL_CLASS(CObjectSentrygun)) { diff --git a/src/visual/EffectChams.cpp b/src/visual/EffectChams.cpp index 674a7048..ee303a32 100644 --- a/src/visual/EffectChams.cpp +++ b/src/visual/EffectChams.cpp @@ -126,7 +126,7 @@ rgba_t EffectChams::ChamsColor(IClientEntity *entity) return ChamsColor(owner); } } - switch (ent->m_Type) + switch (ent->m_Type()) { case ENTITY_BUILDING: if (!ent->m_bEnemy() && !(teammates || teammate_buildings) && @@ -169,7 +169,7 @@ bool EffectChams::ShouldRenderChams(IClientEntity *entity) return false; if (ent->m_IDX == LOCAL_E->m_IDX && !chamsself) return false; - switch (ent->m_Type) + switch (ent->m_Type()) { case ENTITY_BUILDING: if (!buildings) @@ -201,7 +201,7 @@ bool EffectChams::ShouldRenderChams(IClientEntity *entity) } break; case ENTITY_GENERIC: - switch (ent->m_ItemType) + switch (ent->m_ItemType()) { case ITEM_HEALTH_LARGE: case ITEM_HEALTH_MEDIUM: diff --git a/src/visual/EffectGlow.cpp b/src/visual/EffectGlow.cpp index 296ff87d..182c6398 100644 --- a/src/visual/EffectGlow.cpp +++ b/src/visual/EffectGlow.cpp @@ -244,7 +244,7 @@ rgba_t EffectGlow::GlowColor(IClientEntity *entity) return GlowColor(owner); } } - switch (ent->m_Type) + switch (ent->m_Type()) { case ENTITY_BUILDING: if (health) @@ -283,7 +283,7 @@ bool EffectGlow::ShouldRenderGlow(IClientEntity *entity) return false; if (ent->m_IDX == LOCAL_E->m_IDX && !glowself) return false; - switch (ent->m_Type) + switch (ent->m_Type()) { case ENTITY_BUILDING: if (!buildings) @@ -310,7 +310,7 @@ bool EffectGlow::ShouldRenderGlow(IClientEntity *entity) } break; case ENTITY_GENERIC: - const auto &type = ent->m_ItemType; + const auto &type = ent->m_ItemType(); if (type >= ITEM_HEALTH_SMALL && type <= ITEM_HEALTH_LARGE) { return medkits; diff --git a/src/visual/colors.cpp b/src/visual/colors.cpp index ecdae731..ea4a2555 100644 --- a/src/visual/colors.cpp +++ b/src/visual/colors.cpp @@ -30,7 +30,7 @@ rgba_t colors::EntityF(CachedEntity *ent) using namespace colors; result = white; - type = ent->m_ItemType; + type = ent->m_ItemType(); if (type) { if ((type >= ITEM_HEALTH_SMALL && type <= ITEM_HEALTH_LARGE) || @@ -71,7 +71,7 @@ rgba_t colors::EntityF(CachedEntity *ent) result = green; } - if (ent->m_Type == ENTITY_PROJECTILE) + if (ent->m_Type() == ENTITY_PROJECTILE) { if (ent->m_iTeam() == TEAM_BLU) result = blu; @@ -86,7 +86,7 @@ rgba_t colors::EntityF(CachedEntity *ent) } } - if (ent->m_Type == ENTITY_PLAYER || ent->m_Type == ENTITY_BUILDING) + if (ent->m_Type() == ENTITY_PLAYER || ent->m_Type() == ENTITY_BUILDING) { if (ent->m_iTeam() == TEAM_BLU) result = blu; @@ -114,7 +114,7 @@ rgba_t colors::EntityF(CachedEntity *ent) break; } } - if (ent->m_Type == ENTITY_PLAYER) + if (ent->m_Type() == ENTITY_PLAYER) { if (IsPlayerInvulnerable(ent)) {