From c5b3cfa445c1dc29aafd66ba3629474220839605 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Sun, 8 Feb 2015 08:03:06 +0000 Subject: [PATCH] Correct the special behavior to select the pipebomb detonator when you have no pipebombs in your inventory but you have some thrown in the environment so that it animates properly and also applies with the next/previous weapon functions. git-svn-id: https://svn.eduke32.com/eduke32@4967 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/sector.c | 44 +++++++++++++++++---------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/polymer/eduke32/source/sector.c b/polymer/eduke32/source/sector.c index f5d628bbd..852b4224e 100644 --- a/polymer/eduke32/source/sector.c +++ b/polymer/eduke32/source/sector.c @@ -2380,6 +2380,24 @@ void G_AlignWarpElevators(void) } } + +static int32_t P_CheckDetonatorSpecialCase(DukePlayer_t *const p, int32_t weapid) +{ + if (weapid == HANDBOMB_WEAPON && p->ammo_amount[HANDBOMB_WEAPON] == 0) + { + int32_t k = headspritestat[STAT_ACTOR]; + while (k >= 0) + { + if (sprite[k].picnum == HEAVYHBOMB && sprite[k].owner == p->i) + return 1; + + k = nextspritestat[k]; + } + } + + return 0; +} + void P_HandleSharedKeys(int32_t snum) { int32_t i, k = 0, dainv; @@ -2703,7 +2721,7 @@ CHECKINV1: if (k == -1) k = FREEZE_WEAPON; else if (k == 10) k = KNEE_WEAPON; - if ((p->gotweapon & (1<ammo_amount[k] > 0) + if (((p->gotweapon & (1<ammo_amount[k] > 0) || P_CheckDetonatorSpecialCase(p, k)) { j = k; break; @@ -2729,19 +2747,10 @@ CHECKINV1: // XXX: any signifcance to "<= MAX_WEAPONS" instead of "<"? if ((int32_t)j != -1 && j <= MAX_WEAPONS) { - if (j == HANDBOMB_WEAPON && p->ammo_amount[HANDBOMB_WEAPON] == 0) + if (P_CheckDetonatorSpecialCase(p, j)) { - k = headspritestat[STAT_ACTOR]; - while (k >= 0) - { - if (sprite[k].picnum == HEAVYHBOMB && sprite[k].owner == p->i) - { - p->gotweapon |= (1<gotweapon |= (1<show_empty_weapon = 32; } case KNEE_WEAPON: - P_AddWeapon(p, j, 1); - break; case HANDREMOTE_WEAPON: - if (k >= 0) // Found in list of [1]'s - { - p->curr_weapon = j; - p->last_weapon = -1; - p->weapon_pos = WEAPON_POS_RAISE; - } + P_AddWeapon(p, j, 1); break; case HANDBOMB_WEAPON: case TRIPBOMB_WEAPON: