mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
SetAttachmentSlotsFlag: improved code to check array bounds.
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8952 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+10
-18
@@ -5638,7 +5638,8 @@ BOOLEAN OBJECTTYPE::AttachObjectNAS( SOLDIERTYPE * pSoldier, OBJECTTYPE * pAttac
|
||||
}
|
||||
|
||||
//CHRISL: Use this function to sort through Attachments.xml and Launchables.xml
|
||||
UINT64 SetAttachmentSlotsFlag(OBJECTTYPE* pObj){
|
||||
UINT64 SetAttachmentSlotsFlag(OBJECTTYPE* pObj)
|
||||
{
|
||||
UINT64 uiSlotFlag = 0;
|
||||
UINT32 uiLoop = 0;
|
||||
UINT32 fItem;
|
||||
@@ -5646,43 +5647,34 @@ UINT64 SetAttachmentSlotsFlag(OBJECTTYPE* pObj){
|
||||
if (pObj->exists() == false)
|
||||
return 0;
|
||||
|
||||
//Madd: Common Attachment Framework
|
||||
UINT64 point = GetAvailableAttachmentPoint(pObj, 0);
|
||||
|
||||
while(1)
|
||||
while (uiLoop < gMAXITEMS_READ && Item[uiLoop].usItemClass != 0 ||
|
||||
uiLoop < MAXATTACHMENTS && Attachment[uiLoop][0] != 0 ||
|
||||
uiLoop < MAXITEMS + 1 && Launchable[uiLoop][0] != 0)
|
||||
{
|
||||
fItem = 0;
|
||||
//Madd: Common Attachment Framework
|
||||
if (IsAttachmentPointAvailable(point, uiLoop, TRUE))
|
||||
if (uiLoop > 0 && uiLoop < gMAXITEMS_READ && IsAttachmentPointAvailable(point, uiLoop, TRUE))
|
||||
{
|
||||
fItem = uiLoop;
|
||||
if(fItem && ItemIsLegal(fItem, TRUE)) // We've found a valid attachment. Set the nasAttachmentSlots flag appropriately
|
||||
if (fItem && ItemIsLegal(fItem, TRUE))
|
||||
uiSlotFlag |= Item[fItem].nasAttachmentClass;
|
||||
}
|
||||
|
||||
if (Attachment[uiLoop][1] == pObj->usItem)
|
||||
if (uiLoop < MAXATTACHMENTS && Attachment[uiLoop][1] == pObj->usItem)
|
||||
{
|
||||
fItem = Attachment[uiLoop][0];
|
||||
|
||||
if (fItem && ItemIsLegal(fItem, TRUE))
|
||||
uiSlotFlag |= Item[fItem].nasAttachmentClass;
|
||||
}
|
||||
|
||||
if (Launchable[uiLoop][1] == pObj->usItem )
|
||||
if (uiLoop < MAXITEMS + 1 && Launchable[uiLoop][1] == pObj->usItem)
|
||||
{
|
||||
fItem = Launchable[uiLoop][0];
|
||||
|
||||
if (fItem && ItemIsLegal(fItem, TRUE))
|
||||
uiSlotFlag |= Item[fItem].nasAttachmentClass;
|
||||
}
|
||||
|
||||
++uiLoop;
|
||||
|
||||
if (Attachment[uiLoop][0] == 0 && Launchable[uiLoop][0] == 0 && Item[uiLoop].usItemClass == 0 )
|
||||
{
|
||||
// No more attachments to search
|
||||
break;
|
||||
}
|
||||
uiLoop++;
|
||||
}
|
||||
|
||||
return uiSlotFlag;
|
||||
|
||||
Reference in New Issue
Block a user