[game] fix ps crash and disappearing ram (#1398)

* [game] fix ps crash and disappearing ram

* add better comment
This commit is contained in:
water111 2022-05-31 22:19:54 -04:00 committed by GitHub
parent b2a1afddd9
commit b5074a3520
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View file

@ -5,6 +5,13 @@
;; name in dgo: navigate
;; dgos: GAME, ENGINE
;; note: added this to avoid a bug where enemies with NaN positions end up inside the nav mesh.
;; it's not clear yet why the enemies have NaN positions, but nothing else seems to go wrong if we
;; ignore them here. It's possible this happens as enemies are spawned/despawned by the visibility system.
(defmacro is-nan? (flt)
`(and (< 0.0 ,flt) (< ,flt 0.0))
)
;; DECOMP BEGINS
(define *nav-timer* (new 'global 'stopwatch))
@ -2080,7 +2087,9 @@
(f0-9 (+ (-> sv-112 w) (-> sv-80 shape nav-radius)))
(f2-17 (+ 40960.0 f0-9))
)
(when (< f1-3 (* f2-17 f2-17))
;; HACK: added a NaN check here. it seems like some enemies have bogus positions (maybe on their first frame?)
;; and in these cases we shouldn't bother including them in the mesh.
(when (and (< f1-3 (* f2-17 f2-17)) (not (is-nan? (-> sv-112 x))))
(let ((v1-94 sv-96)
(a0-47 (-> sv-80 mesh origin))
)

View file

@ -5,6 +5,8 @@
;; name in dgo: logic-target
;; dgos: GAME, ENGINE
;; target-start is modified due to changing the size of the stack in gkernel.gc
;; DECOMP BEGINS
(defbehavior build-conversions target ((arg0 vector))
@ -2082,7 +2084,8 @@
(let* ((s5-0 (get-process *target-dead-pool* target #x4000))
(v1-3 (when s5-0
(let ((t9-2 (method-of-type target activate)))
(t9-2 (the-as target s5-0) *target-pool* 'target (&-> *dram-stack* 14336))
;; note: this constant must be DPROCESS_STACK_SIZE
(t9-2 (the-as target s5-0) *target-pool* 'target (&-> *dram-stack* DPROCESS_STACK_SIZE))
)
(run-now-in-process s5-0 init-target arg1)
(-> s5-0 ppointer)