Add get_entity to util.c
With checks to make sure entity is correct
Remove is_alive check from valid_client
Fixes 41e6b012d9
This commit is contained in:
parent
02ba15ba3f
commit
a257317f58
|
@ -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);
|
||||
|
|
14
src/util.c
14
src/util.c
|
@ -7,12 +7,24 @@
|
|||
#include <math.h>
|
||||
#include <GL/gl.h>
|
||||
|
||||
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) {
|
||||
|
|
Loading…
Reference in New Issue