1 registered members (AndrewAMD),
1,248
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
how to call ptr_for_handle without "crash"
#365885
03/29/11 21:52
03/29/11 21:52
|
Joined: May 2008
Posts: 301
Oxy
OP
Senior Member
|
OP
Senior Member
Joined: May 2008
Posts: 301
|
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:
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
|
|
|
Re: how to call ptr_for_handle without "crash"
[Re: Oxy]
#365897
03/30/11 00:01
03/30/11 00:01
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
No, after the entity is removed, its pointer is null/invalid (and thus all skills are unreadalbe), and I operate on a list of handles to entities, read out by other codeparts. I don't understand. When you remove the entity, simply set the corresponding handle to zero, i.e. before the ptr_/ent_remove instruction. Then, in your list of handles, the handle will be zero and thus can be ignored, so you don't have to call ptr_for_handle anymore.
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual Check out my new game: Pogostuck: Rage With Your Friends
|
|
|
|