Fixed a CTD that occured when reloading a weapon from the sector inventory panel.

Fixed the sector inventory panel so that you could reload weapons that could be stacked.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@2046 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
ChrisL
2008-04-18 22:41:09 +00:00
parent 38ee990e9f
commit 896891431d
4 changed files with 18 additions and 7 deletions
+11
View File
@@ -2850,6 +2850,11 @@ BOOLEAN ReloadGun( SOLDIERTYPE * pSoldier, OBJECTTYPE * pGun, OBJECTTYPE * pAmmo
bAPs = 0;
//CHRISL: If we enter here from the sector inventory panel, we won't have soldier info. So setup a blank soldier to
// avoid a crash later in the code.
if(pSoldier == NULL)
pSoldier = new SOLDIERTYPE;
if ( (gTacticalStatus.uiFlags & TURNBASED) && (gTacticalStatus.uiFlags & INCOMBAT) )
{
//CHRISL: Alter this so we treat clip fed weapons differently from weapons that load with loose rounds
@@ -2926,6 +2931,12 @@ BOOLEAN ReloadGun( SOLDIERTYPE * pSoldier, OBJECTTYPE * pGun, OBJECTTYPE * pAmmo
}
}
//CHRISL: We need to verify that the passed subObject actually exists. We could get passed an empty subObject if we
// reload a stack of weapons from the stack popup. If this is the case, reset subObject to the last item in the
// stack
if(subObject >= pGun->ubNumberOfObjects)
subObject = ammoObject = pGun->ubNumberOfObjects-1;
//CHRISL: If reloading with a stack, we probably want the item with the most ammo still in it
if (fReloadingWithStack)
{