From 7f467f4f806f12dd6053be8e5af91be5d9d52846 Mon Sep 17 00:00:00 2001 From: Flugente Date: Sun, 28 Apr 2013 15:58:58 +0000 Subject: [PATCH] Fix: militia equipment item fitness function still considered ammo even if MILITIA_USE_SECTOR_EQUIPMENT_AMMO was false, thus possibly ignored guns that had no ammo loaded git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6030 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Inventory Choosing.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Tactical/Inventory Choosing.cpp b/Tactical/Inventory Choosing.cpp index 3a9d2203d..3ef2f5ca6 100644 --- a/Tactical/Inventory Choosing.cpp +++ b/Tactical/Inventory Choosing.cpp @@ -4027,7 +4027,7 @@ void TakeMilitiaEquipmentfromSector( INT16 sMapX, INT16 sMapY, INT8 sMapZ, SOLDI UINT16 numcrates = 0; BOOLEAN fNewMagCreated = FALSE; OBJECTTYPE newAmmoObj; - BOOLEAN fSearchForAmmo = TRUE; + BOOLEAN fSearchForAmmo = TRUE; UINT16 usLauncherItem = 0; UINT8 usLauncherAmmoLeftToTake = 0; UINT16 usSelectedGunBulletsNeeded = 0; // how many bullets do we want for our gun @@ -4367,17 +4367,20 @@ void TakeMilitiaEquipmentfromSector( INT16 sMapX, INT16 sMapY, INT8 sMapZ, SOLDI Calibre_BulletCountMap::iterator calibremap_it = calibrebulletountmap.find( calibre ); - if ( calibremap_it != calibrebulletountmap.end() ) + if ( fSearchForAmmo ) { - UINT32 bullets = GetTotalCalibreAmmo( &((*calibremap_it).second) ); + // only evaluate of ammo is found! + if ( calibremap_it != calibrebulletountmap.end() ) + { + UINT32 bullets = GetTotalCalibreAmmo( &((*calibremap_it).second) ); - EvaluateObjForItem_WithAmmo( pWorldItem, pObj, uiCount, &si[SI_GUN], bullets ); + EvaluateObjForItem_WithAmmo( pWorldItem, pObj, uiCount, &si[SI_GUN], bullets ); + } + } + else + { + EvaluateObjForItem( pWorldItem, pObj, uiCount, &si[SI_GUN] ); } - // no ammo found... a gun without bullets is useless, ignore this thing - //else - //{ - //EvaluateObjForItem_WithAmmo( pWorldItem, pObj, uiCount, &si[SI_GUN], 0 ); - //} } else if ( Item[pWorldItem[ uiCount ].object.usItem].usItemClass & (IC_GRENADE|IC_BOMB) && !si[SI_LAUNCHER].done ) {