From ec52ab30e5b46c1db8006e4569e14c1cd41dbe3f Mon Sep 17 00:00:00 2001 From: Flugente Date: Sun, 15 Jan 2017 23:48:34 +0000 Subject: [PATCH] When trading, mark items that the trader won't buy. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8367 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Interface Items.cpp | 10 ++++++++++ Tactical/ShopKeeper Interface.cpp | 30 ++++++++++++++++++++++++------ 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/Tactical/Interface Items.cpp b/Tactical/Interface Items.cpp index ebaf49bc..df81050e 100644 --- a/Tactical/Interface Items.cpp +++ b/Tactical/Interface Items.cpp @@ -344,6 +344,8 @@ BOOLEAN TransformationMenuPopup_Arm_TestValid(OBJECTTYPE * pObj); void BombInventoryMessageBoxCallBack( UINT8 ubExitValue ); void BombInventoryDisArmMessageBoxCallBack( UINT8 ubExitValue ); +extern BOOLEAN DoesCurrentDealerRefuseToTradeItem( UINT16 usItem ); + // sevenfm: // delayed grenade explosion BOOLEAN TransformationMenuPopup_DelayedGrenadeExplosion_TestValid(OBJECTTYPE* pObj); @@ -2767,6 +2769,14 @@ void INVRenderINVPanelItem( SOLDIERTYPE *pSoldier, INT16 sPocket, UINT8 fDirtyLe UINT32 uiWhichBuffer = ( guiCurrentItemDescriptionScreen == MAP_SCREEN ) ? guiSAVEBUFFER : guiRENDERBUFFER; DrawHatchOnInventory( uiWhichBuffer, sX, sY, (UINT16)(gSMInvData[ sPocket ].sWidth-1), (UINT16)(gSMInvData[ sPocket ].sHeight-1) ); } + // Flugente: if we are currently trading, hatch all items that the trade won't accept anyway in red. That way the player doesn't have to manually find out + else if ( (guiTacticalInterfaceFlags & INTERFACE_SHOPKEEP_INTERFACE) && pObject->exists( ) && DoesCurrentDealerRefuseToTradeItem( pObject->usItem ) ) + { + UINT16 usColor = Get16BPPColor( FROMRGB( 150, 0, 50 ) ); + + UINT32 uiWhichBuffer = (guiCurrentItemDescriptionScreen == MAP_SCREEN) ? guiSAVEBUFFER : guiRENDERBUFFER; + DrawHatchOnInventory_MilitiaAccess( uiWhichBuffer, sX, sY, (UINT16)(gSMInvData[sPocket].sWidth - 1), (UINT16)(gSMInvData[sPocket].sHeight - 1), usColor ); + } // if there's an item in there if ( pObject->exists() ) diff --git a/Tactical/ShopKeeper Interface.cpp b/Tactical/ShopKeeper Interface.cpp index 50754aca..25669f40 100644 --- a/Tactical/ShopKeeper Interface.cpp +++ b/Tactical/ShopKeeper Interface.cpp @@ -6712,18 +6712,16 @@ void ConfirmToDeductMoneyFromPlayersAccountMessageBoxCallBack( UINT8 bExitValue gubSkiDirtyLevel = SKI_DIRTY_LEVEL2; } - - // run through what the player has on the table and see if the shop keep will aceept it or not -BOOLEAN WillShopKeeperRejectObjectsFromPlayer( INT8 bDealerId, INT8 bSlotId ) +BOOLEAN WillShopKeeperRejectItemFromPlayer( INT8 bDealerId, UINT16 usItem ) { BOOLEAN fRejected = TRUE; - if( Item[ PlayersOfferArea[ bSlotId ].sItemIndex ].usItemClass == IC_MONEY ) + if ( Item[usItem].usItemClass == IC_MONEY ) { fRejected = FALSE; } - else if( CanDealerTransactItem( gbSelectedArmsDealerID, PlayersOfferArea[ bSlotId ].sItemIndex, TRUE ) ) + else if ( CanDealerTransactItem( gbSelectedArmsDealerID, usItem, TRUE ) ) { fRejected = FALSE; } @@ -6733,9 +6731,29 @@ BOOLEAN WillShopKeeperRejectObjectsFromPlayer( INT8 bDealerId, INT8 bSlotId ) fRejected = TRUE; } - return( fRejected ); + return fRejected; } +BOOLEAN DoesCurrentDealerRefuseToTradeItem( UINT16 usItem ) +{ + //if non-repairman + if ( armsDealerInfo[gbSelectedArmsDealerID].ubTypeOfArmsDealer != ARMS_DEALER_REPAIRS ) + { + // don't evaluate anything he wouldn't buy! + if ( WillShopKeeperRejectItemFromPlayer( gbSelectedArmsDealerID, usItem ) ) + { + return TRUE; + } + } + + return FALSE; +} + +// run through what the player has on the table and see if the shop keep will aceept it or not +BOOLEAN WillShopKeeperRejectObjectsFromPlayer( INT8 bDealerId, INT8 bSlotId ) +{ + return WillShopKeeperRejectItemFromPlayer( bDealerId, PlayersOfferArea[bSlotId].sItemIndex ); +} void CheckAndHandleClearingOfPlayerOfferArea( void ) {