From aa82e0010cdbd5623fbd9d303266e1046bb3eb01 Mon Sep 17 00:00:00 2001 From: Flugente Date: Tue, 20 Aug 2013 22:53:01 +0000 Subject: [PATCH] possible division by 0 for blind soldiers git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6300 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Weapons.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Tactical/Weapons.cpp b/Tactical/Weapons.cpp index a4f3772e..164318b0 100644 --- a/Tactical/Weapons.cpp +++ b/Tactical/Weapons.cpp @@ -5009,7 +5009,9 @@ UINT32 CalcNewChanceToHitGun(SOLDIERTYPE *pSoldier, INT32 sGridNo, INT16 ubAimTi gbForceWeaponNotReady = true; sDistVisNoScope = pSoldier->GetMaxDistanceVisible(sGridNo, pSoldier->bTargetLevel, CALC_FROM_ALL_DIRS ) * CELL_X_SIZE; gbForceWeaponNotReady = false; - scopeRangeMod = (float)sDistVis / (float)sDistVisNoScope; // percentage DistVis has been enhanced due to an attached scope + + // Flugente: blind soldiers have sDistVisNoScope = 0... + scopeRangeMod = (float)sDistVis / (float)min(1.0f, sDistVisNoScope); // percentage DistVis has been enhanced due to an attached scope iSightRange = (INT32)(iSightRange / scopeRangeMod); if(iSightRange > 0){ //CHRISL: The LOS system, which determines whether to display an enemy unit, does not factor in the AimBonus tag during it's calculations. So having