diff --git a/src/include/util.h b/src/include/util.h index 656227a..31fae2e 100644 --- a/src/include/util.h +++ b/src/include/util.h @@ -21,6 +21,7 @@ typedef struct { /*----------------------------------------------------------------------------*/ +cl_entity_t* get_entity(int ent_idx); bool is_alive(cl_entity_t* ent); bool valid_client(cl_entity_t* ent); char* get_name(int ent_idx); diff --git a/src/util.c b/src/util.c index 7f7ace8..1d7a371 100644 --- a/src/util.c +++ b/src/util.c @@ -7,12 +7,24 @@ #include #include +cl_entity_t* get_entity(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) + return NULL; + + return ent; +} + 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 is_alive(ent) && ent->index != localplayer->index; + return ent && ent->index != localplayer->index; } char* get_name(int ent_idx) {