From a34c95e23ca361992cfeee83ca93b59e4c9de66f Mon Sep 17 00:00:00 2001 From: lalien Date: Fri, 16 Jun 2006 19:57:16 +0000 Subject: [PATCH] - changed selling price calculation for selling to locals to handle ammo git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@239 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- .../Map Screen Interface Map Inventory.cpp | 37 +++++++++++++++---- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/Strategic/Map Screen Interface Map Inventory.cpp b/Strategic/Map Screen Interface Map Inventory.cpp index c8337176..9cf57e2f 100644 --- a/Strategic/Map Screen Interface Map Inventory.cpp +++ b/Strategic/Map Screen Interface Map Inventory.cpp @@ -1438,19 +1438,40 @@ void BeginInventoryPoolPtr( OBJECTTYPE *pInventorySlot ) } else if ( _KeyDown ( ALT ) && fSELLALL) { - INT32 iPrice = 0; - INT8 bLoop; - for (bLoop = 0; bLoop < gItemPointer.ubNumberOfObjects; bLoop++) + INT32 iPrice = 0; + + if( gItemPointer.ubNumberOfObjects > 1) { - iPrice += (Item[gpItemPointer->usItem].usPrice ) * (gpItemPointer->bStatus[bLoop]/100); + if( Item[ gpItemPointer->usItem ].usItemClass == IC_AMMO ) + { + for (INT8 bLoop = 0; bLoop < gItemPointer.ubNumberOfObjects; bLoop++) + { + iPrice += (INT32)( Item[gpItemPointer->usItem].usPrice * (float) gpItemPointer->ubShotsLeft[bLoop] / Magazine[ Item[gpItemPointer->usItem].ubClassIndex ].ubMagSize ); + } + } + else + { + for (INT8 bLoop = 0; bLoop < gItemPointer.ubNumberOfObjects; bLoop++) + { + iPrice += (INT32)( Item[gpItemPointer->usItem].usPrice * (float)gpItemPointer->bStatus[bLoop] / 100 ); + } + } } - for (bLoop = 0; bLoop < MAX_ATTACHMENTS; bLoop++) + else { - iPrice += Item[gpItemPointer->usAttachItem[bLoop]].usPrice * (gpItemPointer->bAttachStatus[bLoop]/100); - } + iPrice = ( Item[gpItemPointer->usItem].usPrice * gpItemPointer->bStatus[0] / 100 ); - iPrice = (INT32) (iPrice / iPriceModifier); + for (INT8 bLoop = 0; bLoop < MAX_ATTACHMENTS; bLoop++) + { + iPrice += (INT32) ( Item[gpItemPointer->usAttachItem[bLoop]].usPrice * (float)gpItemPointer->bAttachStatus[bLoop] / 100); + } + } + + if( iPriceModifier < 1) iPriceModifier = 1; + + iPrice = (INT32) (iPrice / iPriceModifier); + AddTransactionToPlayersBook( SOLD_ITEMS, 0, GetWorldTotalMin(), iPrice ); PlayJA2Sample( COMPUTER_BEEP2_IN, RATE_11025, 15, 1, MIDDLEPAN ); gpItemPointer = NULL;