Fix SPB chase crashing if not chasing a player

This commit is contained in:
James R 2023-03-22 15:04:43 -07:00
parent 312e847151
commit 7cd6f54882

View file

@ -668,6 +668,8 @@ static void SPBChase(mobj_t *spb, mobj_t *bestMobj)
S_StartSound(spb, spb->info->activesound); S_StartSound(spb, spb->info->activesound);
} }
dist = P_AproxDistance(P_AproxDistance(spb->x - chase->x, spb->y - chase->y), spb->z - chase->z);
chasePlayer = chase->player; chasePlayer = chase->player;
if (chasePlayer != NULL) if (chasePlayer != NULL)
@ -723,6 +725,8 @@ static void SPBChase(mobj_t *spb, mobj_t *bestMobj)
spb_intangible(spb) = SPB_FLASHING; spb_intangible(spb) = SPB_FLASHING;
} }
} }
chasePlayer->SPBdistance = dist;
} }
else else
{ {
@ -731,10 +735,6 @@ static void SPBChase(mobj_t *spb, mobj_t *bestMobj)
spb_modetimer(spb) = SPB_HOTPOTATO; spb_modetimer(spb) = SPB_HOTPOTATO;
} }
dist = P_AproxDistance(P_AproxDistance(spb->x - chase->x, spb->y - chase->y), spb->z - chase->z);
chasePlayer->SPBdistance = dist;
desiredSpeed = FixedMul(baseSpeed, FRACUNIT + FixedDiv(dist - range, range)); desiredSpeed = FixedMul(baseSpeed, FRACUNIT + FixedDiv(dist - range, range));
if (desiredSpeed < baseSpeed) if (desiredSpeed < baseSpeed)