Merged from revision: 7219

Fixes (anv & Buggler)
- fix: backpacks stacked in the same sector inventory slot would share ownership, causing soldier to pick-up both of them, now when stacking ownership is automatically disabled,
- fix: when manually reorganizing backpacks in inventory slots, ownerships are properly swapped too,
- fix: when using auto pick-up backpack feature function was looping through non-existing items in sector inventory, possibly creating duplicates,
- fix: "drop all backpacks" feature was limited to 18 mercs, now it works for all player-controlled characters.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7220 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Wanne
2014-05-19 19:00:14 +00:00
parent f05dfc0b1e
commit 0fcbed45b3
2 changed files with 47 additions and 7 deletions
@@ -131,6 +131,8 @@ INT32 MAP_INVENTORY_POOL_SLOT_START_Y;
INT32 iCurrentlyHighLightedItem = -1; INT32 iCurrentlyHighLightedItem = -1;
BOOLEAN fFlashHighLightInventoryItemOnradarMap = FALSE; BOOLEAN fFlashHighLightInventoryItemOnradarMap = FALSE;
INT32 iCurrentlyPickedUpItem = -1;
// whether we are showing the inventory pool graphic // whether we are showing the inventory pool graphic
BOOLEAN fShowMapInventoryPool = FALSE; BOOLEAN fShowMapInventoryPool = FALSE;
// HEADROCK HAM 5: Flag telling us whether we've already redrawn the screen to show // HEADROCK HAM 5: Flag telling us whether we've already redrawn the screen to show
@@ -262,7 +264,7 @@ void DestroyMapInventoryButtons( void );
void DestroyStash( void ); void DestroyStash( void );
void BuildStashForSelectedSector( INT16 sMapX, INT16 sMapY, INT16 sMapZ ); void BuildStashForSelectedSector( INT16 sMapX, INT16 sMapY, INT16 sMapZ );
void BeginInventoryPoolPtr( OBJECTTYPE *pInventorySlot ); void BeginInventoryPoolPtr( OBJECTTYPE *pInventorySlot );
BOOLEAN PlaceObjectInInventoryStash( OBJECTTYPE *pInventorySlot, OBJECTTYPE *pItemPtr ); BOOLEAN PlaceObjectInInventoryStash( OBJECTTYPE *pInventorySlot, OBJECTTYPE *pItemPtr, INT32 iDestSlot = (-1), INT32 iSrcSlot = (-1) );
void RenderItemsForCurrentPageOfInventoryPool( void ); void RenderItemsForCurrentPageOfInventoryPool( void );
BOOLEAN RenderItemInPoolSlot( INT32 iCurrentSlot, INT32 iFirstSlotOnPage ); BOOLEAN RenderItemInPoolSlot( INT32 iCurrentSlot, INT32 iFirstSlotOnPage );
void UpdateHelpTextForInvnentoryStashSlots( void ); void UpdateHelpTextForInvnentoryStashSlots( void );
@@ -1485,6 +1487,8 @@ void MapInvenPoolSlots(MOUSE_REGION * pRegion, INT32 iReason )
sObjectSourceGridNo = pInventoryPoolList[ ( iCurrentInventoryPoolPage * MAP_INVENTORY_POOL_SLOT_COUNT ) + iCounter ].sGridNo; sObjectSourceGridNo = pInventoryPoolList[ ( iCurrentInventoryPoolPage * MAP_INVENTORY_POOL_SLOT_COUNT ) + iCounter ].sGridNo;
sObjectSourseSoldierID = pInventoryPoolList[ ( iCurrentInventoryPoolPage * MAP_INVENTORY_POOL_SLOT_COUNT ) + iCounter ].soldierID; sObjectSourseSoldierID = pInventoryPoolList[ ( iCurrentInventoryPoolPage * MAP_INVENTORY_POOL_SLOT_COUNT ) + iCounter ].soldierID;
iCurrentlyPickedUpItem = ( iCurrentInventoryPoolPage * MAP_INVENTORY_POOL_SLOT_COUNT ) + iCounter;
// check if this is the loaded sector, if so, then notify player, can't do anything // check if this is the loaded sector, if so, then notify player, can't do anything
if( ( sSelMapX == gWorldSectorX )&&( gWorldSectorY == sSelMapY ) &&(gbWorldSectorZ == iCurrentMapSectorZ ) ) if( ( sSelMapX == gWorldSectorX )&&( gWorldSectorY == sSelMapY ) &&(gbWorldSectorZ == iCurrentMapSectorZ ) )
{ {
@@ -1560,7 +1564,8 @@ void MapInvenPoolSlots(MOUSE_REGION * pRegion, INT32 iReason )
} }
// Else, try to place here // Else, try to place here
if ( PlaceObjectInInventoryStash( &( pInventoryPoolList[ ( iCurrentInventoryPoolPage * MAP_INVENTORY_POOL_SLOT_COUNT ) + iCounter ].object ), gpItemPointer ) ) if ( PlaceObjectInInventoryStash( &( pInventoryPoolList[ ( iCurrentInventoryPoolPage * MAP_INVENTORY_POOL_SLOT_COUNT ) + iCounter ].object ), gpItemPointer,
( iCurrentInventoryPoolPage * MAP_INVENTORY_POOL_SLOT_COUNT ) + iCounter, iCurrentlyPickedUpItem ) )
{ {
// HEADROCK HAM 5: A LOT of functions rely on these flags being set. So set them!! // HEADROCK HAM 5: A LOT of functions rely on these flags being set. So set them!!
pInventoryPoolList[(iCurrentInventoryPoolPage*MAP_INVENTORY_POOL_SLOT_COUNT)+iCounter].bVisible = TRUE; pInventoryPoolList[(iCurrentInventoryPoolPage*MAP_INVENTORY_POOL_SLOT_COUNT)+iCounter].bVisible = TRUE;
@@ -1593,8 +1598,8 @@ void MapInvenPoolSlots(MOUSE_REGION * pRegion, INT32 iReason )
{ {
pInventoryPoolList[ ( iCurrentInventoryPoolPage * MAP_INVENTORY_POOL_SLOT_COUNT ) + iCounter ].sGridNo = sObjectSourceGridNo; pInventoryPoolList[ ( iCurrentInventoryPoolPage * MAP_INVENTORY_POOL_SLOT_COUNT ) + iCounter ].sGridNo = sObjectSourceGridNo;
} }
if( sObjectSourseSoldierID != -1 ) //if( sObjectSourseSoldierID != -1 )
pInventoryPoolList[ ( iCurrentInventoryPoolPage * MAP_INVENTORY_POOL_SLOT_COUNT ) + iCounter ].soldierID = sObjectSourseSoldierID; // pInventoryPoolList[ ( iCurrentInventoryPoolPage * MAP_INVENTORY_POOL_SLOT_COUNT ) + iCounter ].soldierID = sObjectSourseSoldierID;
} }
//} //}
@@ -2399,11 +2404,20 @@ void BeginInventoryPoolPtr( OBJECTTYPE *pInventorySlot )
} }
} }
BOOLEAN PlaceObjectInInventoryStash( OBJECTTYPE *pInventorySlot, OBJECTTYPE *pItemPtr ) BOOLEAN PlaceObjectInInventoryStash( OBJECTTYPE *pInventorySlot, OBJECTTYPE *pItemPtr, INT32 iDestSlot, INT32 iSrcSlot )
{ {
// if there is something there, swap it, if they are of the same type and stackable then add to the count // if there is something there, swap it, if they are of the same type and stackable then add to the count
if (pInventorySlot->exists() == false) if (pInventorySlot->exists() == false)
{ {
if( iSrcSlot != (-1) )
{
// anv: swap ownerships too
if( pInventoryPoolList[ iSrcSlot ].soldierID == sObjectSourseSoldierID )
{
pInventoryPoolList[ iSrcSlot ].soldierID = (-1);
}
pInventoryPoolList[ iDestSlot ].soldierID = sObjectSourseSoldierID;
}
// placement in an empty slot // placement in an empty slot
pItemPtr->MoveThisObjectTo(*pInventorySlot); pItemPtr->MoveThisObjectTo(*pInventorySlot);
} }
@@ -2411,11 +2425,31 @@ BOOLEAN PlaceObjectInInventoryStash( OBJECTTYPE *pInventorySlot, OBJECTTYPE *pIt
{ {
if (pItemPtr->usItem == pInventorySlot->usItem && ItemSlotLimit(pItemPtr, STACK_SIZE_LIMIT) >= 2) if (pItemPtr->usItem == pInventorySlot->usItem && ItemSlotLimit(pItemPtr, STACK_SIZE_LIMIT) >= 2)
{ {
// anv: disable soldier's ownership, as otherwise stacked backpacks would share it
if( iDestSlot != (-1) && iSrcSlot != (-1) )
{
pInventoryPoolList[ iDestSlot ].soldierID = (-1);
pInventoryPoolList[ iSrcSlot ].soldierID = (-1);
iCurrentlyPickedUpItem = iDestSlot;
sObjectSourseSoldierID = (-1);
}
// stacking // stacking
pInventorySlot->AddObjectsToStack(*pItemPtr); pInventorySlot->AddObjectsToStack(*pItemPtr);
} }
else else
{ {
if( iDestSlot != (-1) && iSrcSlot != (-1) )
{
// anv: swap ownerships too
if( pInventoryPoolList[ iSrcSlot ].soldierID == sObjectSourseSoldierID )
{
pInventoryPoolList[ iSrcSlot ].soldierID = (-1);
}
INT32 iTempSoldierID = pInventoryPoolList[ iDestSlot ].soldierID;
pInventoryPoolList[ iDestSlot ].soldierID = sObjectSourseSoldierID;
sObjectSourseSoldierID = iTempSoldierID;
iCurrentlyPickedUpItem = iDestSlot;
}
SwapObjs( pItemPtr, pInventorySlot ); SwapObjs( pItemPtr, pInventorySlot );
} }
} }
@@ -4877,6 +4911,12 @@ void SortSectorInventoryStackAndMerge(bool ammoOnly )
SOLDIERTYPE * pSoldier = &(Menptr[ gCharactersList[ bSelectedInfoChar ].usSolID ]); SOLDIERTYPE * pSoldier = &(Menptr[ gCharactersList[ bSelectedInfoChar ].usSolID ]);
for ( UINT32 uiLoop = 0; uiLoop < pInventoryPoolList.size(); uiLoop++ )
{
// anv: disable soldier's ownership, as otherwise stacked backpacks would share it
pInventoryPoolList[ uiLoop ].soldierID = (-1);
}
// Run through sector inventory. // Run through sector inventory.
for ( UINT32 uiLoop = 0; uiLoop < pInventoryPoolList.size(); uiLoop++ ) for ( UINT32 uiLoop = 0; uiLoop < pInventoryPoolList.size(); uiLoop++ )
{ {
+2 -2
View File
@@ -4374,7 +4374,7 @@ BOOLEAN ChangeDropPackStatus(SOLDIERTYPE *pSoldier, BOOLEAN newStatus)
// have a CTD, so lets resolve that here. // have a CTD, so lets resolve that here.
if(Item[gWorldItems[wi].object.usItem].usItemClass != IC_LBEGEAR) if(Item[gWorldItems[wi].object.usItem].usItemClass != IC_LBEGEAR)
gWorldItems[wi].soldierID = -1; gWorldItems[wi].soldierID = -1;
if(gWorldItems[wi].soldierID == pSoldier->ubID && gWorldItems[wi].object.exists() == true && Item[gWorldItems[wi].object.usItem].usItemClass == IC_LBEGEAR && LoadBearingEquipment[Item[gWorldItems[wi].object.usItem].ubClassIndex].lbeClass == BACKPACK) if(gWorldItems[wi].soldierID == pSoldier->ubID && gWorldItems[wi].fExists == TRUE && Item[gWorldItems[wi].object.usItem].usItemClass == IC_LBEGEAR && LoadBearingEquipment[Item[gWorldItems[wi].object.usItem].ubClassIndex].lbeClass == BACKPACK)
{ {
for (int x = 0; x < gWorldItems[wi].object.ubNumberOfObjects; ++x) { for (int x = 0; x < gWorldItems[wi].object.ubNumberOfObjects; ++x) {
// Is the item we dropped in this sector and does it have an active LBENODE flag? // Is the item we dropped in this sector and does it have an active LBENODE flag?
@@ -4653,7 +4653,7 @@ void BtnDropPackCallback(GUI_BUTTON *btn,INT32 reason)
if ( _KeyDown( SHIFT ) ) if ( _KeyDown( SHIFT ) )
{ {
INT8 bAssignment = gpSMCurrentMerc->bAssignment; INT8 bAssignment = gpSMCurrentMerc->bAssignment;
for(int x=0; x<18; x++) for( int x = gTacticalStatus.Team[ OUR_TEAM ].bFirstID; x <= gTacticalStatus.Team[ OUR_TEAM ].bLastID; x++ )
{ {
/* Is DropPackFlag currently false and is there something in the backpack pocket? If so, we haven't /* Is DropPackFlag currently false and is there something in the backpack pocket? If so, we haven't
dropped a pack yet and apparently want to*/ dropped a pack yet and apparently want to*/