Added fix to Zaero g_utils.c->G_UseTargets() to properly free sentien laser and titan hook entities on killtargeting.

Added fix to Zaero Sentien code to free laser entity on death.
This commit is contained in:
Knightmare66 2020-07-29 13:53:57 -04:00
parent 7cf0c475f5
commit 9622f2d370
2 changed files with 34 additions and 1 deletions

View file

@ -2,6 +2,8 @@
#include "g_local.h"
void target_laser_off (edict_t *self); // Knightmare added
void G_ProjectSource (vec3_t point, vec3_t distance, vec3_t forward, vec3_t right, vec3_t result)
{
@ -195,6 +197,28 @@ void G_UseTargets (edict_t *ent, edict_t *activator)
t = NULL;
while ((t = G_Find (t, FOFS(targetname), ent->killtarget)))
{
// Knightmare- free sentien's laser first!
if (Q_stricmp(t->classname, "monster_sentien") == 0)
{
if (t->laser) {
// gi.dprintf ("removing sentien laser before removing sentien.\n");
target_laser_off (t->laser);
G_FreeEdict (t->laser);
t->laser = NULL;
}
}
// Also free the Titan's hook
if (Q_stricmp(t->classname, "monster_zboss") == 0)
{
if (t->laser) {
// gi.dprintf ("removing titan hook before removing titan.\n");
G_FreeEdict (t->laser);
t->laser = NULL;
}
}
// end Knightmare
G_FreeEdict (t);
if (!ent->inuse)
{

View file

@ -1035,7 +1035,16 @@ void sentien_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int dama
{
int n;
target_laser_off (self->laser);
// target_laser_off (self->laser);
// Knightmare- free laser on death, as resurrection by a medic will call
// the spawn function again, and would leak the exisiting laser entity.
if (self->laser) {
// gi.dprintf ("removing sentien laser on death.\n");
target_laser_off (self->laser);
G_FreeEdict (self->laser);
self->laser = NULL;
}
// end Knightmare
// gib code to go here
if (self->health <= self->gib_health)