mirror of
https://github.com/1dot13/source.git
synced 2026-09-16 14:47:17 +02:00
Fix: nada items or CTD when 'move item' assignment takes items from a sector that is currently loaded in tactical.
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6288 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+27
-17
@@ -6002,6 +6002,12 @@ void HandleEquipmentMove( INT16 sMapX, INT16 sMapY, INT8 bZ )
|
|||||||
|
|
||||||
pWorldItem_Target[ uiCount ].fExists = FALSE;
|
pWorldItem_Target[ uiCount ].fExists = FALSE;
|
||||||
|
|
||||||
|
// if the sector is currently loaded, we need to also remove items from item pools
|
||||||
|
if( ( gWorldSectorX == targetX )&&( gWorldSectorY == targetY ) && (gbWorldSectorZ == bZ ) )
|
||||||
|
{
|
||||||
|
RemoveItemFromPool(pWorldItem_Target[ uiCount ].sGridNo, uiCount, pWorldItem_Target[ uiCount ].ubLevel);
|
||||||
|
}
|
||||||
|
|
||||||
if ( moveditems > maxitems )
|
if ( moveditems > maxitems )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -6040,28 +6046,32 @@ void HandleEquipmentMove( INT16 sMapX, INT16 sMapY, INT8 bZ )
|
|||||||
if ( !moveditems )
|
if ( !moveditems )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// hack
|
// if the sector we took stuff from isn't loaded, do a resort, otherwise the item list will have holes (linked lists have to be rebuilt)
|
||||||
WORLDITEM* pWorldItem_tmp = new WORLDITEM[ uiTotalNumberOfRealItems_Target ];
|
WORLDITEM* pWorldItem_tmp = NULL;
|
||||||
|
if( ( gWorldSectorX != targetX ) || ( gWorldSectorY != targetY ) || (gbWorldSectorZ != bZ ) )
|
||||||
// copy over old inventory
|
|
||||||
UINT32 newcount = 0;
|
|
||||||
for( UINT32 uiCount = 0; uiCount < uiTotalNumberOfRealItems_Target; ++uiCount )
|
|
||||||
{
|
{
|
||||||
if ( pWorldItem_Target[ uiCount ].fExists )
|
pWorldItem_tmp = new WORLDITEM[ uiTotalNumberOfRealItems_Target ];
|
||||||
|
|
||||||
|
// copy over old inventory
|
||||||
|
UINT32 newcount = 0;
|
||||||
|
for( UINT32 uiCount = 0; uiCount < uiTotalNumberOfRealItems_Target; ++uiCount )
|
||||||
{
|
{
|
||||||
pWorldItem_tmp[newcount] = pWorldItem_Target[uiCount];
|
if ( pWorldItem_Target[ uiCount ].fExists )
|
||||||
++newcount;
|
{
|
||||||
|
pWorldItem_tmp[newcount] = pWorldItem_Target[uiCount];
|
||||||
|
++newcount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// use the new map
|
// use the new map
|
||||||
if ( pWorldItem_Target )
|
if ( pWorldItem_Target )
|
||||||
{
|
{
|
||||||
delete[] pWorldItem_Target;
|
delete[] pWorldItem_Target;
|
||||||
pWorldItem_Target = NULL;
|
pWorldItem_Target = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pWorldItem_Target = pWorldItem_tmp;
|
pWorldItem_Target = pWorldItem_tmp;
|
||||||
|
}
|
||||||
|
|
||||||
// save the changed inventory
|
// save the changed inventory
|
||||||
if( ( targetX == gWorldSectorX )&&( gWorldSectorY == targetY ) && (gbWorldSectorZ == bZ ) )
|
if( ( targetX == gWorldSectorX )&&( gWorldSectorY == targetY ) && (gbWorldSectorZ == bZ ) )
|
||||||
|
|||||||
Reference in New Issue
Block a user