diff --git a/Tactical/Interface Enhanced.cpp b/Tactical/Interface Enhanced.cpp index 5834e5ea..9d903851 100644 --- a/Tactical/Interface Enhanced.cpp +++ b/Tactical/Interface Enhanced.cpp @@ -2302,7 +2302,7 @@ void InternalInitEDBTooltipRegion( OBJECTTYPE * gpItemDescObject, UINT32 guiCurr MSYS_EnableRegion( &gUDBFasthelpRegions[ iFirstDataRegion + 1 ] ); } //////////////////// POCKET VOLUME (for MOLLE pockets) - if ( Item[ gpItemDescObject->usItem ].nasAttachmentClass != 0 && LoadBearingEquipment[ Item[ gpItemDescObject->usItem ].ubClassIndex ].lbePocketIndex[0] > 0 ) + if ( Item[ gpItemDescObject->usItem ].nasAttachmentClass != 0 && GetFirstPocketOnItem(gpItemDescObject->usItem) != 0 ) { swprintf( pStr, L"%s%s", szUDBGenCommonStatsTooltipText[ 2 ], szUDBGenCommonStatsExplanationsTooltipText[ 2 ]); SetRegionFastHelpText( &(gUDBFasthelpRegions[ iFirstDataRegion + 2 ]), pStr ); @@ -5882,7 +5882,7 @@ void DrawMiscStats( OBJECTTYPE * gpItemDescObject ) BltVideoObjectFromIndex( guiSAVEBUFFER, guiItemInfoAdvancedIcon, 63, gItemDescGenRegions[1][0].sLeft + sOffsetX, gItemDescGenRegions[1][0].sTop + sOffsetY, VO_BLT_SRCTRANSPARENCY, NULL ); } //////////////////// POCKET VOLUME (for MOLLE pockets) - if ( Item[ gpItemDescObject->usItem ].nasAttachmentClass != 0 && LoadBearingEquipment[ Item[ gpItemDescObject->usItem ].ubClassIndex ].lbePocketIndex[0] > 0 ) + if ( Item[ gpItemDescObject->usItem ].nasAttachmentClass != 0 && GetFirstPocketOnItem(gpItemDescObject->usItem) != 0 ) { BltVideoObjectFromIndex( guiSAVEBUFFER, guiItemInfoAdvancedIcon, 64, gItemDescGenRegions[2][0].sLeft + sOffsetX, gItemDescGenRegions[2][0].sTop + sOffsetY, VO_BLT_SRCTRANSPARENCY, NULL ); } @@ -14554,7 +14554,7 @@ void DrawMiscValues( OBJECTTYPE * gpItemDescObject ) } } //////////////////// POCKET VOLUME (for MOLLE pockets) - if ( Item[ gpItemDescObject->usItem ].nasAttachmentClass != 0 && LoadBearingEquipment[ Item[ gpItemDescObject->usItem ].ubClassIndex ].lbePocketIndex[0] > 0 ) + if ( Item[ gpItemDescObject->usItem ].nasAttachmentClass != 0 && GetFirstPocketOnItem(gpItemDescObject->usItem) != 0 ) { // Set line to draw into ubNumLine = 2; diff --git a/Tactical/Interface Items.cpp b/Tactical/Interface Items.cpp index 6f26d8fa..72cd855a 100644 --- a/Tactical/Interface Items.cpp +++ b/Tactical/Interface Items.cpp @@ -6344,17 +6344,23 @@ void ItemDescAttachmentsCallback( MOUSE_REGION * pRegion, INT32 iReason ) if( &(*iter) == pAttachment ) { std::vector usAttachmentSlotIndexVector = GetItemSlots(gpItemDescObject); - // if the attachments pocket is not empty then do not allow to remove this attachment + if( gpItemDescObject->IsActiveLBE(gubItemDescStatusIndex) ) // not worn by the soldier { LBENODE* pLBE = gpItemDescObject->GetLBEPointer(gubItemDescStatusIndex); + // we have an item in this pocket if( pLBE->inv[(AttachmentSlots[usAttachmentSlotIndexVector[slotCount]].ubPocketMapping -1)].exists() ) - return; + // place item on the ground + AutoPlaceObjectToWorld(gpItemDescSoldier, &pLBE->inv[(AttachmentSlots[usAttachmentSlotIndexVector[slotCount]].ubPocketMapping -1)], TRUE); } else // the soldier is wearing the LBE { + // we have an item in this pocket if( gpItemDescSoldier->inv[pocketKey[(AttachmentSlots[usAttachmentSlotIndexVector[slotCount]].ubPocketMapping -1)]].exists() ) - return; + // place in soldiers inventory + if( !AutoPlaceObject(gpItemDescSoldier, &gpItemDescSoldier->inv[pocketKey[(AttachmentSlots[usAttachmentSlotIndexVector[slotCount]].ubPocketMapping -1)]], FALSE) ) + // that didn't work. Place on ground instead. + AutoPlaceObjectToWorld(gpItemDescSoldier, &gpItemDescSoldier->inv[pocketKey[(AttachmentSlots[usAttachmentSlotIndexVector[slotCount]].ubPocketMapping -1)]], TRUE); } break; } diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp index f2d4003b..1aa0b687 100644 --- a/Tactical/Items.cpp +++ b/Tactical/Items.cpp @@ -4907,7 +4907,46 @@ BOOLEAN OBJECTTYPE::AttachObjectNAS( SOLDIERTYPE * pSoldier, OBJECTTYPE * pAttac pAttachment->MoveThisObjectTo(attachmentObject,1,pSoldier,NUM_INV_SLOTS,1); } } else { - pAttachment->MoveThisObjectTo(attachmentObject,1,pSoldier,NUM_INV_SLOTS,1); + // if this is an active LBE (holding an item) it must be a MOLLE pocket. We need to move the item out of this pocket or it will be invisible. + if ( pAttachment->IsActiveLBE(subObject) ) + { + std::vector LBESlots; + switch( LoadBearingEquipment[Item[pAttachment->usItem].ubClassIndex].lbeClass ) + { + case THIGH_PACK: + GetLBESlots( LTHIGHPOCKPOS, LBESlots ); + break; + case VEST_PACK: + GetLBESlots( VESTPOCKPOS, LBESlots ); + break; + case COMBAT_PACK: + GetLBESlots( CPACKPOCKPOS, LBESlots ); + break; + case BACKPACK: + GetLBESlots( BPACKPOCKPOS, LBESlots ); + break; + // this should never happen + default: + return FALSE; + } + + LBENODE* pLBE = pAttachment->GetLBEPointer(0); + for(unsigned int i=0; iinv[i].exists() ) + { + // place in soldiers inventory + if( !AutoPlaceObject(pSoldier, &pLBE->inv[i], FALSE) ) + // that didn't work. Place it on the ground instead. + AutoPlaceObjectToWorld( pSoldier, &pLBE->inv[i], TRUE ); + } + } + // finished removing items. Now attach the MOLLE pocket to its carrier. + pAttachment->MoveThisObjectTo(attachmentObject,1,pSoldier,NUM_INV_SLOTS,1); + } + else + pAttachment->MoveThisObjectTo(attachmentObject,1,pSoldier,NUM_INV_SLOTS,1); } //WarmSteel - Because we want every attachment to stay in place in NAS, we must first delete the "null" attachment, then insert the new one.