From 48819f860a09b62ac6baaf8294703a0d207141fc Mon Sep 17 00:00:00 2001 From: Flugente Date: Sun, 14 Sep 2014 21:23:16 +0000 Subject: [PATCH] Fix: Equipping militia with guns and ammo could lead to creation of ammo items with 0 bullets. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7518 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Inventory Choosing.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Tactical/Inventory Choosing.cpp b/Tactical/Inventory Choosing.cpp index 3ce9c537..b016985c 100644 --- a/Tactical/Inventory Choosing.cpp +++ b/Tactical/Inventory Choosing.cpp @@ -4660,7 +4660,12 @@ void TakeMilitiaEquipmentfromSector( INT16 sMapX, INT16 sMapY, INT8 sMapZ, SOLDI (*pObj)[i]->data.ubShotsLeft -= takeammo; if ( !(*pObj)[i]->data.ubShotsLeft ) - pWorldItem[ uiCount ].object.MoveThisObjectTo(gTempObject, 1 ); + { + pWorldItem[uiCount].object.RemoveObjectAtIndex( i ); + + // we removed an item from the stack - set back the loop variable so we don't miss an object + --i; + } } if ( pWorldItem[ uiCount ].object.ubNumberOfObjects < 1 ) @@ -4668,7 +4673,7 @@ void TakeMilitiaEquipmentfromSector( INT16 sMapX, INT16 sMapY, INT8 sMapZ, SOLDI if ( pWorldItem[ uiCount ].sGridNo != NOWHERE ) RemoveItemFromPool(pWorldItem[ uiCount ].sGridNo, uiCount, pWorldItem[ uiCount ].ubLevel); - pWorldItem[ uiCount ].fExists = FALSE; + pWorldItem[uiCount].fExists = FALSE; } } } @@ -4700,7 +4705,7 @@ void TakeMilitiaEquipmentfromSector( INT16 sMapX, INT16 sMapY, INT8 sMapZ, SOLDI if ( pWorldItem[ uiCount ].sGridNo != NOWHERE ) RemoveItemFromPool(pWorldItem[ uiCount ].sGridNo, uiCount, pWorldItem[ uiCount ].ubLevel); - pWorldItem[ uiCount ].fExists = FALSE; + pWorldItem[uiCount].fExists = FALSE; } } }