Consolidate P_AddWeaponNoSwitch into an additional P_AddWeapon argument.

git-svn-id: https://svn.eduke32.com/eduke32@4216 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2013-12-26 19:45:00 +00:00
parent c45ca57eb0
commit 380aa880dc
5 changed files with 17 additions and 21 deletions

View file

@ -4768,10 +4768,9 @@ DETONATEB:
if ((ps->gotweapon & (1<<HANDBOMB_WEAPON)) == 0 || s->owner == ps->i)
{
/* P_AddWeapon(ps,HANDBOMB_WEAPON); */
if (!(ps->weaponswitch & 1) && PWEAPON(0, ps->curr_weapon, WorksLike) != HANDREMOTE_WEAPON)
P_AddWeaponNoSwitch(ps,HANDBOMB_WEAPON);
else P_AddWeapon(ps,HANDBOMB_WEAPON);
int32_t doswitch = ((ps->weaponswitch & 1) ||
PWEAPON(0, ps->curr_weapon, WorksLike) == HANDREMOTE_WEAPON);
P_AddWeapon(ps, HANDBOMB_WEAPON, doswitch);
}
if (sprite[s->owner].picnum != APLAYER)

View file

@ -821,15 +821,12 @@ static void P_AddWeaponMaybeSwitch(DukePlayer_t *ps, int32_t weap)
new_wchoice = i;
}
if (new_wchoice < curr_wchoice)
P_AddWeapon(ps, weap);
else
P_AddWeaponNoSwitch(ps, weap);
P_AddWeapon(ps, weap, (new_wchoice < curr_wchoice));
}
else if (ps->weaponswitch & 1)
P_AddWeapon(ps, weap);
else
P_AddWeaponNoSwitch(ps, weap);
{
P_AddWeapon(ps, weap, (ps->weaponswitch & 1));
}
}
#if defined LUNATIC

View file

@ -3183,7 +3183,7 @@ void P_AddAmmo(int32_t weapon,DukePlayer_t *p,int32_t amount)
p->ammo_amount[weapon] = p->max_ammo_amount[weapon];
}
void P_AddWeaponNoSwitch(DukePlayer_t *p, int32_t weapon)
static void P_AddWeaponNoSwitch(DukePlayer_t *p, int32_t weapon)
{
int32_t snum = sprite[p->i].yvel;
@ -3238,10 +3238,11 @@ void P_ChangeWeapon(DukePlayer_t *p, int32_t weapon)
P_SetWeaponGamevars(snum, p);
}
void P_AddWeapon(DukePlayer_t *p, int32_t weapon)
void P_AddWeapon(DukePlayer_t *p, int32_t weapon, int32_t doswitch)
{
P_AddWeaponNoSwitch(p, weapon);
P_ChangeWeapon(p, weapon);
if (doswitch)
P_ChangeWeapon(p, weapon);
}
void P_SelectNextInvItem(DukePlayer_t *p)
@ -3280,7 +3281,7 @@ void P_CheckWeapon(DukePlayer_t *p)
if ((p->gotweapon & (1<<weapon)) && p->ammo_amount[weapon] > 0)
{
P_AddWeapon(p,weapon);
P_AddWeapon(p, weapon, 1);
return;
}
}
@ -3964,7 +3965,7 @@ static void P_ProcessWeapon(int32_t snum)
{
(*kb) = 0;
if ((p->ammo_amount[HANDBOMB_WEAPON] > 0) && PIPEBOMB_CONTROL(snum) == PIPEBOMB_REMOTE)
P_AddWeapon(p,HANDBOMB_WEAPON);
P_AddWeapon(p, HANDBOMB_WEAPON, 1);
else P_CheckWeapon(p);
}
}
@ -5253,7 +5254,7 @@ HORIZONLY:
p->subweapon |= (1<<GROW_WEAPON);
else if (p->last_full_weapon == SHRINKER_WEAPON)
p->subweapon &= ~(1<<GROW_WEAPON);
P_AddWeapon(p, p->last_full_weapon);
P_AddWeapon(p, p->last_full_weapon, 1);
return;
}
}

View file

@ -363,8 +363,7 @@ static inline void P_PalFrom(DukePlayer_t *p, uint8_t f, uint8_t r, uint8_t g, u
int32_t A_GetHitscanRange(int32_t i);
void P_GetInput(int32_t snum);
void P_AddAmmo(int32_t weapon,DukePlayer_t *p,int32_t amount);
void P_AddWeapon(DukePlayer_t *p,int32_t weapon);
void P_AddWeaponNoSwitch(DukePlayer_t *p,int32_t weapon);
void P_AddWeapon(DukePlayer_t *p,int32_t weapon, int32_t doswitch);
void P_CheckWeapon(DukePlayer_t *p);
void P_DisplayScuba(int32_t snum);
void P_DisplayWeapon(int32_t snum);

View file

@ -2843,7 +2843,7 @@ CHECKINV1:
p->show_empty_weapon = 32;
}
case KNEE_WEAPON:
P_AddWeapon(p, j);
P_AddWeapon(p, j, 1);
break;
case HANDREMOTE_WEAPON:
if (k >= 0) // Found in list of [1]'s
@ -2856,7 +2856,7 @@ CHECKINV1:
case HANDBOMB_WEAPON:
case TRIPBOMB_WEAPON:
if (p->ammo_amount[j] > 0 && (p->gotweapon & (1<<j)))
P_AddWeapon(p, j);
P_AddWeapon(p, j, 1);
break;
}
}