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
This commit is contained in:
Sevenfm
2021-05-03 04:57:07 +00:00
parent d41c0f2f93
commit a9a6193a81
2 changed files with 29 additions and 25 deletions
+18 -13
View File
@@ -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;
+11 -12
View File
@@ -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 )
{