[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.
This commit is contained in:
Dillon Pentz 2023-02-21 19:30:09 +13:00 committed by GitHub
parent a76f558537
commit 66c680e8a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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))))
)
)
)