mirror of
https://github.com/1dot13/source.git
synced 2026-09-09 14:46:05 +02:00
Brief: //dnl ch76
- Debug performance improvement when working with inventory and UDB. Details: - Open UDB was quite slow and then clicking at some attachment slots halted game for few seconds. - Moving mouse over opened inventory slots with hundreds of items jerking and halting mouse for moment. - Fix CTD in rare occasions after attach and then remove GL and try attach some improper attachment. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6570 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -2860,6 +2860,18 @@ void HandleAnyMercInSquadHasCompatibleStuff( UINT8 ubSquad, OBJECTTYPE *pObject,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOLEAN IsMutuallyValidAttachmentOrLaunchable(UINT16 usAttItem, UINT16 usItem)//dnl??? ch76 091113
|
||||||
|
{
|
||||||
|
UINT32 uiLoop = 0;
|
||||||
|
while(Attachment[uiLoop][0] | Launchable[uiLoop][0])
|
||||||
|
{
|
||||||
|
if(Attachment[uiLoop][0] == usAttItem && Attachment[uiLoop][1] == usItem || Attachment[uiLoop][0] == usItem && Attachment[uiLoop][1] == usAttItem || Launchable[uiLoop][0] == usAttItem && Launchable[uiLoop][1] == usItem || Launchable[uiLoop][0] == usItem && Launchable[uiLoop][1] == usAttItem)
|
||||||
|
return(TRUE);
|
||||||
|
uiLoop++;
|
||||||
|
}
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
BOOLEAN HandleCompatibleAmmoUIForMapScreen( SOLDIERTYPE *pSoldier, INT32 bInvPos, BOOLEAN fOn, BOOLEAN fFromMerc )
|
BOOLEAN HandleCompatibleAmmoUIForMapScreen( SOLDIERTYPE *pSoldier, INT32 bInvPos, BOOLEAN fOn, BOOLEAN fFromMerc )
|
||||||
{
|
{
|
||||||
BOOLEAN fFound = FALSE;
|
BOOLEAN fFound = FALSE;
|
||||||
@@ -2946,7 +2958,7 @@ BOOLEAN HandleCompatibleAmmoUIForMapScreen( SOLDIERTYPE *pSoldier, INT32 bInvPos
|
|||||||
// don't consider for UI purposes
|
// don't consider for UI purposes
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
#if 0//dnl??? ch76 091113
|
||||||
if ( ValidAttachment( pObject->usItem, pTestObject ) ||
|
if ( ValidAttachment( pObject->usItem, pTestObject ) ||
|
||||||
ValidAttachment( pTestObject->usItem, pObject ) ||
|
ValidAttachment( pTestObject->usItem, pObject ) ||
|
||||||
ValidLaunchable( pTestObject->usItem, pObject->usItem ) ||
|
ValidLaunchable( pTestObject->usItem, pObject->usItem ) ||
|
||||||
@@ -2957,6 +2969,9 @@ BOOLEAN HandleCompatibleAmmoUIForMapScreen( SOLDIERTYPE *pSoldier, INT32 bInvPos
|
|||||||
// (UsingNewAttachmentSystem()==true && ValidItemAttachmentSlot(pObject, pTestObject->usItem, FALSE, FALSE, 0, cnt)) ||
|
// (UsingNewAttachmentSystem()==true && ValidItemAttachmentSlot(pObject, pTestObject->usItem, FALSE, FALSE, 0, cnt)) ||
|
||||||
// ValidLaunchable( pTestObject->usItem, pObject->usItem ) ||
|
// ValidLaunchable( pTestObject->usItem, pObject->usItem ) ||
|
||||||
// ValidLaunchable( pObject->usItem, pTestObject->usItem ) )
|
// ValidLaunchable( pObject->usItem, pTestObject->usItem ) )
|
||||||
|
#else
|
||||||
|
if(IsMutuallyValidAttachmentOrLaunchable(pObject->usItem, pTestObject->usItem))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
fFoundAttachment = TRUE;
|
fFoundAttachment = TRUE;
|
||||||
|
|
||||||
@@ -3053,11 +3068,14 @@ BOOLEAN HandleCompatibleAmmoUIForMapInventory( SOLDIERTYPE *pSoldier, INT32 bInv
|
|||||||
// don't consider for UI purposes
|
// don't consider for UI purposes
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
#if 0//dnl??? ch76 091113
|
||||||
if ( ValidAttachment( pObject->usItem, pTestObject ) ||
|
if ( ValidAttachment( pObject->usItem, pTestObject ) ||
|
||||||
ValidAttachment( pTestObject->usItem, pObject ) ||
|
ValidAttachment( pTestObject->usItem, pObject ) ||
|
||||||
ValidLaunchable( pTestObject->usItem, pObject->usItem ) ||
|
ValidLaunchable( pTestObject->usItem, pObject->usItem ) ||
|
||||||
ValidLaunchable( pObject->usItem, pTestObject->usItem ) )
|
ValidLaunchable( pObject->usItem, pTestObject->usItem ) )
|
||||||
|
#else
|
||||||
|
if(IsMutuallyValidAttachmentOrLaunchable(pObject->usItem, pTestObject->usItem))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
fFoundAttachment = TRUE;
|
fFoundAttachment = TRUE;
|
||||||
|
|
||||||
@@ -5490,8 +5508,7 @@ BOOLEAN InternalInitItemDescriptionBox( OBJECTTYPE *pObject, INT16 sX, INT16 sY,
|
|||||||
//CHRISL: This function is designed to recreate the attachment tooltips
|
//CHRISL: This function is designed to recreate the attachment tooltips
|
||||||
void UpdateAttachmentTooltips(OBJECTTYPE *pObject, UINT8 ubStatusIndex)
|
void UpdateAttachmentTooltips(OBJECTTYPE *pObject, UINT8 ubStatusIndex)
|
||||||
{
|
{
|
||||||
UINT32 slotCount = 0;
|
UINT32 slotCount = 0;
|
||||||
|
|
||||||
//WarmSteel - Copied most of this from bobby rays attachment listing. No need to reinvent the wheel.
|
//WarmSteel - Copied most of this from bobby rays attachment listing. No need to reinvent the wheel.
|
||||||
BOOLEAN fAttachmentsFound = FALSE;
|
BOOLEAN fAttachmentsFound = FALSE;
|
||||||
// Contains entire string of attachment names
|
// Contains entire string of attachment names
|
||||||
@@ -5505,6 +5522,15 @@ void UpdateAttachmentTooltips(OBJECTTYPE *pObject, UINT8 ubStatusIndex)
|
|||||||
std::vector<UINT16> usAttachmentSlotIndexVector = GetItemSlots(pObject);
|
std::vector<UINT16> usAttachmentSlotIndexVector = GetItemSlots(pObject);
|
||||||
UINT64 point = GetAvailableAttachmentPoint(pObject, 0); //Madd: Common Attachment Framework
|
UINT64 point = GetAvailableAttachmentPoint(pObject, 0); //Madd: Common Attachment Framework
|
||||||
|
|
||||||
|
//dnl??? ch76 081113
|
||||||
|
std::vector<UINT16> attachedList;
|
||||||
|
for(UINT8 x=0; x<(*pObject)[ubStatusIndex]->attachments.size(); x++)// attached item list rather create here then inside loop to gain performance
|
||||||
|
{
|
||||||
|
OBJECTTYPE* pAttachment2 = (*pObject)[ubStatusIndex]->GetAttachmentAtIndex(x);
|
||||||
|
if(pAttachment2->exists())
|
||||||
|
attachedList.push_back(pAttachment2->usItem);
|
||||||
|
}
|
||||||
|
|
||||||
//start by deleting the currently defined regions if they exist
|
//start by deleting the currently defined regions if they exist
|
||||||
//BOB : also, clean up the popup boxes (in case they're still around)
|
//BOB : also, clean up the popup boxes (in case they're still around)
|
||||||
// and init them to NULL in case they contain garbage
|
// and init them to NULL in case they contain garbage
|
||||||
@@ -5565,12 +5591,10 @@ void UpdateAttachmentTooltips(OBJECTTYPE *pObject, UINT8 ubStatusIndex)
|
|||||||
|
|
||||||
UINT16 usLoopSlotID = usAttachmentSlotIndexVector[slotCount];
|
UINT16 usLoopSlotID = usAttachmentSlotIndexVector[slotCount];
|
||||||
attachList.clear();
|
attachList.clear();
|
||||||
|
|
||||||
//Print all attachments that fit on this item.
|
//Print all attachments that fit on this item.
|
||||||
for(UINT16 usLoop = 0; usLoop < MAXATTACHMENTS; usLoop++)
|
for(UINT16 usLoop = 0; usLoop < MAXATTACHMENTS; usLoop++)
|
||||||
{ //We no longer find valid attachments from AttachmentSlots.xml so we need to work a bit harder to get our list
|
{ //We no longer find valid attachments from AttachmentSlots.xml so we need to work a bit harder to get our list
|
||||||
usAttachment = 0;
|
usAttachment = 0;
|
||||||
|
|
||||||
//Madd: Common Attachment Framework
|
//Madd: Common Attachment Framework
|
||||||
if (Item[usLoop].nasAttachmentClass & AttachmentSlots[usLoopSlotID].nasAttachmentClass && IsAttachmentPointAvailable(point, usLoop, TRUE))
|
if (Item[usLoop].nasAttachmentClass & AttachmentSlots[usLoopSlotID].nasAttachmentClass && IsAttachmentPointAvailable(point, usLoop, TRUE))
|
||||||
{
|
{
|
||||||
@@ -5590,7 +5614,6 @@ void UpdateAttachmentTooltips(OBJECTTYPE *pObject, UINT8 ubStatusIndex)
|
|||||||
attachList.push_back(usAttachment);
|
attachList.push_back(usAttachment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
usAttachment = 0;
|
usAttachment = 0;
|
||||||
if(Attachment[usLoop][1] == pObject->usItem && AttachmentSlots[usLoopSlotID].nasAttachmentClass & Item[Attachment[usLoop][0]].nasAttachmentClass)
|
if(Attachment[usLoop][1] == pObject->usItem && AttachmentSlots[usLoopSlotID].nasAttachmentClass & Item[Attachment[usLoop][0]].nasAttachmentClass)
|
||||||
{ //search primary item attachments.xml
|
{ //search primary item attachments.xml
|
||||||
@@ -5602,6 +5625,7 @@ void UpdateAttachmentTooltips(OBJECTTYPE *pObject, UINT8 ubStatusIndex)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ //search for attachments/launchables made valid by other attachments
|
{ //search for attachments/launchables made valid by other attachments
|
||||||
|
#if 0//dnl??? ch76 081113
|
||||||
for(UINT8 x=0; x<(*pObject)[ubStatusIndex]->attachments.size(); x++)
|
for(UINT8 x=0; x<(*pObject)[ubStatusIndex]->attachments.size(); x++)
|
||||||
{
|
{
|
||||||
OBJECTTYPE* pAttachment2 = (*pObject)[ubStatusIndex]->GetAttachmentAtIndex(x);
|
OBJECTTYPE* pAttachment2 = (*pObject)[ubStatusIndex]->GetAttachmentAtIndex(x);
|
||||||
@@ -5613,6 +5637,18 @@ void UpdateAttachmentTooltips(OBJECTTYPE *pObject, UINT8 ubStatusIndex)
|
|||||||
usAttachment = Launchable[usLoop][0];
|
usAttachment = Launchable[usLoop][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
UINT32 cnt = attachedList.size();
|
||||||
|
UINT16 *p = cnt ? &attachedList.front() : NULL;
|
||||||
|
while(cnt)
|
||||||
|
{
|
||||||
|
if(Attachment[usLoop][1] == *p && AttachmentSlots[usLoopSlotID].nasAttachmentClass & Item[Attachment[usLoop][0]].nasAttachmentClass)
|
||||||
|
usAttachment = Attachment[usLoop][0];
|
||||||
|
else if(Launchable[usLoop][1] == *p && AttachmentSlots[usLoopSlotID].nasAttachmentClass & Item[Launchable[usLoop][0]].nasAttachmentClass)
|
||||||
|
usAttachment = Launchable[usLoop][0];
|
||||||
|
cnt--, p++;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if(Attachment[usLoop][0] == 0 && Launchable[usLoop][0] == 0 && Item[usLoop].usItemClass == 0)
|
if(Attachment[usLoop][0] == 0 && Launchable[usLoop][0] == 0 && Item[usLoop].usItemClass == 0)
|
||||||
break;
|
break;
|
||||||
|
|||||||
+4
-3
@@ -2267,8 +2267,8 @@ BOOLEAN ValidItemAttachmentSlot( OBJECTTYPE * pObj, UINT16 usAttachment, BOOLEAN
|
|||||||
BOOLEAN fSimilarItems = FALSE, fSameItem = FALSE, fNoSpace = FALSE;
|
BOOLEAN fSimilarItems = FALSE, fSameItem = FALSE, fNoSpace = FALSE;
|
||||||
UINT16 usSimilarItem = NOTHING;
|
UINT16 usSimilarItem = NOTHING;
|
||||||
INT16 ubSlotIndex = 0;
|
INT16 ubSlotIndex = 0;
|
||||||
INT32 iLoop2 = 0;
|
// INT32 iLoop2 = 0;
|
||||||
INT16 sTimesToRun = 0;
|
// INT16 sTimesToRun = 0;
|
||||||
UINT8 curSlot = 0;
|
UINT8 curSlot = 0;
|
||||||
UINT8 ubVolumeTaken;
|
UINT8 ubVolumeTaken;
|
||||||
BOOLEAN foundValidAttachment = FALSE;
|
BOOLEAN foundValidAttachment = FALSE;
|
||||||
@@ -2324,7 +2324,8 @@ BOOLEAN ValidItemAttachmentSlot( OBJECTTYPE * pObj, UINT16 usAttachment, BOOLEAN
|
|||||||
//Do we want to check all attachment slots or just the one in slotcount?
|
//Do we want to check all attachment slots or just the one in slotcount?
|
||||||
if(slotCount == -1){
|
if(slotCount == -1){
|
||||||
//Loop through slots
|
//Loop through slots
|
||||||
for(UINT8 curSlot = 0; curSlot < (*pObj)[subObject]->attachments.size() && !foundValidAttachment; curSlot++){
|
UINT32 uiSlots = min((*pObj)[subObject]->attachments.size(), usAttachmentSlotIndexVector.size());//dnl??? ch76 091113 ugly fix as AK74 after attach/remove GL will have more attachments then usAttachmentSlotIndexVector which lead to CTD
|
||||||
|
for(UINT8 curSlot = 0; curSlot < uiSlots && !foundValidAttachment; curSlot++){
|
||||||
//Any attachment that is already in this slot will go here.
|
//Any attachment that is already in this slot will go here.
|
||||||
OBJECTTYPE * pAttachment;
|
OBJECTTYPE * pAttachment;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user