From 8579bc4a240aa5d4b76effd067adfd4074aa3254 Mon Sep 17 00:00:00 2001 From: MaddMugsy Date: Mon, 26 Jun 2006 16:36:59 +0000 Subject: [PATCH] -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 --- GameVersion.cpp | 4 ++-- Tactical/ShopKeeper Interface.cpp | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/GameVersion.cpp b/GameVersion.cpp index ce6dddf3..f738ecc6 100644 --- a/GameVersion.cpp +++ b/GameVersion.cpp @@ -23,12 +23,12 @@ INT16 zVersionLabel[256] = { L"Beta v. 0.98" }; #else //RELEASE BUILD VERSION - INT16 zVersionLabel[256] = { L"Release v1.13.298" }; + INT16 zVersionLabel[256] = { L"Release v1.13.304" }; #endif -INT8 czVersionNumber[16] = { "Build 06.06.24" }; +INT8 czVersionNumber[16] = { "Build 06.06.26" }; INT16 zTrackingNumber[16] = { L"Z" }; diff --git a/Tactical/ShopKeeper Interface.cpp b/Tactical/ShopKeeper Interface.cpp index d70156fd..6be90654 100644 --- a/Tactical/ShopKeeper Interface.cpp +++ b/Tactical/ShopKeeper Interface.cpp @@ -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 )