int CShop::GetQuantityForItem(const CInventoryItemPtr& item) { int quantity = item->GetPersistentCount(); // Check if this is a weapon CInventoryWeaponItemPtr weaponItem = boost::dynamic_pointer_cast<CInventoryWeaponItem>(item); bool isWeapon = (weaponItem != NULL); if (isWeapon) { // Use the ammonition for weapon items if (weaponItem->NeedsAmmo()) { quantity = weaponItem->GetAmmo(); } else { // Non-ammo weapons need to be enabled to be added quantity = weaponItem->IsEnabled() ? 1 : 0; } } return quantity; }