From 2cdc34693491a1f8ff39f7a5f07c96733a7c73a2 Mon Sep 17 00:00:00 2001 From: rftr Date: Tue, 3 May 2022 22:24:44 +0000 Subject: [PATCH] fix divide-by-zero crash in some cases when crepitus queen is doing a tentacle attack bug found by BigBritishGuy on discord git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9376 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- TacticalAI/Attacks.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TacticalAI/Attacks.cpp b/TacticalAI/Attacks.cpp index 3d24419d..b3fee114 100644 --- a/TacticalAI/Attacks.cpp +++ b/TacticalAI/Attacks.cpp @@ -2061,7 +2061,7 @@ void CalcTentacleAttack(SOLDIERTYPE *pSoldier, ATTACKTYPE *pBestStab ) ubRawAPCost = ubMinAPCost; // sevenfm: 100AP system - iHitRate = (pSoldier->bActionPoints * ubChanceToHit) / (ubRawAPCost + ubAimTime * APBPConstants[AP_CLICK_AIM]); + iHitRate = (pSoldier->bActionPoints * ubChanceToHit) / max(1,(ubRawAPCost + ubAimTime * APBPConstants[AP_CLICK_AIM])); //iHitRate = (pSoldier->bActionPoints * ubChanceToHit) / (ubRawAPCost + ubAimTime); //NumMessage("hitRate = ",iHitRate);