From a9a6193a817b22dfbf78dd11177349f5fdf5ad29 Mon Sep 17 00:00:00 2001 From: Sevenfm Date: Mon, 3 May 2021 04:57:07 +0000 Subject: [PATCH] Another efficiency improvement for attachments validity check function - will not check all items in inventory to be a valid gun/ammo for tested item if the tested item is attachment/hidden addon (by Shadooow). Significant improvement for the inventory panel item highlighting code on map screen. There is also a fix for wrong items highlighted when changing currently selected merc (by Shadooow). Old code was constantly running update for highlights several times a second. Now it only happens when the mouse position first finds or loses an item in inventory. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8998 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Strategic/mapscreen.cpp | 31 ++++++++++++++++++------------- Tactical/Interface Items.cpp | 23 +++++++++++------------ 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/Strategic/mapscreen.cpp b/Strategic/mapscreen.cpp index 89e2b84d8..34669ff78 100644 --- a/Strategic/mapscreen.cpp +++ b/Strategic/mapscreen.cpp @@ -750,7 +750,7 @@ void RenderIconsForUpperLeftCornerPiece( INT8 bCharNumber ); void RenderAttributeStringsForUpperLeftHandCorner( UINT32 uiBufferToRenderTo ); void DisplayThePotentialPathForCurrentDestinationCharacterForMapScreenInterface( INT16 sMapX, INT16 sMapY ); -void HandleCursorOverRifleAmmo( ); +void HandleCursorOverRifleAmmo( );//shadooow: function is now unused and can be deleted void SetUpCursorForStrategicMap( void ); void HandleAnimatedCursorsForMapScreen( ); @@ -5453,8 +5453,6 @@ UINT32 MapScreenHandle(void) // update the prev next merc buttons UpdateTheStateOfTheNextPrevMapScreenCharacterButtons( ); - // handle for inventory - HandleCursorOverRifleAmmo( ); // check contract times, update screen if they do change CheckAndUpdateBasedOnContractTimes( ); @@ -9289,12 +9287,18 @@ void BltCharInvPanel() Assert( pSoldier ); CreateDestroyMapInvButton(); - if( gbCheckForMouseOverItemPos != -1 ) + if (gfCheckForMouseOverItem) { - if( HandleCompatibleAmmoUIForMapScreen( pSoldier, (INT32)gbCheckForMouseOverItemPos, TRUE, TRUE ) == TRUE ) + if (HandleCompatibleAmmoUI(pSoldier, (INT8)gbCheckForMouseOverItemPos, TRUE)) { - fMapPanelDirty = TRUE; + // if showing sector inventory + if (fShowMapInventoryPool) + { + fMapPanelDirty = TRUE; + } + fTeamPanelDirty = TRUE; } + gfCheckForMouseOverItem = FALSE; } if( ( fShowMapInventoryPool ) ) @@ -9572,21 +9576,20 @@ void MAPInvMoveCallback( MOUSE_REGION *pRegion, INT32 iReason ) { } else if (iReason == MSYS_CALLBACK_REASON_GAIN_MOUSE ) -// if( ( iReason == MSYS_CALLBACK_REASON_MOVE ) || ( iReason == MSYS_CALLBACK_REASON_GAIN_MOUSE ) ) { - gubMAP_HandInvDispText[ uiHandPos ] = 2; - guiMouseOverItemTime = GetJA2Clock( ); + gubMAP_HandInvDispText[uiHandPos] = 2; + guiMouseOverItemTime = GetJA2Clock(); gfCheckForMouseOverItem = TRUE; - HandleCompatibleAmmoUI( pSoldier, (INT8)uiHandPos, FALSE ); gbCheckForMouseOverItemPos = (INT8)uiHandPos; + fTeamPanelDirty = TRUE; } if (iReason == MSYS_CALLBACK_REASON_LOST_MOUSE ) { - gubMAP_HandInvDispText[ uiHandPos ] = 1; - HandleCompatibleAmmoUI( pSoldier, (INT8)uiHandPos, FALSE ); + gubMAP_HandInvDispText[uiHandPos] = 1; + HandleCompatibleAmmoUI(pSoldier, (INT8)uiHandPos, FALSE); gfCheckForMouseOverItem = FALSE; + gbCheckForMouseOverItemPos = NO_SLOT; fTeamPanelDirty = TRUE; - gbCheckForMouseOverItemPos = -1; } } @@ -15025,6 +15028,8 @@ void ChangeSelectedInfoChar( INT8 bCharNumber, BOOLEAN fResetSelectedList ) // then get out of inventory mode fShowInventoryFlag = FALSE; } + //shadooow: this resets the current highlight item selection to be redrawn again + HandleCompatibleAmmoUI(MercPtrs[gCharactersList[bCharNumber].usSolID], NULL, FALSE); } fCharacterInfoPanelDirty = TRUE; diff --git a/Tactical/Interface Items.cpp b/Tactical/Interface Items.cpp index 04231bae4..4f08779ea 100644 --- a/Tactical/Interface Items.cpp +++ b/Tactical/Interface Items.cpp @@ -3290,9 +3290,9 @@ BOOLEAN InternalHandleCompatibleAmmoUI( SOLDIERTYPE *pSoldier, OBJECTTYPE *pTest } } } - - //if ( !fFoundAttachment ) - //{ + //if the test object is hidden addon or attachment, it won't be ammunition or gun so skip this + if (!Item[pTestObject->usItem].hiddenaddon && !Item[pTestObject->usItem].attachment) + { if( ( Item [ pTestObject->usItem ].usItemClass & IC_GUN ) ) { for ( cnt = 0; cnt < invsize; ++cnt ) @@ -3332,17 +3332,16 @@ BOOLEAN InternalHandleCompatibleAmmoUI( SOLDIERTYPE *pSoldier, OBJECTTYPE *pTest } } } - //If we are currently NOT in the Shopkeeper interface - else if ( !(guiTacticalInterfaceFlags & INTERFACE_SHOPKEEP_INTERFACE) ) + } + //If we are currently NOT in the Shopkeeper interface and item is not gun or ammo + if (!(guiTacticalInterfaceFlags & INTERFACE_SHOPKEEP_INTERFACE) && ((Item[pTestObject->usItem].usItemClass & IC_GUN) || (Item[pTestObject->usItem].usItemClass & IC_AMMO))) + { + if (CompatibleItemForApplyingOnMerc(pTestObject)) { - if ( CompatibleItemForApplyingOnMerc( pTestObject ) ) - { - fFound = TRUE; - gbCompatibleApplyItem = fOn; - } + fFound = TRUE; + gbCompatibleApplyItem = fOn; } - //} - + } if ( !fFound ) {