Skip to content

Commit

Permalink
Fix picking up grenades with wrong ammo (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
cxong committed Aug 19, 2018
1 parent 107ee1f commit e95bb23
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/cdogs/pickup.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,17 @@ static bool HasGunUsingAmmo(const TActor *a, const int ammoId)

static bool TryPickupAmmo(TActor *a, const Pickup *p, const char **sound)
{
// Don't pickup if not using ammo
if (!ConfigGetBool(&gConfig, "Game.Ammo"))
{
return false;
}
// Don't pickup if ammo full
const Ammo *ammo = AmmoGetById(&gAmmo, p->class->u.Ammo.Id);
const Ammo *ammo = AmmoGetById(
&gAmmo,
p->class->Type == PICKUP_AMMO ?
p->class->u.Ammo.Id :
IdWeaponClass(p->class->u.GunId)->AmmoId);
const int current = *(int *)CArrayGet(&a->ammo, p->class->u.Ammo.Id);
if (current >= ammo->Max)
{
Expand Down Expand Up @@ -294,7 +303,10 @@ static bool TryPickupGun(
{
return false;
}
const WeaponClass *wc = IdWeaponClass(p->class->u.GunId);
const WeaponClass *wc =
p->class->Type == PICKUP_GUN ?
IdWeaponClass(p->class->u.GunId) :
StrWeaponClass(AmmoGetById(&gAmmo, p->class->u.Ammo.Id)->DefaultGun);

int ammoDeficit = 0;
const Ammo *ammo = NULL;
Expand Down

0 comments on commit e95bb23

Please sign in to comment.