From beeb01e0b4783be88e04662f1c5e7d127e428cfd Mon Sep 17 00:00:00 2001 From: Wanne Date: Mon, 20 Jun 2011 20:03:35 +0000 Subject: [PATCH] - Bugfix: Fixed CTD if weapon doesn't have ubDeadliness set it causes a division by zero and a CTD. (fix by Dougster) o Specifically an enemy had binoculars in his hand, and went to pick up a weapon off the ground, and it would crash. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@4506 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- TacticalAI/FindLocations.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/TacticalAI/FindLocations.cpp b/TacticalAI/FindLocations.cpp index aac2f01e..c54fce6b 100644 --- a/TacticalAI/FindLocations.cpp +++ b/TacticalAI/FindLocations.cpp @@ -1866,7 +1866,14 @@ INT8 SearchForItems( SOLDIERTYPE * pSoldier, INT8 bReason, UINT16 usItem ) { if (Weapon[pObj->usItem].ubDeadliness > Weapon[pSoldier->inv[HANDPOS].usItem].ubDeadliness) { - iTempValue = 100 * Weapon[pObj->usItem].ubDeadliness / Weapon[pSoldier->inv[HANDPOS].usItem].ubDeadliness; + if ((Weapon[pSoldier->inv[HANDPOS].usItem].ubDeadliness != NULL) && (Weapon[pSoldier->inv[HANDPOS].usItem].ubDeadliness >= 0)) + { + iTempValue = 100 * Weapon[pObj->usItem].ubDeadliness / Weapon[pSoldier->inv[HANDPOS].usItem].ubDeadliness; + } + else + { + iTempValue = 100 * Weapon[pObj->usItem].ubDeadliness; + } } else {