From 82aa1a6f7d6ab5d2f765f532918873c4d6617ce1 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Thu, 22 Jun 2023 15:59:27 +0300 Subject: [PATCH] Fix bug that prevented arms dealer inventory from restocking (#169) if (numTotalItems.count(usItemIndex) == 1 ) would prevent dealers to reorder items if their current stock was zero --- Tactical/Arms Dealer Init.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Tactical/Arms Dealer Init.cpp b/Tactical/Arms Dealer Init.cpp index 51f5643db..b7573fce4 100644 --- a/Tactical/Arms Dealer Init.cpp +++ b/Tactical/Arms Dealer Init.cpp @@ -493,15 +493,20 @@ void DailyCheckOnItemQuantities() if ( itemsAreOnOrder.count( usItemIndex ) == 0 ) { ubMaxSupply = GetDealersMaxItemAmount( ubArmsDealer, usItemIndex ); - + UINT16 halfSupply = (UINT16)(ubMaxSupply / 2); + UINT16 itemsInStock = 0; + if ( numTotalItems.count(usItemIndex) > 0 ) + { + itemsInStock = numTotalItems[usItemIndex]; + } //if the qty on hand is half the desired amount or fewer - if(numTotalItems.count(usItemIndex) == 1 && numTotalItems[ usItemIndex ] <= (INT32)( ubMaxSupply / 2 ) ) + if( itemsInStock <= halfSupply ) { //determine if the item can be restocked (assume new, use items aren't checked for until the stuff arrives) if (ItemTransactionOccurs( ubArmsDealer, usItemIndex, DEALER_BUYING, FALSE )) { // figure out how many items to reorder (items are reordered an entire batch at a time) - ubNumItems = HowManyItemsToReorder( ubMaxSupply, numTotalItems[ usItemIndex ] ); + ubNumItems = HowManyItemsToReorder( ubMaxSupply, itemsInStock); #ifdef JA2UB //if the dealer is betty, and we are to ADD the stuff instantly if( ubArmsDealer == ARMS_DEALER_BETTY && fInstallyHaveItemsAppear &&