mirror of
https://github.com/yquake2/xatrix.git
synced 2024-11-12 23:54:30 +00:00
Fixed fixbot bot_goal leak
This commit is contained in:
parent
debf08a512
commit
b018177247
3 changed files with 41 additions and 15 deletions
|
@ -148,6 +148,42 @@ fixbot_search(edict_t *self)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
bot_goal_think(edict_t *self)
|
||||||
|
{
|
||||||
|
if (!self)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* clean up the bot_goal if the fixbot loses it (to avoid entity leaks) */
|
||||||
|
if (!self->owner || !self->owner->inuse || self->owner->goalentity != self)
|
||||||
|
{
|
||||||
|
G_FreeEdict(self);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
self->nextthink = level.time + FRAMETIME;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static edict_t *
|
||||||
|
make_bot_goal(edict_t *self)
|
||||||
|
{
|
||||||
|
edict_t *ent = G_Spawn();
|
||||||
|
|
||||||
|
ent->classname = "bot_goal";
|
||||||
|
ent->solid = SOLID_BBOX;
|
||||||
|
ent->owner = self;
|
||||||
|
|
||||||
|
ent->think = bot_goal_think;
|
||||||
|
ent->nextthink = level.time + FRAMETIME;
|
||||||
|
|
||||||
|
gi.linkentity(ent);
|
||||||
|
|
||||||
|
return ent;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
landing_goal(edict_t *self)
|
landing_goal(edict_t *self)
|
||||||
{
|
{
|
||||||
|
@ -161,11 +197,7 @@ landing_goal(edict_t *self)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ent = G_Spawn();
|
ent = make_bot_goal(self);
|
||||||
ent->classname = "bot_goal";
|
|
||||||
ent->solid = SOLID_BBOX;
|
|
||||||
ent->owner = self;
|
|
||||||
gi.linkentity(ent);
|
|
||||||
|
|
||||||
VectorSet(ent->mins, -32, -32, -24);
|
VectorSet(ent->mins, -32, -32, -24);
|
||||||
VectorSet(ent->maxs, 32, 32, 24);
|
VectorSet(ent->maxs, 32, 32, 24);
|
||||||
|
@ -196,11 +228,7 @@ takeoff_goal(edict_t *self)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ent = G_Spawn();
|
ent = make_bot_goal(self);
|
||||||
ent->classname = "bot_goal";
|
|
||||||
ent->solid = SOLID_BBOX;
|
|
||||||
ent->owner = self;
|
|
||||||
gi.linkentity(ent);
|
|
||||||
|
|
||||||
VectorSet(ent->mins, -32, -32, -24);
|
VectorSet(ent->mins, -32, -32, -24);
|
||||||
VectorSet(ent->maxs, 32, 32, 24);
|
VectorSet(ent->maxs, 32, 32, 24);
|
||||||
|
@ -283,11 +311,7 @@ roam_goal(edict_t *self)
|
||||||
whichvec[1] = 0;
|
whichvec[1] = 0;
|
||||||
whichvec[2] = 0;
|
whichvec[2] = 0;
|
||||||
|
|
||||||
ent = G_Spawn();
|
ent = make_bot_goal(self);
|
||||||
ent->classname = "bot_goal";
|
|
||||||
ent->solid = SOLID_BBOX;
|
|
||||||
ent->owner = self;
|
|
||||||
gi.linkentity(ent);
|
|
||||||
|
|
||||||
oldlen = 0;
|
oldlen = 0;
|
||||||
|
|
||||||
|
|
|
@ -570,6 +570,7 @@ extern void flipper_run ( edict_t * self ) ;
|
||||||
extern void flipper_run_loop ( edict_t * self ) ;
|
extern void flipper_run_loop ( edict_t * self ) ;
|
||||||
extern void flipper_stand ( edict_t * self ) ;
|
extern void flipper_stand ( edict_t * self ) ;
|
||||||
extern void SP_monster_fixbot ( edict_t * self ) ;
|
extern void SP_monster_fixbot ( edict_t * self ) ;
|
||||||
|
extern void bot_goal_think ( edict_t *self ) ;
|
||||||
extern void fixbot_die ( edict_t * self , edict_t * inflictor , edict_t * attacker , int damage , vec3_t point ) ;
|
extern void fixbot_die ( edict_t * self , edict_t * inflictor , edict_t * attacker , int damage , vec3_t point ) ;
|
||||||
extern void fixbot_dead ( edict_t * self ) ;
|
extern void fixbot_dead ( edict_t * self ) ;
|
||||||
extern void fixbot_pain ( edict_t * self , edict_t * other , float kick , int damage ) ;
|
extern void fixbot_pain ( edict_t * self , edict_t * other , float kick , int damage ) ;
|
||||||
|
|
|
@ -570,6 +570,7 @@
|
||||||
{"flipper_run_loop", (byte *)flipper_run_loop},
|
{"flipper_run_loop", (byte *)flipper_run_loop},
|
||||||
{"flipper_stand", (byte *)flipper_stand},
|
{"flipper_stand", (byte *)flipper_stand},
|
||||||
{"SP_monster_fixbot", (byte *)SP_monster_fixbot},
|
{"SP_monster_fixbot", (byte *)SP_monster_fixbot},
|
||||||
|
{"bot_goal_think", (byte *)bot_goal_think},
|
||||||
{"fixbot_die", (byte *)fixbot_die},
|
{"fixbot_die", (byte *)fixbot_die},
|
||||||
{"fixbot_dead", (byte *)fixbot_dead},
|
{"fixbot_dead", (byte *)fixbot_dead},
|
||||||
{"fixbot_pain", (byte *)fixbot_pain},
|
{"fixbot_pain", (byte *)fixbot_pain},
|
||||||
|
|
Loading…
Reference in a new issue