Skip to content

Commit

Permalink
Fixed (all games): Bug #2131013 - Segfault if thing pain chance > 0 b…
Browse files Browse the repository at this point in the history
…ut no pain state. If the specified pain state cannot be found (or none specified) respond by attacking back but not attempting a mobj state change.
  • Loading branch information
danij committed Feb 16, 2009
1 parent ba4b16a commit aba3360
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
3 changes: 2 additions & 1 deletion doomsday/plugins/jdoom/src/p_inter.c
Expand Up @@ -1119,7 +1119,8 @@ int P_DamageMobj(mobj_t* target, mobj_t* inflictor, mobj_t* source,
{
target->flags |= MF_JUSTHIT; // Fight back!

P_MobjChangeState(target, target->info->painState);
if(target->info->painState)
P_MobjChangeState(target, target->info->painState);
}

target->reactionTime = 0; // We're awake now...
Expand Down
3 changes: 2 additions & 1 deletion doomsday/plugins/jdoom64/src/p_inter.c
Expand Up @@ -1208,7 +1208,8 @@ int P_DamageMobj(mobj_t* target, mobj_t* inflictor, mobj_t* source,
{
target->flags |= MF_JUSTHIT; // Fight back!

P_MobjChangeState(target, target->info->painState);
if(target->info->painState)
P_MobjChangeState(target, target->info->painState);
}

target->reactionTime = 0; // We're awake now...
Expand Down
3 changes: 2 additions & 1 deletion doomsday/plugins/jheretic/src/p_inter.c
Expand Up @@ -1469,7 +1469,8 @@ int P_DamageMobj(mobj_t* target, mobj_t* inflictor, mobj_t* source,
{
target->flags |= MF_JUSTHIT; // Fight back!

P_MobjChangeState(target, target->info->painState);
if(target->info->painState)
P_MobjChangeState(target, target->info->painState);
}

target->reactionTime = 0; // We're awake now...
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jhexen/src/p_enemy.c
Expand Up @@ -3376,7 +3376,7 @@ void C_DECL A_SorcBallOrbit(mobj_t *actor)
float dist = parent->radius - actor->radius * 2;
angle_t prevangle = (angle_t) actor->special1;

if(actor->target->health <= 0)
if(actor->target->health <= 0 && actor->info->painState)
P_MobjChangeState(actor, actor->info->painState);

baseangle = (angle_t) parent->special1;
Expand Down
9 changes: 6 additions & 3 deletions doomsday/plugins/jhexen/src/p_inter.c
Expand Up @@ -2201,7 +2201,8 @@ int P_DamageMobj(mobj_t* target, mobj_t* inflictor, mobj_t* source,
if(P_Random() < 96)
{
target->flags |= MF_JUSTHIT; // fight back!
P_MobjChangeState(target, target->info->painState);
if(target->info->painState)
P_MobjChangeState(target, target->info->painState);
}
else
{ // "electrocute" the target.
Expand All @@ -2224,7 +2225,8 @@ int P_DamageMobj(mobj_t* target, mobj_t* inflictor, mobj_t* source,
{
target->flags |= MF_JUSTHIT; // fight back!

P_MobjChangeState(target, target->info->painState);
if(target->info->painState)
P_MobjChangeState(target, target->info->painState);
if(inflictor && inflictor->type == MT_POISONCLOUD)
{
if(target->flags & MF_COUNTKILL && P_Random() < 128 &&
Expand Down Expand Up @@ -2381,7 +2383,8 @@ int P_PoisonDamage(player_t* player, mobj_t* source, int damage,
{ // Still alive, phew!
if(!(mapTime & 63) && playPainSound)
{
P_MobjChangeState(target, target->info->painState);
if(target->info->painState)
P_MobjChangeState(target, target->info->painState);
}
}
else
Expand Down

0 comments on commit aba3360

Please sign in to comment.