Fix bad use of HIGHEST_ENTITY

This commit is contained in:
BenCat07 2019-06-09 19:12:19 +02:00
parent 25f3dad75b
commit edd7937460
19 changed files with 39 additions and 30 deletions

View File

@ -70,7 +70,7 @@ static settings::Float fovcircle_opacity{ "aimbot.fov-circle.opacity", "0.7" };
int GetSentry() int GetSentry()
{ {
for (int i = 1; i < HIGHEST_ENTITY; i++) for (int i = 1; i <= HIGHEST_ENTITY; i++)
{ {
CachedEntity *ent = ENTITY(i); CachedEntity *ent = ENTITY(i);
if (CE_BAD(ent)) if (CE_BAD(ent))
@ -378,7 +378,7 @@ CachedEntity *RetrieveBestTarget(bool aimkey_state, bool Backtracking)
CachedEntity *ent; CachedEntity *ent;
CachedEntity *target_highest_ent = 0; CachedEntity *target_highest_ent = 0;
target_highest_score = -256; target_highest_score = -256;
for (int i = 1; i < HIGHEST_ENTITY; i++) for (int i = 1; i <= HIGHEST_ENTITY; i++)
{ {
ent = ENTITY(i); ent = ENTITY(i);
if (CE_BAD(ent)) if (CE_BAD(ent))

View File

@ -21,7 +21,7 @@ int NearbyEntities()
int ret = 0; int ret = 0;
if (CE_BAD(LOCAL_E) || CE_BAD(LOCAL_W)) if (CE_BAD(LOCAL_E) || CE_BAD(LOCAL_W))
return ret; return ret;
for (int i = 0; i < HIGHEST_ENTITY; i++) for (int i = 0; i <= HIGHEST_ENTITY; i++)
{ {
CachedEntity *ent = ENTITY(i); CachedEntity *ent = ENTITY(i);
if (CE_BAD(ent)) if (CE_BAD(ent))
@ -49,7 +49,7 @@ static void CreateMove()
return; return;
if (CE_INT(LOCAL_E, netvar.iHealth) < (int) trigger_health && NearbyEntities() > 1) if (CE_INT(LOCAL_E, netvar.iHealth) < (int) trigger_health && NearbyEntities() > 1)
current_user_cmd->buttons |= IN_ATTACK2; current_user_cmd->buttons |= IN_ATTACK2;
for (int i = 0; i < HIGHEST_ENTITY; i++) for (int i = 0; i <= HIGHEST_ENTITY; i++)
{ {
CachedEntity *ent = ENTITY(i); CachedEntity *ent = ENTITY(i);
if (CE_BAD(ent)) if (CE_BAD(ent))

View File

@ -85,7 +85,7 @@ void CreateMove()
targets.clear(); targets.clear();
// Cycle through the ents and search for valid ents // Cycle through the ents and search for valid ents
for (int i = 0; i < HIGHEST_ENTITY; i++) for (int i = 0; i <= HIGHEST_ENTITY; i++)
{ {
// Assign the for loops tick number to an ent // Assign the for loops tick number to an ent
CachedEntity *ent = ENTITY(i); CachedEntity *ent = ENTITY(i);

View File

@ -198,7 +198,7 @@ int BlastDangerValue(CachedEntity *patient)
return 1; return 1;
} }
// Find rockets/pipes nearby // Find rockets/pipes nearby
for (int i = 32; i < HIGHEST_ENTITY; i++) for (int i = 32; i <= HIGHEST_ENTITY; i++)
{ {
CachedEntity *ent = ENTITY(i); CachedEntity *ent = ENTITY(i);
if (CE_BAD(ent)) if (CE_BAD(ent))
@ -233,7 +233,7 @@ int NearbyEntities()
int ret = 0; int ret = 0;
if (CE_BAD(LOCAL_E) || CE_BAD(LOCAL_W)) if (CE_BAD(LOCAL_E) || CE_BAD(LOCAL_W))
return ret; return ret;
for (int i = 0; i < HIGHEST_ENTITY; i++) for (int i = 0; i <= HIGHEST_ENTITY; i++)
{ {
CachedEntity *ent = ENTITY(i); CachedEntity *ent = ENTITY(i);
if (CE_BAD(ent)) if (CE_BAD(ent))

View File

@ -96,7 +96,7 @@ void CreateMove()
float closest_dist = 0.0f; float closest_dist = 0.0f;
Vector closest_vec; Vector closest_vec;
// Loop to find the closest entity // Loop to find the closest entity
for (int i = 0; i < HIGHEST_ENTITY; i++) for (int i = 0; i <= HIGHEST_ENTITY; i++)
{ {
// Find an ent from the for loops current tick // Find an ent from the for loops current tick

View File

@ -349,7 +349,7 @@ static void cm()
{ {
// Try to get a new target // Try to get a new target
auto ent_count = followcart ? HIGHEST_ENTITY : g_IEngine->GetMaxClients(); auto ent_count = followcart ? HIGHEST_ENTITY : g_IEngine->GetMaxClients();
for (int i = 1; i < ent_count; i++) for (int i = 1; i <= ent_count; i++)
{ {
auto entity = ENTITY(i); auto entity = ENTITY(i);
if (CE_INVALID(entity)) // Exist + dormant if (CE_INVALID(entity)) // Exist + dormant

View File

@ -377,7 +377,7 @@ void DrawText()
//if (TF2C) AddSideString(colors::white, "Crits: %i", s_bCrits); //if (TF2C) AddSideString(colors::white, "Crits: %i", s_bCrits);
//if (TF2C) AddSideString(colors::white, "CritMult: %i", //if (TF2C) AddSideString(colors::white, "CritMult: %i",
RemapValClampedNC( CE_INT(LOCAL_E, netvar.iCritMult), 0, 255, 1.0, 6 )); RemapValClampedNC( CE_INT(LOCAL_E, netvar.iCritMult), 0, 255, 1.0, 6 ));
for (int i = 0; i < HIGHEST_ENTITY; i++) { for (int i = 0; i <= HIGHEST_ENTITY; i++) {
CachedEntity* e = ENTITY(i); CachedEntity* e = ENTITY(i);
if (CE_GOOD(e)) { if (CE_GOOD(e)) {
if (e->m_Type() == EntityType::ENTITY_PROJECTILE) { if (e->m_Type() == EntityType::ENTITY_PROJECTILE) {
@ -456,7 +456,7 @@ void Schema_Reload()
CatCommand schema("schema", "Load custom schema", Schema_Reload); CatCommand schema("schema", "Load custom schema", Schema_Reload);
CatCommand update_gui_color("gui_color_update", "Update the GUI Color", []() { CatCommand update_gui_color("gui_color_update", "Update the GUI Color", []() {
hack::command_stack().push("cat set zk.style.tab-button.color.selected.background 446498ff;cat set zk.style.tab-button.color.separator 446498ff;cat set zk.style.tab-button.color.hover.underline 446498ff;cat set zk.style.tab-button.color.selected.underline 446498ff;cat set zk.style.tooltip.border 446498ff;cat set zk.style.box.color.border 446498ff;cat set zk.style.color-preview.color.border 446498ff;cat set zk.style.modal-container.color.border 446498ff;cat set zk.style.tab-selection.color.border 446498ff;cat set zk.style.table.color.border 446498ff;cat set zk.style.checkbox.color.border 446498ff;cat set zk.style.checkbox.color.checked 446498ff;cat set zk.style.checkbox.color.hover 446498ff;cat set zk.style.input.color.border 446498ff;cat set zk.style.input.key.color.border 446498ff;cat set zk.style.input.select.border 446498ff;cat set zk.style.input.slider.color.handle_border 446498ff;cat set zk.style.input.slider.color.bar 446498ff;cat set zk.style.input.text.color.border.active 42BC99ff"); hack::command_stack().push("cat set zk.style.tab-button.color.selected.background 446498ff;cat set zk.style.tab-button.color.separator 446498ff;cat set zk.style.tab-button.color.hover.underline 446498ff;cat set zk.style.tab-button.color.selected.underline 446498ff;cat set zk.style.tooltip.border 446498ff;cat set zk.style.box.color.border 446498ff;cat set zk.style.color-preview.color.border 446498ff;cat set zk.style.modal-container.color.border 446498ff;cat set zk.style.tab-selection.color.border 446498ff;cat set zk.style.table.color.border 446498ff;cat set zk.style.checkbox.color.border 446498ff;cat set zk.style.checkbox.color.checked 446498ff;cat set zk.style.checkbox.color.hover 00a098ff;cat set zk.style.input.color.border 446498ff;cat set zk.style.input.key.color.border 446498ff;cat set zk.style.input.select.border 446498ff;cat set zk.style.input.slider.color.handle_border 446498ff;cat set zk.style.input.slider.color.bar 446498ff;cat set zk.style.input.text.color.border.active 42BC99ff");
hack::command_stack().push("cat set zk.style.input.text.color.border.inactive 446498ff;cat set zk.style.tree-list-entry.color.lines 42BC99ff;cat set zk.style.task.color.background.hover 446498ff;cat set zk.style.task.color.border 446498ff;cat set zk.style.taskbar.color.border 446498ff;cat set zk.style.window.color.border 446498ff;cat set zk.style.window-close-button.color.border 446498ff;cat set zk.style.window-header.color.background.active 446498ff;cat set zk.style.window-header.color.border.inactive 446498ff;cat set zk.style.window-header.color.border.active 446498ff"); hack::command_stack().push("cat set zk.style.input.text.color.border.inactive 446498ff;cat set zk.style.tree-list-entry.color.lines 42BC99ff;cat set zk.style.task.color.background.hover 446498ff;cat set zk.style.task.color.border 446498ff;cat set zk.style.taskbar.color.border 446498ff;cat set zk.style.window.color.border 446498ff;cat set zk.style.window-close-button.color.border 446498ff;cat set zk.style.window-header.color.background.active 446498ff;cat set zk.style.window-header.color.border.inactive 446498ff;cat set zk.style.window-header.color.border.active 446498ff");
}); });
@ -574,7 +574,7 @@ static CatCommand dump_vars_by_name("debug_dump_netvars_name", "Dump netvars of
if (args.ArgC() < 1) if (args.ArgC() < 1)
return; return;
std::string name(args.Arg(1)); std::string name(args.Arg(1));
for (int i = 0; i < HIGHEST_ENTITY; i++) for (int i = 0; i <= HIGHEST_ENTITY; i++)
{ {
CachedEntity *ent = ENTITY(i); CachedEntity *ent = ENTITY(i);
if (CE_BAD(ent)) if (CE_BAD(ent))

View File

@ -449,7 +449,7 @@ static bool getHealthAndAmmo()
if (static_cast<float>(LOCAL_E->m_iHealth()) / LOCAL_E->m_iMaxHealth() < 0.64f) if (static_cast<float>(LOCAL_E->m_iHealth()) / LOCAL_E->m_iMaxHealth() < 0.64f)
{ {
std::vector<Vector> healthpacks; std::vector<Vector> healthpacks;
for (int i = 1; i < HIGHEST_ENTITY; i++) for (int i = 1; i <= HIGHEST_ENTITY; i++)
{ {
CachedEntity *ent = ENTITY(i); CachedEntity *ent = ENTITY(i);
if (CE_BAD(ent)) if (CE_BAD(ent))
@ -480,7 +480,7 @@ static bool getHealthAndAmmo()
if (hasLowAmmo()) if (hasLowAmmo())
{ {
std::vector<Vector> ammopacks; std::vector<Vector> ammopacks;
for (int i = 1; i < HIGHEST_ENTITY; i++) for (int i = 1; i <= HIGHEST_ENTITY; i++)
{ {
CachedEntity *ent = ENTITY(i); CachedEntity *ent = ENTITY(i);
if (CE_BAD(ent)) if (CE_BAD(ent))

View File

@ -25,7 +25,7 @@ static settings::Boolean show_teammates{ "radar.show.teammates", "true" };
static settings::Boolean show_healthpacks{ "radar.show.health", "true" }; static settings::Boolean show_healthpacks{ "radar.show.health", "true" };
static settings::Boolean show_ammopacks{ "radar.show.ammo", "true" }; static settings::Boolean show_ammopacks{ "radar.show.ammo", "true" };
Timer invalid{}; static Timer invalid{};
std::pair<int, int> WorldToRadar(int x, int y) std::pair<int, int> WorldToRadar(int x, int y)
{ {
@ -76,7 +76,7 @@ void DrawEntity(int x, int y, CachedEntity *ent)
rgba_t clr; rgba_t clr;
float healthp = 0.0f; float healthp = 0.0f;
if (CE_GOOD(ent)) if (CE_VALID(ent))
{ {
if (ent->m_Type() == ENTITY_PLAYER) if (ent->m_Type() == ENTITY_PLAYER)
{ {
@ -89,7 +89,9 @@ void DrawEntity(int x, int y, CachedEntity *ent)
return; return;
if (clazz <= 0 || clazz > 9) if (clazz <= 0 || clazz > 9)
return; return;
const auto &wtr = WorldToRadar(ent->m_vecOrigin().x, ent->m_vecOrigin().y); if (ent->m_vecDormantOrigin() == Vector(0.0f))
return;
const auto &wtr = WorldToRadar(ent->m_vecDormantOrigin().x, ent->m_vecDormantOrigin().y);
if (use_icons) if (use_icons)
{ {
@ -116,7 +118,9 @@ void DrawEntity(int x, int y, CachedEntity *ent)
{ {
if (ent->m_iClassID() == CL_CLASS(CObjectDispenser) || ent->m_iClassID() == CL_CLASS(CObjectSentrygun) || ent->m_iClassID() == CL_CLASS(CObjectTeleporter)) if (ent->m_iClassID() == CL_CLASS(CObjectDispenser) || ent->m_iClassID() == CL_CLASS(CObjectSentrygun) || ent->m_iClassID() == CL_CLASS(CObjectTeleporter))
{ {
const auto &wtr = WorldToRadar(ent->m_vecOrigin().x, ent->m_vecOrigin().y); if (ent->m_vecDormantOrigin() == Vector(0.0f))
return;
const auto &wtr = WorldToRadar(ent->m_vecDormantOrigin().x, ent->m_vecDormantOrigin().y);
tx_teams[CE_INT(ent, netvar.iTeamNum) - 2].draw(x + wtr.first, y + wtr.second, *icon_size * 1.5f, *icon_size * 1.5f, colors::white); tx_teams[CE_INT(ent, netvar.iTeamNum) - 2].draw(x + wtr.first, y + wtr.second, *icon_size * 1.5f, *icon_size * 1.5f, colors::white);
switch (ent->m_iClassID()) switch (ent->m_iClassID())
{ {
@ -153,16 +157,18 @@ void DrawEntity(int x, int y, CachedEntity *ent)
} }
else if (ent->m_Type() == ENTITY_GENERIC) else if (ent->m_Type() == ENTITY_GENERIC)
{ {
if (ent->m_vecDormantOrigin() == Vector(0.0f))
return;
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); const auto &wtr = WorldToRadar(ent->m_vecDormantOrigin().x, ent->m_vecDormantOrigin().y);
float sz = *icon_size * 0.15f * 0.5f; float sz = *icon_size * 0.15f * 0.5f;
float sz2 = *icon_size * 0.85; float sz2 = *icon_size * 0.85;
tx_items[0].draw(x + wtr.first + sz, y + wtr.second + sz, sz2, sz2, colors::white); tx_items[0].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); const auto &wtr = WorldToRadar(ent->m_vecDormantOrigin().x, ent->m_vecDormantOrigin().y);
float sz = *icon_size * 0.15f * 0.5f; float sz = *icon_size * 0.15f * 0.5f;
float sz2 = *icon_size * 0.85; float sz2 = *icon_size * 0.85;
tx_items[1].draw(x + wtr.first + sz, y + wtr.second + sz, sz2, sz2, colors::white); tx_items[1].draw(x + wtr.first + sz, y + wtr.second + sz, sz2, sz2, colors::white);
@ -197,10 +203,10 @@ void Draw()
if (enemies_over_teammates) if (enemies_over_teammates)
enemies.clear(); enemies.clear();
std::vector<CachedEntity *> sentries; std::vector<CachedEntity *> sentries;
for (int i = 1; i < HIGHEST_ENTITY; i++) for (int i = 1; i <= HIGHEST_ENTITY; i++)
{ {
ent = ENTITY(i); ent = ENTITY(i);
if (CE_BAD(ent)) if (CE_INVALID(ent))
continue; continue;
if (!ent->m_bAlivePlayer()) if (!ent->m_bAlivePlayer())
continue; continue;

View File

@ -38,7 +38,7 @@ void Draw()
spy_count = 0; spy_count = 0;
if (last_say > g_GlobalVars->curtime) if (last_say > g_GlobalVars->curtime)
last_say = 0; last_say = 0;
for (int i = 0; i < HIGHEST_ENTITY && i < 32; i++) for (int i = 0; i <= HIGHEST_ENTITY && i < 32; i++)
{ {
ent = ENTITY(i); ent = ENTITY(i);
if (CE_BAD(ent)) if (CE_BAD(ent))

View File

@ -1403,7 +1403,7 @@ CatCommand print_classnames("debug_print_classnames", "Lists classnames currentl
CachedEntity *ent; CachedEntity *ent;
// Go through all the entities // Go through all the entities
for (int i = 0; i < HIGHEST_ENTITY; i++) for (int i = 0; i <= HIGHEST_ENTITY; i++)
{ {
// Get an entity // Get an entity

View File

@ -40,6 +40,7 @@ void RunEnginePrediction(IClientEntity *ent, CUserCmd *ucmd)
{ {
if (!ent) if (!ent)
return; return;
typedef void (*SetupMoveFn)(IPrediction *, IClientEntity *, CUserCmd *, class IMoveHelper *, CMoveData *); typedef void (*SetupMoveFn)(IPrediction *, IClientEntity *, CUserCmd *, class IMoveHelper *, CMoveData *);
typedef void (*FinishMoveFn)(IPrediction *, IClientEntity *, CUserCmd *, CMoveData *); typedef void (*FinishMoveFn)(IPrediction *, IClientEntity *, CUserCmd *, CMoveData *);

View File

@ -17,7 +17,7 @@ bool HasSandvichOut(CachedEntity *entity)
CachedEntity *weapon; CachedEntity *weapon;
weapon_idx = CE_INT(entity, netvar.hActiveWeapon) & 0xFFF; weapon_idx = CE_INT(entity, netvar.hActiveWeapon) & 0xFFF;
if (!(weapon_idx > 0 && weapon_idx < HIGHEST_ENTITY)) if (!(weapon_idx > 0 && weapon_idx <= HIGHEST_ENTITY))
return false; return false;
weapon = ENTITY(weapon_idx); weapon = ENTITY(weapon_idx);
if (CE_GOOD(weapon)) if (CE_GOOD(weapon))

View File

@ -127,7 +127,7 @@ class ignoremanager
} }
static void updateDanger() static void updateDanger()
{ {
for (size_t i = 0; i < HIGHEST_ENTITY; i++) for (size_t i = 0; i <= HIGHEST_ENTITY; i++)
{ {
CachedEntity *ent = ENTITY(i); CachedEntity *ent = ENTITY(i);
if (CE_INVALID(ent)) if (CE_INVALID(ent))

View File

@ -14,7 +14,7 @@ void TFPlayerResource::Update()
IClientEntity *ent; IClientEntity *ent;
entity = 0; entity = 0;
for (int i = 0; i < HIGHEST_ENTITY; i++) for (int i = 0; i <= HIGHEST_ENTITY; i++)
{ {
ent = g_IEntityList->GetClientEntity(i); ent = g_IEntityList->GetClientEntity(i);
if (ent && ent->GetClientClass()->m_ClassID == RCC_PLAYERRESOURCE) if (ent && ent->GetClientClass()->m_ClassID == RCC_PLAYERRESOURCE)

View File

@ -14,7 +14,7 @@ Vector prevloc[2048]{};
void Update() void Update()
{ {
for (int i = 1; i < HIGHEST_ENTITY; i++) for (int i = 1; i <= HIGHEST_ENTITY; i++)
{ {
CachedEntity *ent = ENTITY(i); CachedEntity *ent = ENTITY(i);
if (CE_BAD(ent)) if (CE_BAD(ent))

View File

@ -342,7 +342,7 @@ void EffectChams::Render(int x, int y, int w, int h)
return; return;
CMatRenderContextPtr ptr(GET_RENDER_CONTEXT); CMatRenderContextPtr ptr(GET_RENDER_CONTEXT);
BeginRenderChams(); BeginRenderChams();
for (int i = 1; i < HIGHEST_ENTITY; i++) for (int i = 1; i <= HIGHEST_ENTITY; i++)
{ {
IClientEntity *entity = g_IEntityList->GetClientEntity(i); IClientEntity *entity = g_IEntityList->GetClientEntity(i);
if (!entity || entity->IsDormant() || CE_BAD(ENTITY(i))) if (!entity || entity->IsDormant() || CE_BAD(ENTITY(i)))

View File

@ -1,4 +1,5 @@
#include <GL/glew.h>
#include "visual/imgui/imgui_impl.h" #include "visual/imgui/imgui_impl.h"
#include "visual/drawing.hpp" #include "visual/drawing.hpp"
#include "visual/imgui/imgui.h" #include "visual/imgui/imgui.h"
@ -35,6 +36,7 @@ void ImGui_Impl_Render(ImDrawData *draw_data)
glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT); glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);

View File

@ -10,7 +10,7 @@ namespace zerokernel_checkbox
static settings::RVariable<int> checkbox_size{ "zk.style.checkbox.size", "12" }; static settings::RVariable<int> checkbox_size{ "zk.style.checkbox.size", "12" };
static settings::RVariable<rgba_t> color_border{ "zk.style.checkbox.color.border", "446498ff" }; static settings::RVariable<rgba_t> color_border{ "zk.style.checkbox.color.border", "446498ff" };
static settings::RVariable<rgba_t> color_checked{ "zk.style.checkbox.color.checked", "446498ff" }; static settings::RVariable<rgba_t> color_checked{ "zk.style.checkbox.color.checked", "446498ff" };
static settings::RVariable<rgba_t> color_hover{ "zk.style.checkbox.color.hover", "446498ff77" }; static settings::RVariable<rgba_t> color_hover{ "zk.style.checkbox.color.hover", "00a098ff" };
} // namespace zerokernel_checkbox } // namespace zerokernel_checkbox
bool zerokernel::Checkbox::onLeftMouseClick() bool zerokernel::Checkbox::onLeftMouseClick()