From 89b9a69b9bedf113009319bcc1434f50ed00e6ac Mon Sep 17 00:00:00 2001 From: Flugente Date: Fri, 13 Feb 2015 20:47:54 +0000 Subject: [PATCH] Fix: Militia does not equip multi-shot launchers if there are less than 3 shots in the sector. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7735 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Inventory Choosing.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Tactical/Inventory Choosing.cpp b/Tactical/Inventory Choosing.cpp index e7262e3d5..fa7045c19 100644 --- a/Tactical/Inventory Choosing.cpp +++ b/Tactical/Inventory Choosing.cpp @@ -4471,15 +4471,25 @@ void TakeMilitiaEquipmentfromSector( INT16 sMapX, INT16 sMapY, INT8 sMapZ, SOLDI // we investigate the launchers we found, and their ammo. if ( gGameExternalOptions.fMilitiaUseSectorInventory_Launcher && !si[SI_LAUNCHER].done ) { + // remember the best ammo count we found + UINT16 bestammocount = 0; + LauncherHelpMap::iterator itend = launcherhelpmap.end(); for (LauncherHelpMap::iterator it = launcherhelpmap.begin(); it != itend; ++it) { - // we pick the first launcher that needs no ammo or has enough ammo - if ( !(*it).second.fNeedsAmmo || (*it).second.ammocount > 3 ) + // if a launcher does not need ammo, take that one + if ( !(*it).second.fNeedsAmmo ) + { + usLauncherItem = (*it).first; + usLauncherAmmoLeftToTake = 0; + break; + } + // otherwise pick the one with the highest ammo count (but not higher than 3, we don't want to hoard all the ammo) + else if ( (*it).second.ammocount > bestammocount ) { usLauncherItem = (*it).first; usLauncherAmmoLeftToTake = (*it).second.ammocount ? 3 : 0; - break; + bestammocount = usLauncherAmmoLeftToTake; } } }