Fix Broly SIGFPE

- Don't spawn the KI if the duration <= 0
- If the KI spawned but the duration <= 0 for any other reason remove the object instead of performing the division
This commit is contained in:
toaster 2022-12-29 17:54:19 +00:00
parent 41ebd7c67d
commit 881507889d
2 changed files with 16 additions and 6 deletions

View file

@ -56,7 +56,7 @@ void Obj_DuelBombInit(mobj_t *bomb);
/* Broly Ki */ /* Broly Ki */
mobj_t *Obj_SpawnBrolyKi(mobj_t *source, tic_t duration); mobj_t *Obj_SpawnBrolyKi(mobj_t *source, tic_t duration);
void Obj_BrolyKiThink(mobj_t *ki); boolean Obj_BrolyKiThink(mobj_t *ki);
/* Special Stage UFO */ /* Special Stage UFO */
waypoint_t *K_GetSpecialUFOWaypoint(mobj_t *ufo); waypoint_t *K_GetSpecialUFOWaypoint(mobj_t *ufo);

View file

@ -34,14 +34,16 @@ Obj_SpawnBrolyKi
( mobj_t * source, ( mobj_t * source,
tic_t duration) tic_t duration)
{ {
mobj_t *x = P_SpawnMobjFromMobj( mobj_t *x;
source, 0, 0, 0, MT_BROLY);
if (duration == 0) if (duration <= 0)
{ {
return x; return NULL;
} }
x = P_SpawnMobjFromMobj(
source, 0, 0, 0, MT_BROLY);
// Shrink into center of source object. // Shrink into center of source object.
x->z = (source->z + source->height / 2); x->z = (source->z + source->height / 2);
@ -61,12 +63,20 @@ Obj_SpawnBrolyKi
return x; return x;
} }
void boolean
Obj_BrolyKiThink (mobj_t *x) Obj_BrolyKiThink (mobj_t *x)
{ {
if (broly_duration(x) <= 0)
{
P_RemoveMobj(x);
return false;
}
const fixed_t const fixed_t
t = get_unit_linear(x), t = get_unit_linear(x),
n = Easing_OutSine(t, 0, broly_maxscale(x)); n = Easing_OutSine(t, 0, broly_maxscale(x));
P_InstaScale(x, n); P_InstaScale(x, n);
return true;
} }