[jak2] fix bad actors using unloaded types (#2402)

Actors that use types from a level that got unloaded should now get
killed immediately instead of continuing to exist and eventually crash
the game.

NOTE: Will spam the console whenever a bad actor tries to spawn. I would
like to document all instances of where this happens!
This commit is contained in:
ManDude
2023-03-24 07:18:43 +00:00
committed by GitHub
parent f56e807d75
commit cc16f62428
23 changed files with 4717 additions and 4682 deletions
+31 -12
View File
@@ -20,8 +20,7 @@
e
)
;; custom entity functions for pc port
(defun-debug entity-inspect-draw ((inspect-info entity-debug-inspect))
(defun entity-inspect-draw ((inspect-info entity-debug-inspect))
"draw text about an entity on screen"
(update-pad inspect-info 0)
@@ -29,8 +28,7 @@
(set! *debug-actor* (the string (and (-> inspect-info show-actor-info) name)))
;; draw trans
(add-debug-x #t (bucket-id debug-no-zbuf1) (-> e trans) (static-rgba 255 255 0 128))
(if (or (not (-> inspect-info show-actor-info)) (!= (-> e type) entity-actor) (and (= (-> e type) entity-actor) (not (-> (the entity-actor e) extra process))))
(add-debug-text-3d #t (bucket-id debug-no-zbuf1) name (-> e trans) (font-color red) (new 'static 'vector2h :y 8)))
(add-debug-text-3d #t (bucket-id debug-no-zbuf1) name (-> e trans) (font-color red) (new 'static 'vector2h :y 8))
;; start writing text
(let* ((begin-y (- 16 (* (-> inspect-info scroll-y) 16))) (cur-y begin-y) (y-adv 16))
@@ -40,7 +38,7 @@
(draw-string-xy
(string-format "~3L~A~0L ~A~%tags: ~D size: ~D aid: #x~x~%R1/L1 scroll L3 toggle display-actor-info~%--------------------" (-> e type) name (length e) (asize-of e) (-> e aid))
debug-buf 352 cur-y (font-color default) (font-flags shadow kerning middle))
(+! cur-y (* 10 6))
(+! cur-y (* 14 4))
(cond
((type-type? (-> e type) entity-actor)
(let ((actor (the entity-actor e)))
@@ -48,7 +46,7 @@
(draw-string-xy
(string-format "etype: ~A~%vis: ~D task: ~S" (-> actor etype) (-> actor vis-id) (game-task->string (-> actor task)))
debug-buf 352 cur-y (font-color default) (font-flags shadow kerning middle))
(+! cur-y (* 10 3))
(+! cur-y (* 14 2))
)
)
)
@@ -74,7 +72,7 @@
)
;; some water-height info but with 5 elts
((and (= (-> e tag i name) 'water-height) (= (-> e tag i elt-count) 4) (= (-> e tag i elt-type) float))
(+! y-adv (* 10 3))
(+! y-adv (* 14 3))
(format *debug-temp-string* " ~mm ~mm ~mm~%(~S)~%~mm"
(-> (the (pointer float) data) 0)
(-> (the (pointer float) data) 1)
@@ -125,7 +123,8 @@
(case (-> e tag i name)
;; meters are better here
(('spring-height 'vis-dist 'height-info 'distance 'cam-notice-dist 'cam-vert 'cam-horz 'idle-distance
'nearest-y-threshold 'center-point 'center-radius 'notice-dist 'trigger-height 'notice-top)
'nearest-y-threshold 'center-point 'center-radius 'notice-dist 'trigger-height 'notice-top
'elevator-move-rate 'elevator-y-threshold 'elevator-xz-threshold 'height)
(format *debug-temp-string* "~mm" (-> (the (pointer float) data) ii))
)
;; degrees are better for these
@@ -137,7 +136,16 @@
)
)
)
((int8) (format *debug-temp-string* "~D" (-> (the (pointer int8) data) ii)))
((int8)
(case (-> e tag i name)
(('task-actor)
(format *debug-temp-string* "~S" (game-task-actor->string (the-as game-task-actor (-> (the (pointer uint8) data) ii))))
)
(else
(format *debug-temp-string* "~D" (-> (the (pointer int8) data) ii))
)
)
)
((int16) (format *debug-temp-string* "~D" (-> (the (pointer int16) data) ii)))
((int32)
(case (-> e tag i name)
@@ -158,6 +166,9 @@
(('shadow-mask)
(format *debug-temp-string* "#b~b" (-> (the (pointer uint8) data) ii))
)
(('light-index)
(format *debug-temp-string* "~D" (-> (the (pointer uint8) data) ii))
)
(('task)
(format *debug-temp-string* "~S" (game-task->string (the-as game-task (-> (the (pointer uint8) data) ii))))
)
@@ -183,6 +194,14 @@
(format *debug-temp-string* "~%(~S)" (begin (bit-enum->string enemy-option (-> (the (pointer uint32) data) ii) (clear *temp-string*)) *temp-string*))
(+! y-adv 14)
)
(('kill-mask)
(format *debug-temp-string* "~%(~S)" (begin (bit-enum->string task-mask (-> (the (pointer uint32) data) ii) (clear *temp-string*)) *temp-string*))
(+! y-adv 14)
)
;; (('elevator-flags)
;; (format *debug-temp-string* "~%(~S)" (begin (bit-enum->string elevator-flags (-> (the (pointer uint32) data) ii) (clear *temp-string*)) *temp-string*))
;; (+! y-adv 14)
;; )
(else
(format *debug-temp-string* "#x~x" (-> (the (pointer uint32) data) ii))
)
@@ -235,10 +254,10 @@
((actor-group)
(let* ((group (-> (the (pointer actor-group) data) ii))
(len (-> group length)))
(format *debug-temp-string* "~%group ~D:" ii len)
(format *debug-temp-string* "~%--- GROUP ~D: ---" ii len)
(dotimes (iii len)
(format *debug-temp-string* " ~S" (res-lump-struct (entity-by-aid (-> group data iii id)) 'name string))
)
(format *debug-temp-string* "~% #x~x (~S)" (-> group data iii id) (res-lump-struct (entity-by-aid (-> group data iii id)) 'name string))
(+! y-adv 14))
)
(+! y-adv 14)
)