diff --git a/Strategic/Map Screen Interface Map Inventory.cpp b/Strategic/Map Screen Interface Map Inventory.cpp index ddaad622..c949e1c5 100644 --- a/Strategic/Map Screen Interface Map Inventory.cpp +++ b/Strategic/Map Screen Interface Map Inventory.cpp @@ -2274,6 +2274,7 @@ void DestroyStash( void ) void BeginInventoryPoolPtr( OBJECTTYPE *pInventorySlot ) { BOOLEAN fOk = FALSE; + BOOLEAN fShift = FALSE; BOOLEAN fSELLALL = gGameExternalOptions.fSellAll; // If not null return @@ -2288,6 +2289,7 @@ void BeginInventoryPoolPtr( OBJECTTYPE *pInventorySlot ) { // Remove all from soldier's slot fOk = (0 == pInventorySlot->MoveThisObjectTo(gItemPointer,-1,0,NUM_INV_SLOTS,MAX_OBJECTS_PER_SLOT)); + fShift = TRUE; } else { @@ -2306,69 +2308,108 @@ void BeginInventoryPoolPtr( OBJECTTYPE *pInventorySlot ) if ( _KeyDown ( CTRL ))//MM: Pass item to selected merc. Delete if none selected. { SOLDIERTYPE *pSoldier = &Menptr[ gCharactersList[ bSelectedInfoChar ].usSolID ]; - bool placedObject = false; + bool placedAllObjects = false; if(pSoldier->exists() == true) { + UINT8 ubInitialNumberOfObjects = gpItemPointer->ubNumberOfObjects; + + /* // commented for item compare feature for easy autoplace of multiple items if (InItemDescriptionBox( )) - { - DeleteItemDescriptionBox(); - } + DeleteItemDescriptionBox();*/ + + if (!fShowInventoryFlag) + fShowInventoryFlag = TRUE; if(pSoldier->flags.uiStatusFlags & SOLDIER_VEHICLE) { - for(int x = 0; xinv[x].exists() == true) + if(pSoldier->inv[x].usItem == gpItemPointer->usItem) { - if(pSoldier->inv[x].usItem == gpItemPointer->usItem) + if(TryToStackInSlot(pSoldier, gpItemPointer, x) == true) { - pSoldier->inv[x].AddObjectsToStack(*gpItemPointer, gpItemPointer->ubNumberOfObjects, pSoldier, x); - placedObject = true; - break; + placedAllObjects = true; + break; } + else + continue; } - else + } + + // else place item in an empty slot + if(gpItemPointer->ubNumberOfObjects == ubInitialNumberOfObjects) + { + for(int x = 0; xMoveThisObjectTo(pSoldier->inv[x], gpItemPointer->ubNumberOfObjects, pSoldier, x); - placedObject = true; - break; + if(vehicleInv[x] == FALSE) + continue; + + if(pSoldier->inv[x].exists() == false) + { + gpItemPointer->MoveThisObjectTo(pSoldier->inv[x], gpItemPointer->ubNumberOfObjects, pSoldier, x); + + if(gpItemPointer->ubNumberOfObjects == 0) + { + placedAllObjects = true; + break; + } + // vehicle slots holds less items than sector inventory slots + else if(gpItemPointer->ubNumberOfObjects < ubInitialNumberOfObjects) + break; + } } } } else { - if (AutoPlaceObject(pSoldier,gpItemPointer,FALSE)) //doesn't work for vehicles :p - placedObject = true; + if (AutoPlaceObject(pSoldier,gpItemPointer,FALSE,NO_SLOT,TRUE)) //doesn't work for vehicles :p + if(gpItemPointer->ubNumberOfObjects == 0) + placedAllObjects = true; } - if (placedObject) + if (placedAllObjects) { - fShowInventoryFlag = true; + fShowInventoryFlag = TRUE; fTeamPanelDirty = TRUE; fInterfacePanelDirty = DIRTYLEVEL2; fMapInventoryItem = FALSE; gpItemPointer = NULL; } - else // can't seem to get the code to just leave the item alone after it's been clicked on, so just pick it up... + else { - gpItemPointerSoldier = NULL; - - // now set the cursor - guiExternVo = GetInterfaceGraphicForItem( &(Item[ gpItemPointer->usItem ]) ); - gusExternVoSubIndex = g_bUsePngItemImages ? 0 : Item[ gpItemPointer->usItem ].ubGraphicNum; - - fMapInventoryItem = TRUE; - MSYS_ChangeRegionCursor( &gMPanelRegion , EXTERN_CURSOR ); - SetCurrentCursorFromDatabase( EXTERN_CURSOR ); - - if ( fShowInventoryFlag && bSelectedInfoChar >= 0 ) + // return leftover items back to original slot after autoplace + if (fShift && gpItemPointer->ubNumberOfObjects < ubInitialNumberOfObjects) { - ReevaluateItemHatches( MercPtrs[ gCharactersList[ bSelectedInfoChar ].usSolID ], FALSE ); + gpItemPointer->MoveThisObjectTo(*pInventorySlot); + + fShowInventoryFlag = TRUE; fTeamPanelDirty = TRUE; + fInterfacePanelDirty = DIRTYLEVEL2; + fMapInventoryItem = FALSE; + gpItemPointer = NULL; + } + else // pick item up to indicate no more room for autoplace + { + gpItemPointerSoldier = NULL; + + // now set the cursor + guiExternVo = GetInterfaceGraphicForItem( &(Item[ gpItemPointer->usItem ]) ); + gusExternVoSubIndex = g_bUsePngItemImages ? 0 : Item[ gpItemPointer->usItem ].ubGraphicNum; + + fMapInventoryItem = TRUE; + MSYS_ChangeRegionCursor( &gMPanelRegion , EXTERN_CURSOR ); + SetCurrentCursorFromDatabase( EXTERN_CURSOR ); + + if ( fShowInventoryFlag && bSelectedInfoChar >= 0 ) + { + ReevaluateItemHatches( MercPtrs[ gCharactersList[ bSelectedInfoChar ].usSolID ], FALSE ); + fTeamPanelDirty = TRUE; + } } } } diff --git a/Tactical/Interface Items.cpp b/Tactical/Interface Items.cpp index 1dbe71b4..8cb5239a 100644 --- a/Tactical/Interface Items.cpp +++ b/Tactical/Interface Items.cpp @@ -1435,18 +1435,19 @@ BOOLEAN InitInvSlotInterface( INV_REGION_DESC *pRegionDesc , INV_REGION_DESC *pC FilenameForBPP("INTERFACE\\inventory_figure_female_H.sti", VObjectDesc.ImageFile); CHECKF( AddVideoObject( &VObjectDesc, &(guiBodyInvVO[ 3 ][ 1 ] ) ) ); - // Kaiden: Vehicle Inventory change - Added two new STI's for Vehicle Inventory - // Feel free to change them to more appropriate pictures, I just blanked out - // the body image for now, I'm no graphics artist. - //VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE; - //FilenameForBPP("INTERFACE\\inventory_figure_Vehicle.sti", - //VObjectDesc.ImageFile); - //CHECKF( AddVideoObject( &VObjectDesc, &(guiBodyInvVO[ 4 ][ 0 ] ) ) ); + if(UsingNewInventorySystem() == false) + { + // Kaiden: Vehicle Inventory change - Added two new STI's for Vehicle Inventory + // Feel free to change them to more appropriate pictures, I just blanked out + // the body image for now, I'm no graphics artist. + VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE; + FilenameForBPP("INTERFACE\\inventory_figure_Vehicle.sti", VObjectDesc.ImageFile); + CHECKF( AddVideoObject( &VObjectDesc, &(guiBodyInvVO[ 4 ][ 0 ] ) ) ); - //VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE; - //FilenameForBPP("INTERFACE\\inventory_figure_Vehicle_h.sti", - //VObjectDesc.ImageFile); - //CHECKF( AddVideoObject( &VObjectDesc, &(guiBodyInvVO[ 4 ][ 1 ] ) ) ); + VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE; + FilenameForBPP("INTERFACE\\inventory_figure_Vehicle_h.sti", VObjectDesc.ImageFile); + CHECKF( AddVideoObject( &VObjectDesc, &(guiBodyInvVO[ 4 ][ 1 ] ) ) ); + } // add gold key graphic VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE; @@ -1580,12 +1581,17 @@ void ShutdownInvSlotInterface( ) DeleteVideoObjectFromIndex( guiBodyInvVO[ 2 ][ 0 ] ); DeleteVideoObjectFromIndex( guiBodyInvVO[ 1 ][ 0 ] ); DeleteVideoObjectFromIndex( guiBodyInvVO[ 3 ][ 0 ] ); - //DeleteVideoObjectFromIndex( guiBodyInvVO[ 4 ][ 0 ] ); + DeleteVideoObjectFromIndex( guiBodyInvVO[ 0 ][ 1 ] ); DeleteVideoObjectFromIndex( guiBodyInvVO[ 2 ][ 1 ] ); DeleteVideoObjectFromIndex( guiBodyInvVO[ 1 ][ 1 ] ); DeleteVideoObjectFromIndex( guiBodyInvVO[ 3 ][ 1 ] ); - //DeleteVideoObjectFromIndex( guiBodyInvVO[ 4 ][ 1 ] ); + + if(UsingNewInventorySystem() == false) + { + DeleteVideoObjectFromIndex( guiBodyInvVO[ 4 ][ 0 ] ); + DeleteVideoObjectFromIndex( guiBodyInvVO[ 4 ][ 1 ] ); + } DeleteVideoObjectFromIndex( guiGoldKeyVO ); @@ -1615,9 +1621,9 @@ void RenderInvBodyPanel( SOLDIERTYPE *pSoldier, INT16 sX, INT16 sY ) // Kaiden: Vehicle Inventory change - Added IF Test, Else function call was // the original statement - if ( (gGameExternalOptions.fVehicleInventory) && (pSoldier->flags.uiStatusFlags & SOLDIER_VEHICLE) ) + if ( (gGameExternalOptions.fVehicleInventory) && (pSoldier->flags.uiStatusFlags & SOLDIER_VEHICLE) && UsingNewInventorySystem() == false ) { - //BltVideoObjectFromIndex( guiSAVEBUFFER, guiBodyInvVO[4][0], 0, sX, sY, VO_BLT_SRCTRANSPARENCY, NULL ); + BltVideoObjectFromIndex( guiSAVEBUFFER, guiBodyInvVO[4][bSubImageIndex], 0, sX, sY, VO_BLT_SRCTRANSPARENCY, NULL ); } else { diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp index 42381f81..f19e61b8 100644 --- a/Tactical/Items.cpp +++ b/Tactical/Items.cpp @@ -6687,7 +6687,7 @@ bool TryToPlaceInSlot(SOLDIERTYPE* pSoldier, OBJECTTYPE* pObj, bool fNewItem, in } if (bSlot == SECONDHANDPOS) { - if (pSoldier->inv[HANDPOS].exists() == true) { + if (pSoldier->inv[HANDPOS].exists() == true && Item[pSoldier->inv[ HANDPOS ].usItem].twohanded) { return false; } } @@ -6699,39 +6699,18 @@ bool TryToPlaceInSlot(SOLDIERTYPE* pSoldier, OBJECTTYPE* pObj, bool fNewItem, in return false; } -bool PlaceInAnySlot(SOLDIERTYPE* pSoldier, OBJECTTYPE* pObj, bool fNewItem, int bExcludeSlot) +bool PlaceInAnySlot(SOLDIERTYPE* pSoldier, OBJECTTYPE* pObj, bool fNewItem, int bExcludeSlot, bool fStackOrSingleSlot) { - //first, try to STACK the item - //try to STACK in any slot - for(int bSlot = BODYPOSSTART; bSlot < BIGPOCKSTART; bSlot++) { - if (bSlot != bExcludeSlot && TryToStackInSlot(pSoldier, pObj, bSlot) == true) { - return true; - } - } - - if (FitsInSmallPocket(pObj) == true) { - //try to STACK in small pockets - for(int bSlot = SMALLPOCKSTART; bSlot < SMALLPOCKFINAL; bSlot++) { - if (bSlot != bExcludeSlot && TryToStackInSlot(pSoldier, pObj, bSlot) == true) { - return true; - } - } - } - - //try to STACK in big pockets, and possibly medium pockets - int bigPocketEnd = (UsingNewInventorySystem() == true) ? MEDPOCKFINAL : BIGPOCKFINAL; - for(int bSlot = BIGPOCKSTART; bSlot < bigPocketEnd; bSlot++) { - if (bSlot != bExcludeSlot && TryToStackInSlot(pSoldier, pObj, bSlot) == true) { - return true; - } - } + UINT8 ubInitialNumberOfObjects = pObj->ubNumberOfObjects; //now try to PLACE //try to PLACE in any body slot for(int bSlot = BODYPOSSTART; bSlot < BIGPOCKSTART; bSlot++) { - if (bSlot != bExcludeSlot && TryToPlaceInSlot(pSoldier, pObj, fNewItem, bSlot, BODYPOSFINAL) == true) { + if (bSlot != bExcludeSlot && TryToPlaceInSlot(pSoldier, pObj, fNewItem, bSlot, BODYPOSFINAL) == true) + return true; + + if(pObj->ubNumberOfObjects < ubInitialNumberOfObjects && fStackOrSingleSlot) return true; - } } if(UsingNewInventorySystem() == true) @@ -6743,46 +6722,61 @@ bool PlaceInAnySlot(SOLDIERTYPE* pSoldier, OBJECTTYPE* pObj, bool fNewItem, int UINT8 lCapacity=0; UINT8 capacity=0; int bSlot; - //Start with active big pockets - sPocket=PickPocket(pSoldier, SMALLPOCKSTART, SMALLPOCKFINAL, pObj->usItem, pObj->ubNumberOfObjects, &sCapacity, bExcludeSlot); - //Next search active medium pockets - mPocket=PickPocket(pSoldier, MEDPOCKSTART, MEDPOCKFINAL, pObj->usItem, pObj->ubNumberOfObjects, &mCapacity, bExcludeSlot); - //Lastly search active small pockets - lPocket=PickPocket(pSoldier, BIGPOCKSTART, BIGPOCKFINAL, pObj->usItem, pObj->ubNumberOfObjects, &lCapacity, bExcludeSlot); - //Finally, compare the three pockets we've found and return the pocket that is most logical to use - capacity = min(sCapacity, mCapacity); - capacity = min(lCapacity, capacity); - if(capacity == 254) { //no pocket found - return false; + + for( UINT8 i = 0; i < ubInitialNumberOfObjects; i++) + { + // pocket may not accomodate entire stack + for( UINT8 ubCurrentObjects = pObj->ubNumberOfObjects; ubCurrentObjects > 0; ubCurrentObjects--) + { + //Start with active small pockets + sPocket=PickPocket(pSoldier, SMALLPOCKSTART, SMALLPOCKFINAL, pObj->usItem, ubCurrentObjects, &sCapacity, bExcludeSlot); + //Next search active medium pockets + mPocket=PickPocket(pSoldier, MEDPOCKSTART, MEDPOCKFINAL, pObj->usItem, ubCurrentObjects, &mCapacity, bExcludeSlot); + //Lastly search active big pockets + lPocket=PickPocket(pSoldier, BIGPOCKSTART, BIGPOCKFINAL, pObj->usItem, ubCurrentObjects, &lCapacity, bExcludeSlot); + //Finally, compare the three pockets we've found and return the pocket that is most logical to use + capacity = min(sCapacity, mCapacity); + capacity = min(lCapacity, capacity); + + // pocket can fit slot + if(capacity != 254) + break; + } + + if(capacity == 254) //no pocket found + return false; + else if(capacity == sCapacity) + bSlot = sPocket; + else if(capacity == mCapacity) + bSlot = mPocket; + else if(capacity == lCapacity) + bSlot = lPocket; + + if(TryToPlaceInSlot(pSoldier, pObj, fNewItem, bSlot, NUM_INV_SLOTS) == true || fStackOrSingleSlot) + return true; } - else if(capacity == sCapacity) { - bSlot = sPocket; - } - else if(capacity == mCapacity) { - bSlot = mPocket; - } - else if(capacity == lCapacity) { - bSlot = lPocket; - } - if(TryToPlaceInSlot(pSoldier, pObj, fNewItem, bSlot, NUM_INV_SLOTS) == true) - return true; } else { if (FitsInSmallPocket(pObj) == true) { //try to PLACE in small pockets for(int bSlot = SMALLPOCKSTART; bSlot < SMALLPOCKFINAL; bSlot++) { - if (bSlot != bExcludeSlot && TryToPlaceInSlot(pSoldier, pObj, fNewItem, bSlot, NUM_INV_SLOTS) == true) { + if (bSlot != bExcludeSlot && TryToPlaceInSlot(pSoldier, pObj, fNewItem, bSlot, NUM_INV_SLOTS) == true) + return true; + + if(pObj->ubNumberOfObjects < ubInitialNumberOfObjects && fStackOrSingleSlot) return true; - } } } //try to PLACE in big pockets, and possibly medium pockets + int bigPocketEnd = (UsingNewInventorySystem() == true) ? MEDPOCKFINAL : BIGPOCKFINAL; for(int bSlot = BIGPOCKSTART; bSlot < bigPocketEnd; bSlot++) { - if (bSlot != bExcludeSlot && TryToPlaceInSlot(pSoldier, pObj, fNewItem, bSlot, bigPocketEnd) == true) { + if (bSlot != bExcludeSlot && TryToPlaceInSlot(pSoldier, pObj, fNewItem, bSlot, bigPocketEnd) == true) + return true; + + if(pObj->ubNumberOfObjects < ubInitialNumberOfObjects && fStackOrSingleSlot) return true; - } } } @@ -6952,7 +6946,7 @@ BOOLEAN AutoPlaceObjectToWorld(SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, INT8 b } // CHRISL: Function needed for LBENODE -BOOLEAN AutoPlaceObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN fNewItem, INT8 bExcludeSlot ) +BOOLEAN AutoPlaceObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN fNewItem, INT8 bExcludeSlot, BOOLEAN fStackOrSingleSlot ) { INVTYPE * pItem; UINT32 packCombo, backCombo; @@ -6963,10 +6957,41 @@ BOOLEAN AutoPlaceObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN fNew //Pulmu bugfix //ADB ubWeight has been removed, see comments in OBJECTTYPE //pObj->ubWeight = CalculateObjectWeight( pObj); + + UINT8 ubInitialNumberOfObjects = pObj->ubNumberOfObjects; + + //first, try to STACK the item + //try to STACK in any slot + for(int bSlot = BODYPOSSTART; bSlot < BIGPOCKSTART; bSlot++) { + if (bSlot != bExcludeSlot && TryToStackInSlot(pSoldier, pObj, bSlot) == true) { + return true; + } + } + + if (FitsInSmallPocket(pObj) == true) { + //try to STACK in small pockets + for(int bSlot = SMALLPOCKSTART; bSlot < SMALLPOCKFINAL; bSlot++) { + if (bSlot != bExcludeSlot && TryToStackInSlot(pSoldier, pObj, bSlot) == true) { + return true; + } + } + } + + //try to STACK in big pockets, and possibly medium pockets + int bigPocketEnd = (UsingNewInventorySystem() == true) ? MEDPOCKFINAL : BIGPOCKFINAL; + for(int bSlot = BIGPOCKSTART; bSlot < bigPocketEnd; bSlot++) { + if (bSlot != bExcludeSlot && TryToStackInSlot(pSoldier, pObj, bSlot) == true) { + return true; + } + } + + if(pObj->ubNumberOfObjects < ubInitialNumberOfObjects && fStackOrSingleSlot) + return true; + + // then overrides to the standard system: put guns in hand, armour on body (if slot empty) pItem = &(Item[pObj->usItem]); int lbeClass; - // Overrides to the standard system: put guns in hand, armour on body (if slot empty) switch (pItem->usItemClass) { case IC_GUN: @@ -6979,7 +7004,7 @@ BOOLEAN AutoPlaceObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN fNew { // put the one-handed weapon in the guy's hand... PlaceObject( pSoldier, HANDPOS, pObj, fNewItem ); - if ( pObj->exists() == false ) + if ( pObj->exists() == false || fStackOrSingleSlot ) { return( TRUE ); } @@ -6988,7 +7013,7 @@ BOOLEAN AutoPlaceObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN fNew { // put the one-handed weapon in the guy's 2nd hand... PlaceObject( pSoldier, SECONDHANDPOS, pObj, fNewItem ); - if ( pObj->exists() == false ) + if ( pObj->exists() == false || fStackOrSingleSlot ) { return( TRUE ); } @@ -7005,7 +7030,7 @@ BOOLEAN AutoPlaceObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN fNew if(pSoldier->inv[GUNSLINGPOCKPOS].exists() == false) // Long Gun use Gun Sling { PlaceObject( pSoldier, GUNSLINGPOCKPOS, pObj, fNewItem ); - if (pObj->exists() == false) + if (pObj->exists() == false || fStackOrSingleSlot) return( TRUE ); } break; @@ -7014,7 +7039,7 @@ BOOLEAN AutoPlaceObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN fNew if(pSoldier->inv[KNIFEPOCKPOS].exists() == false) // Knife { PlaceObject( pSoldier, KNIFEPOCKPOS, pObj, fNewItem ); - if (pObj->exists() == false) + if (pObj->exists() == false || fStackOrSingleSlot) return( TRUE ); } break; @@ -7029,7 +7054,7 @@ BOOLEAN AutoPlaceObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN fNew { // put on the armour! PlaceObject( pSoldier, VESTPOS, pObj, fNewItem ); - if ( pObj->exists() == false ) + if ( pObj->exists() == false || fStackOrSingleSlot ) { return( TRUE ); } @@ -7050,7 +7075,7 @@ BOOLEAN AutoPlaceObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN fNew // put on the armour! PlaceObject( pSoldier, LEGPOS, pObj, fNewItem ); } - if ( pObj->exists() == false ) + if ( pObj->exists() == false || fStackOrSingleSlot ) { return( TRUE ); } @@ -7060,7 +7085,7 @@ BOOLEAN AutoPlaceObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN fNew { // put on the armour! PlaceObject( pSoldier, HELMETPOS, pObj, fNewItem ); - if ( pObj->exists() == false ) + if ( pObj->exists() == false || fStackOrSingleSlot ) { return( TRUE ); } @@ -7075,7 +7100,7 @@ BOOLEAN AutoPlaceObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN fNew if ( (pSoldier->inv[HEAD1POS].exists() == false) && CompatibleFaceItem( pObj->usItem, pSoldier->inv[HEAD2POS].usItem ) ) { PlaceObject( pSoldier, HEAD1POS, pObj, fNewItem ); - if ( pObj->exists() == false ) + if ( pObj->exists() == false || fStackOrSingleSlot ) { return( TRUE ); } @@ -7083,7 +7108,7 @@ BOOLEAN AutoPlaceObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN fNew else if ( (pSoldier->inv[HEAD2POS].exists() == false) && CompatibleFaceItem( pObj->usItem, pSoldier->inv[HEAD1POS].usItem ) ) { PlaceObject( pSoldier, HEAD2POS, pObj, fNewItem ); - if ( pObj->exists() == false ) + if ( pObj->exists() == false || fStackOrSingleSlot ) { return( TRUE ); } @@ -7099,19 +7124,19 @@ BOOLEAN AutoPlaceObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN fNew { if (pSoldier->inv[LTHIGHPOCKPOS].exists() == false) { PlaceObject( pSoldier, LTHIGHPOCKPOS, pObj, fNewItem ); - if(pObj->exists() == false) + if(pObj->exists() == false || fStackOrSingleSlot) return( TRUE ); } if (pSoldier->inv[RTHIGHPOCKPOS].exists() == false) { PlaceObject( pSoldier, RTHIGHPOCKPOS, pObj, fNewItem ); - if(pObj->exists() == false) + if(pObj->exists() == false || fStackOrSingleSlot) return( TRUE ); } } else if(pSoldier->inv[VESTPOCKPOS].exists() == false && lbeClass == VEST_PACK) // Vest pack { PlaceObject( pSoldier, VESTPOCKPOS, pObj, fNewItem ); - if(pObj->exists() == false) + if(pObj->exists() == false || fStackOrSingleSlot) return( TRUE ); } else if(pSoldier->inv[CPACKPOCKPOS].exists() == false && lbeClass == COMBAT_PACK) // Combat pack @@ -7122,7 +7147,7 @@ BOOLEAN AutoPlaceObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN fNew if((pSoldier->inv[BPACKPOCKPOS].exists() == true && packCombo != 0 && (backCombo & packCombo)) || pSoldier->inv[BPACKPOCKPOS].exists() == false) { PlaceObject( pSoldier, CPACKPOCKPOS, pObj, fNewItem ); - if(pObj->exists() == false) + if(pObj->exists() == false || fStackOrSingleSlot) return( TRUE ); } } @@ -7140,7 +7165,7 @@ BOOLEAN AutoPlaceObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN fNew pSoldier->flags.DropPackFlag = FALSE; pSoldier->flags.ZipperFlag = FALSE; RenderBackpackButtons(ACTIVATE_BUTTON); /* CHRISL: Needed for new inventory backpack buttons */ - if(pObj->exists() == false) + if(pObj->exists() == false || fStackOrSingleSlot) return( TRUE ); } //} @@ -7150,9 +7175,9 @@ BOOLEAN AutoPlaceObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN fNew break; } - if (PlaceInAnySlot(pSoldier, pObj, (fNewItem == TRUE), bExcludeSlot) == true) { + if (PlaceInAnySlot(pSoldier, pObj, (fNewItem == TRUE), bExcludeSlot, fStackOrSingleSlot) == true) return TRUE; - } + return( FALSE ); } diff --git a/Tactical/Items.h b/Tactical/Items.h index 18c62a2c..8a474510 100644 --- a/Tactical/Items.h +++ b/Tactical/Items.h @@ -95,12 +95,12 @@ BOOLEAN AutoPlaceObjectAnywhere(SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLE BOOLEAN AutoPlaceObjectToWorld(SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, INT8 bVisible = TRUE); // Send fNewItem to true to set off new item glow in inv panel -BOOLEAN AutoPlaceObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN fNewItem, INT8 bExcludeSlot = NO_SLOT ); +BOOLEAN AutoPlaceObject( SOLDIERTYPE * pSoldier, OBJECTTYPE * pObj, BOOLEAN fNewItem, INT8 bExcludeSlot = NO_SLOT, BOOLEAN fStackOrSingleSlot = FALSE ); //ADB bool FitsInSmallPocket(OBJECTTYPE* pObj); -bool PlaceInAnySlot(SOLDIERTYPE* pSoldier, OBJECTTYPE* pObj, bool fNewItem, int bExcludeSlot = NO_SLOT); +bool PlaceInAnySlot(SOLDIERTYPE* pSoldier, OBJECTTYPE* pObj, bool fNewItem, int bExcludeSlot = NO_SLOT, bool fStackOrSingleSlot = FALSE); bool PlaceInAnyPocket(SOLDIERTYPE* pSoldier, OBJECTTYPE* pObj, bool fNewItem, int bExcludeSlot = NO_SLOT); bool PlaceInAnySmallPocket(SOLDIERTYPE* pSoldier, OBJECTTYPE* pObj, bool fNewItem, int bExcludeSlot = NO_SLOT); bool PlaceInAnyBigOrMediumPocket(SOLDIERTYPE* pSoldier, OBJECTTYPE* pObj, bool fNewItem, int bExcludeSlot = NO_SLOT); diff --git a/Tactical/Soldier Create.cpp b/Tactical/Soldier Create.cpp index 248e394e..b7aad00c 100644 --- a/Tactical/Soldier Create.cpp +++ b/Tactical/Soldier Create.cpp @@ -3837,7 +3837,7 @@ void CopyProfileItems( SOLDIERTYPE *pSoldier, SOLDIERCREATE_STRUCT *pCreateStruc //only npcs can have money fRet = CreateMoney(pProfile->uiMoney, &gTempObject ); if(fRet) - PlaceInAnySlot(pSoldier, &gTempObject, true); + AutoPlaceObject(pSoldier, &gTempObject, true); } } }