Posted By: Oxy
how to call ptr_for_handle without "crash" - 03/29/11 21:52
When I create a handle of an object,
remove the object (ent_remove)
and retreive it (ENITY) later with
ptr_for_handle,
the engine will call an error on warn_level > 1
But checking if the handle is NULL before retreiving the pointer does not work.
How do I know if a handle is empty, or an invalid (removed) object
BEFORE calling ptr_for_handle?
Example:
remove the object (ent_remove)
and retreive it (ENITY) later with
ptr_for_handle,
the engine will call an error on warn_level > 1
But checking if the handle is NULL before retreiving the pointer does not work.
How do I know if a handle is empty, or an invalid (removed) object
BEFORE calling ptr_for_handle?
Example:
Code:
for(i=0;i<counter;i++) { if(entities[i]!=0) //DOES NOT RESPOND TO NULL { //will cause an error thrown testEnt=ptr_for_handle(entities[i]); //well here I can check if its NULL, but thats too late if( checkEnt!=NULL) { ... } } } .... ent_remove(entityToKill); //killing an entity at some time