|
Re: Entity pointer to a removed entity
[Re: Lukas]
#334216
07/21/10 20:30
07/21/10 20:30
|
Joined: Apr 2009
Posts: 138 Germany
Toryno
OP
Member
|
OP
Member
Joined: Apr 2009
Posts: 138
Germany
|
It seems that this doesn't work. Ok here's my code. You see: In the second frame, victim points to an entity which has allready been removed so the engine crashes.
ENTITY* jet = ent_create(...);
function example() {
wait(1);
ent_remove(jet);
}
action turret() {
ENTITY* victim = jet;
...
while(1)
if (victim != NULL) {
victim.LIFE -= time_step; // crash
}
}
}
Last edited by Toryno; 07/21/10 20:45. Reason: i wrote an example to the code to make in more unsterstandable
Thanks for reading, thinking, answering
|
|
|
Re: Entity pointer to a removed entity
[Re: Toryno]
#334262
07/22/10 06:36
07/22/10 06:36
|
Joined: Sep 2007
Posts: 62 Germany
bodden
Junior Member
|
Junior Member
Joined: Sep 2007
Posts: 62
Germany
|
I'm not in front of my 3dgs-PC, so I'm not sure. But you could try instead of Or use if (victim != jet) { victim = null; } insisde the while {}
|
|
|
Re: Entity pointer to a removed entity
[Re: bodden]
#334290
07/22/10 10:56
07/22/10 10:56
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
you should also be able to use
if(ptr_first(victim) != NULL)
Because if 'victim' is no longer pointing to a valid entity, ptr_first will return a NULL...
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|