Posted By: Germanunkol
fighting the "my" pointer - 02/24/12 15:00
From what I understand, the my pointer works in the following way:
When an entity is removed, all functions in which the "my" pointer points to this entity are stopped.
At random intervals, however, I get a "Error E1513: Script crash in shieldEffectEnt: se5".
This means that the line
if(my) ent_remove(my);
crashes.
But why?
Even if some other function removes the my entity, then this function should be terminated, right? And if no other function deletes the my pointer, then why does the ent_remove call crash?
Edit: I just checked. The "my" pointer is not changed during the lifetime of the function. Or, more precisely, I logged the my pointer just before sys_marker("se0"); and before sys_marker("se5");. In both cases, it spat out the exact same value for the pointer. Still, I get the exact same crash.
When an entity is removed, all functions in which the "my" pointer points to this entity are stopped.
At random intervals, however, I get a "Error E1513: Script crash in shieldEffectEnt: se5".
This means that the line
if(my) ent_remove(my);
crashes.
But why?
Even if some other function removes the my entity, then this function should be terminated, right? And if no other function deletes the my pointer, then why does the ent_remove call crash?
Code:
void shieldEffectEnt() { sys_marker("se0"); set(my,PASSABLE); vec_set(my.pan,vector(you.lastHitPan, you.lastHitTilt,0)); my.flags2 |= UNTOUCHABLE; my_playsound(my,shieldHitOGG, volumeMain*volumeFX*500*soundBrightFlash); my.parent = you; sc_ent_shieldImpact(my, getShieldEffectColor(you.shieldEffectType), 15, 1); var timePassed = 0; while(my != NULL && you != NULL && timePassed < 8) { sys_marker("se3"); timePassed += time_frame; vec_set(my.x, you.x); sys_marker("se4"); wait(1); } sys_marker("se5"); if(my) ent_remove(my); //will also stop sc_ent_shieldImpact sys_marker("se6"); }
Edit: I just checked. The "my" pointer is not changed during the lifetime of the function. Or, more precisely, I logged the my pointer just before sys_marker("se0"); and before sys_marker("se5");. In both cases, it spat out the exact same value for the pointer. Still, I get the exact same crash.