Skip to content
Permalink
Browse files

game: fix pick up weapon when player doesn't have a primary weapon to…

… drop
  • Loading branch information...
Aranud committed Sep 9, 2019
1 parent 234ec5b commit 6856273089f1809118d69c8865e57bf0b63deee3
Showing with 31 additions and 32 deletions.
  1. +31 −32 src/game/g_items.c
@@ -527,51 +527,50 @@ int Pickup_Weapon(gentity_t *ent, gentity_t *other)
primaryWeapon = G_GetPrimaryWeaponForClient(other->client);
}

// added parens around ambiguous &&
// drop our primary weapon if one exist
if (primaryWeapon)
{
// drop our primary weapon
G_DropWeapon(other, primaryWeapon);
}

// now pickup the other one
other->client->dropWeaponTime = level.time;
// now pickup the other one
other->client->dropWeaponTime = level.time;

// add the weapon
COM_BitSet(other->client->ps.weapons, ent->item->giWeapon);
// add the weapon
COM_BitSet(other->client->ps.weapons, ent->item->giWeapon);

// fixup mauser/sniper issues
if (GetWeaponTableData(ent->item->giWeapon)->weapAlts)
{
weapon_t weapAlts = GetWeaponTableData(ent->item->giWeapon)->weapAlts;
// fixup mauser/sniper issues
if (GetWeaponTableData(ent->item->giWeapon)->weapAlts)
{
weapon_t weapAlts = GetWeaponTableData(ent->item->giWeapon)->weapAlts;

if (GetWeaponTableData(weapAlts)->type & (WEAPON_TYPE_RIFLENADE | WEAPON_TYPE_SCOPED | WEAPON_TYPE_SET))
{
COM_BitSet(other->client->ps.weapons, weapAlts);
}
if (GetWeaponTableData(weapAlts)->type & (WEAPON_TYPE_RIFLENADE | WEAPON_TYPE_SCOPED | WEAPON_TYPE_SET))
{
COM_BitSet(other->client->ps.weapons, weapAlts);
}
}

other->client->ps.ammoclip[GetWeaponTableData(ent->item->giWeapon)->clipIndex] = 0;
other->client->ps.ammo[GetWeaponTableData(ent->item->giWeapon)->ammoIndex] = 0;
other->client->ps.ammoclip[GetWeaponTableData(ent->item->giWeapon)->clipIndex] = 0;
other->client->ps.ammo[GetWeaponTableData(ent->item->giWeapon)->ammoIndex] = 0;

if (GetWeaponTableData(ent->item->giWeapon)->type & WEAPON_TYPE_MORTAR)
{
other->client->ps.ammo[GetWeaponTableData(ent->item->giWeapon)->clipIndex] = quantity;
if (GetWeaponTableData(ent->item->giWeapon)->type & WEAPON_TYPE_MORTAR)
{
other->client->ps.ammo[GetWeaponTableData(ent->item->giWeapon)->clipIndex] = quantity;

// secondary weapon ammo
if (ent->delay != 0.f)
{
Add_Ammo(other, GetWeaponTableData(ent->item->giWeapon)->weapAlts, ent->delay, qfalse);
}
}
else
// secondary weapon ammo
if (ent->delay != 0.f)
{
other->client->ps.ammoclip[GetWeaponTableData(ent->item->giWeapon)->clipIndex] = quantity;
Add_Ammo(other, GetWeaponTableData(ent->item->giWeapon)->weapAlts, ent->delay, qfalse);
}
}
else
{
other->client->ps.ammoclip[GetWeaponTableData(ent->item->giWeapon)->clipIndex] = quantity;

// secondary weapon ammo
if (ent->delay != 0.f)
{
other->client->ps.ammo[GetWeaponTableData(ent->item->giWeapon)->weapAlts] = ent->delay;
}
// secondary weapon ammo
if (ent->delay != 0.f)
{
other->client->ps.ammo[GetWeaponTableData(ent->item->giWeapon)->weapAlts] = ent->delay;
}
}
}

0 comments on commit 6856273

Please sign in to comment.
You can’t perform that action at this time.