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;