From f3046d6ac8af3ed07584cd164822e0cc87f60cc2 Mon Sep 17 00:00:00 2001 From: 8dcc <8dcc.git@gmail.com> Date: Mon, 24 Jul 2023 17:06:06 +0200 Subject: [PATCH] Rename player functions from util valid_client -> valid_player get_entity -> get_player --- src/features/chams.c | 2 +- src/features/esp.c | 5 ++--- src/include/util.h | 4 ++-- src/util.c | 9 +++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/features/chams.c b/src/features/chams.c index dea6afd..19b811e 100644 --- a/src/features/chams.c +++ b/src/features/chams.c @@ -24,7 +24,7 @@ bool chams(void* this_ptr) { if (ent->index == localplayer->index) { /* TODO: Hand chams (set var, check in gl hook, return true) */ return false; - } else if (!valid_client(ent) || !is_alive(ent)) { + } else if (!valid_player(ent) || !is_alive(ent)) { return false; } diff --git a/src/features/esp.c b/src/features/esp.c index ba47211..729a592 100644 --- a/src/features/esp.c +++ b/src/features/esp.c @@ -66,10 +66,9 @@ void esp(void) { /* Iterate all clients */ for (int i = 1; i <= i_engine->GetMaxClients(); i++) { - cl_entity_t* ent = get_entity(i); + cl_entity_t* ent = get_player(i); - if (!ent || !valid_client(ent) || !is_alive(ent) || - vec_is_zero(ent->origin)) + if (!valid_player(ent) || !is_alive(ent) || vec_is_zero(ent->origin)) continue; const int bh = 70; diff --git a/src/include/util.h b/src/include/util.h index d725301..d31a4f2 100644 --- a/src/include/util.h +++ b/src/include/util.h @@ -23,9 +23,9 @@ typedef struct { /*----------------------------------------------------------------------------*/ -cl_entity_t* get_entity(int ent_idx); +cl_entity_t* get_player(int ent_idx); bool is_alive(cl_entity_t* ent); -bool valid_client(cl_entity_t* ent); +bool valid_player(cl_entity_t* ent); char* get_name(int ent_idx); vec3_t vec3(float x, float y, float z); bool vec_is_zero(vec3_t v); diff --git a/src/util.c b/src/util.c index abcb044..633be53 100644 --- a/src/util.c +++ b/src/util.c @@ -9,13 +9,13 @@ #include /* getpagesize */ #include /* mprotect */ -cl_entity_t* get_entity(int ent_idx) { +cl_entity_t* get_player(int ent_idx) { if (ent_idx < 0 || ent_idx > 32) return NULL; cl_entity_t* ent = i_engine->GetEntityByIndex(ent_idx); - if (ent->curstate.messagenum < localplayer->curstate.messagenum) + if (!valid_player(ent)) return NULL; return ent; @@ -25,8 +25,9 @@ bool is_alive(cl_entity_t* ent) { return ent && ent->curstate.movetype != 6 && ent->curstate.movetype != 0; } -bool valid_client(cl_entity_t* ent) { - return ent && ent->index != localplayer->index; +bool valid_player(cl_entity_t* ent) { + return ent && ent->index != localplayer->index && + ent->curstate.messagenum >= localplayer->curstate.messagenum; } char* get_name(int ent_idx) {