From 66c680e8a348160de75c4fcda72c444c8378d9c8 Mon Sep 17 00:00:00 2001 From: Dillon Pentz Date: Tue, 21 Feb 2023 19:30:09 +1300 Subject: [PATCH] [jak2] fix rare civilian flee crash (#2230) Fixes a rare crash that can sometimes happen when civilians are picking a direction to flee in, where a branch count may be 0, causing a divide by 0 MATH_EXCEPTION. --- goal_src/jak2/levels/city/common/civilian.gc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/goal_src/jak2/levels/city/common/civilian.gc b/goal_src/jak2/levels/city/common/civilian.gc index be11e38943..040bab6aef 100644 --- a/goal_src/jak2/levels/city/common/civilian.gc +++ b/goal_src/jak2/levels/city/common/civilian.gc @@ -403,7 +403,8 @@ (dotimes (s0-0 s2-0) (+! f30-0 (civilian-method-214 obj (-> s3-0 branch-array s0-0) (+ arg1 -1) arg2 s1-0)) ) - (set! arg3 (+ s1-0 (the float (/ (the int f30-0) s2-0)))) + ;; changed to fix a divide by zero crash + (set! arg3 (+ s1-0 (the float (/-0-guard (the int f30-0) s2-0)))) ) ) )