mirror of
https://github.com/yquake2/rogue.git
synced 2024-11-26 14:10:55 +00:00
Make sure that a monsters enemy is still alive when deciding to attack.
When the monster was already killed by another monster or a coop player some references may be NULL and the game was crashed. This was observed by maraakte, who reported it in issue #164. I've just merged his fix from q2dos.
This commit is contained in:
parent
ff4c00e5e6
commit
7720887274
1 changed files with 19 additions and 9 deletions
28
src/g_ai.c
28
src/g_ai.c
|
@ -473,7 +473,11 @@ HuntTarget(edict_t *self)
|
||||||
self->monsterinfo.run(self);
|
self->monsterinfo.run(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
VectorSubtract(self->enemy->s.origin, self->s.origin, vec);
|
if(visible(self, self->enemy))
|
||||||
|
{
|
||||||
|
VectorSubtract(self->enemy->s.origin, self->s.origin, vec);
|
||||||
|
}
|
||||||
|
|
||||||
self->ideal_yaw = vectoyaw(vec);
|
self->ideal_yaw = vectoyaw(vec);
|
||||||
|
|
||||||
/* wait a while before first attack */
|
/* wait a while before first attack */
|
||||||
|
@ -486,7 +490,7 @@ HuntTarget(edict_t *self)
|
||||||
void
|
void
|
||||||
FoundTarget(edict_t *self)
|
FoundTarget(edict_t *self)
|
||||||
{
|
{
|
||||||
if (!self)
|
if (!self|| !self->enemy || !self->enemy->inuse)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -824,7 +828,7 @@ M_CheckAttack(edict_t *self)
|
||||||
float chance;
|
float chance;
|
||||||
trace_t tr;
|
trace_t tr;
|
||||||
|
|
||||||
if (!self)
|
if (!self || !self->enemy || !self->enemy->inuse)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1158,8 +1162,10 @@ ai_checkattack(edict_t *self, float dist)
|
||||||
qboolean hesDeadJim;
|
qboolean hesDeadJim;
|
||||||
qboolean retval;
|
qboolean retval;
|
||||||
|
|
||||||
if (!self)
|
if (!self || !self->enemy || !self->enemy->inuse)
|
||||||
{
|
{
|
||||||
|
enemy_vis = false;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1300,10 +1306,14 @@ ai_checkattack(edict_t *self, float dist)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enemy_infront = infront(self, self->enemy);
|
if (self->enemy)
|
||||||
enemy_range = range(self, self->enemy);
|
{
|
||||||
VectorSubtract(self->enemy->s.origin, self->s.origin, temp);
|
enemy_infront = infront(self, self->enemy);
|
||||||
enemy_yaw = vectoyaw(temp);
|
enemy_range = range(self, self->enemy);
|
||||||
|
VectorSubtract(self->enemy->s.origin, self->s.origin, temp);
|
||||||
|
enemy_yaw = vectoyaw(temp);
|
||||||
|
}
|
||||||
|
|
||||||
retval = self->monsterinfo.checkattack(self);
|
retval = self->monsterinfo.checkattack(self);
|
||||||
|
|
||||||
if (retval)
|
if (retval)
|
||||||
|
@ -1360,7 +1370,7 @@ ai_run(edict_t *self, float dist)
|
||||||
qboolean gotcha = false;
|
qboolean gotcha = false;
|
||||||
edict_t *realEnemy;
|
edict_t *realEnemy;
|
||||||
|
|
||||||
if (!self)
|
if (!self || !self->enemy || !self->enemy->inuse)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue