Skip to content

Commit a78d791

Browse files
committed
fix ammo counting for HWPs
1 parent 0a67bbe commit a78d791

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

src/Basescape/CraftEquipmentState.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -524,11 +524,18 @@ void CraftEquipmentState::moveRightByValue(int change)
524524
{
525525
// And now let's see if we can add the total number of vehicles.
526526
RuleItem *ammo = _game->getMod()->getItem(item->getCompatibleAmmo()->front());
527-
int ammoPerVehicle = ammo->getClipSize();
528-
if (ammoPerVehicle > 0 && item->getClipSize() > 0)
527+
int ammoPerVehicle, clipSize;
528+
if (ammo->getClipSize() > 0 && item->getClipSize() > 0)
529529
{
530-
ammoPerVehicle = item->getClipSize() / ammo->getClipSize();
530+
clipSize = item->getClipSize();
531+
ammoPerVehicle = clipSize / ammo->getClipSize();
531532
}
533+
else
534+
{
535+
clipSize = ammo->getClipSize();
536+
ammoPerVehicle = clipSize;
537+
}
538+
532539
int baseQty = _base->getStorageItems()->getItem(ammo->getType()) / ammoPerVehicle;
533540
if (_game->getSavedGame()->getMonthsPassed() == -1)
534541
baseQty = 1;
@@ -542,7 +549,7 @@ void CraftEquipmentState::moveRightByValue(int change)
542549
_base->getStorageItems()->removeItem(ammo->getType(), ammoPerVehicle);
543550
_base->getStorageItems()->removeItem(_items[_sel]);
544551
}
545-
c->getVehicles()->push_back(new Vehicle(item, ammoPerVehicle, size));
552+
c->getVehicles()->push_back(new Vehicle(item, clipSize, size));
546553
}
547554
}
548555
else

0 commit comments

Comments
 (0)