* Fix various instances where bananadrag might not be reset.

* Improve K_KillBananaChain to be tail recursive.
This commit is contained in:
toaster 2018-08-06 16:19:07 +01:00
parent 59c64e1ec7
commit 2abf256531
2 changed files with 20 additions and 6 deletions

View file

@ -2440,6 +2440,8 @@ static mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t map
} }
else else
{ {
player->kartstuff[k_bananadrag] = 0; // RESET timer, for multiple bananas
if (dir == 1 || dir == 2) if (dir == 1 || dir == 2)
{ {
// Shoot forward // Shoot forward
@ -2476,8 +2478,6 @@ static mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t map
{ {
mobj_t *lasttrail = K_FindLastTrailMobj(player); mobj_t *lasttrail = K_FindLastTrailMobj(player);
player->kartstuff[k_bananadrag] = 0; // RESET timer, for multiple bananas
if (lasttrail) if (lasttrail)
{ {
newx = lasttrail->x; newx = lasttrail->x;
@ -2724,10 +2724,10 @@ void K_DoPogoSpring(mobj_t *mo, fixed_t vertispeed, boolean mute)
void K_KillBananaChain(mobj_t *banana, mobj_t *inflictor, mobj_t *source) void K_KillBananaChain(mobj_t *banana, mobj_t *inflictor, mobj_t *source)
{ {
if (banana->hnext) mobj_t *cachenext;
{
K_KillBananaChain(banana->hnext, inflictor, source); killnext:
} cachenext = banana->hnext;
if (banana->health) if (banana->health)
{ {
@ -2743,6 +2743,9 @@ void K_KillBananaChain(mobj_t *banana, mobj_t *inflictor, mobj_t *source)
if (inflictor) if (inflictor)
P_InstaThrust(banana, R_PointToAngle2(inflictor->x, inflictor->y, banana->x, banana->y)+ANGLE_90, 16*FRACUNIT); P_InstaThrust(banana, R_PointToAngle2(inflictor->x, inflictor->y, banana->x, banana->y)+ANGLE_90, 16*FRACUNIT);
} }
if ((banana = cachenext))
goto killnext;
} }
void K_RepairOrbitChain(mobj_t *orbit) void K_RepairOrbitChain(mobj_t *orbit)
@ -2796,6 +2799,14 @@ static void K_MoveHeldObjects(player_t *player)
return; return;
} }
if (P_MobjWasRemoved(player->mo->hnext))
{
// we need this here too because this is done in afterthink - pointers are cleaned up at the START of each tic...
P_SetTarget(&player->mo->hnext, NULL);
player->kartstuff[k_bananadrag] = 0;
return;
}
switch (player->mo->hnext->type) switch (player->mo->hnext->type)
{ {
case MT_ORBINAUT_SHIELD: // Kart orbit items case MT_ORBINAUT_SHIELD: // Kart orbit items

View file

@ -2183,6 +2183,9 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source)
if (!target->target->player->kartstuff[k_itemamount]) if (!target->target->player->kartstuff[k_itemamount])
target->target->player->kartstuff[k_itemheld] = 0; target->target->player->kartstuff[k_itemheld] = 0;
if (target->target->hnext == target)
P_SetTarget(&target->target->hnext, NULL);
} }
} }
// //