mirror of
https://github.com/1dot13/source.git
synced 2026-07-29 13:52:17 +02:00
-fixed possible negative shopkeeper prices for ammo w/bullets > 100
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@304 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -3121,6 +3121,37 @@ UINT32 CalcShopKeeperItemPrice( BOOLEAN fDealerSelling, BOOLEAN fUnitPriceOnly,
|
||||
break;
|
||||
|
||||
case IC_AMMO:
|
||||
//Madd: quick fix for negative prices at Tony's
|
||||
// this must handle overloaded objects from dealer boxes!
|
||||
if ( pItemObject->ubNumberOfObjects <= MAX_OBJECTS_PER_SLOT )
|
||||
{
|
||||
// legal amount, count them all normally (statuses could be different)
|
||||
ubItemsToCount = pItemObject->ubNumberOfObjects;
|
||||
ubItemsNotCounted = 0;
|
||||
// in this situation, uiUnitPrice will actually be the sum of the values of ALL the multiple objects
|
||||
}
|
||||
else
|
||||
{
|
||||
// overloaded amount, count just the first, the others must all be identical
|
||||
ubItemsToCount = 1;
|
||||
ubItemsNotCounted = pItemObject->ubNumberOfObjects - 1;
|
||||
}
|
||||
|
||||
// add the value of each magazine (multiple mags may have vastly different #bullets left)
|
||||
for (ubCnt = 0; ubCnt < ubItemsToCount; ubCnt++ )
|
||||
{
|
||||
// for bullets, ItemConditionModifier will convert the #ShotsLeft into a percentage
|
||||
uiUnitPrice += (UINT32)( CalcValueOfItemToDealer( gbSelectedArmsDealerID, usItemID, fDealerSelling ) *
|
||||
(pItemObject->ubShotsLeft[ubCnt] / Magazine[ Item[ usItemID ].ubClassIndex ].ubMagSize) *
|
||||
dModifier );
|
||||
|
||||
if ( fUnitPriceOnly )
|
||||
{
|
||||
// want price for only one of them. All statuses must be the same in order to use this flag!
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// this must handle overloaded objects from dealer boxes!
|
||||
if ( pItemObject->ubNumberOfObjects <= MAX_OBJECTS_PER_SLOT )
|
||||
|
||||
Reference in New Issue
Block a user