From 2abf256531cf37f47c2779e681557b090afcb1bd Mon Sep 17 00:00:00 2001 From: toaster Date: Mon, 6 Aug 2018 16:19:07 +0100 Subject: [PATCH] * Fix various instances where bananadrag might not be reset. * Improve K_KillBananaChain to be tail recursive. --- src/k_kart.c | 23 +++++++++++++++++------ src/p_inter.c | 3 +++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 7442d85f..a395ad1d 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2440,6 +2440,8 @@ static mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t map } else { + player->kartstuff[k_bananadrag] = 0; // RESET timer, for multiple bananas + if (dir == 1 || dir == 2) { // 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); - player->kartstuff[k_bananadrag] = 0; // RESET timer, for multiple bananas - if (lasttrail) { 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) { - if (banana->hnext) - { - K_KillBananaChain(banana->hnext, inflictor, source); - } + mobj_t *cachenext; + +killnext: + cachenext = banana->hnext; if (banana->health) { @@ -2743,6 +2743,9 @@ void K_KillBananaChain(mobj_t *banana, mobj_t *inflictor, mobj_t *source) if (inflictor) 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) @@ -2796,6 +2799,14 @@ static void K_MoveHeldObjects(player_t *player) 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) { case MT_ORBINAUT_SHIELD: // Kart orbit items diff --git a/src/p_inter.c b/src/p_inter.c index 6ca5e6c2..913d1722 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2183,6 +2183,9 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) if (!target->target->player->kartstuff[k_itemamount]) target->target->player->kartstuff[k_itemheld] = 0; + + if (target->target->hnext == target) + P_SetTarget(&target->target->hnext, NULL); } } //