diff --git a/goal_src/jak1/kernel/gstate.gc b/goal_src/jak1/kernel/gstate.gc index 1fc3e7cf53..29ee50f60d 100644 --- a/goal_src/jak1/kernel/gstate.gc +++ b/goal_src/jak1/kernel/gstate.gc @@ -399,7 +399,11 @@ It type checks the arguments for the entry function. (defun send-event-function ((proc process-tree) (msg event-message-block)) "Function to send an event to a process. Please use the send-event macros when possible" (with-pp - (when (and proc (!= (-> proc type) process-tree) (-> (the process proc) event-hook)) + ;; og:preserve-this check that we have a _valid_ process. originally this just checked + ;; that type != process-tree, but sometimes we might get stale process ref (qbert-plat-master) + (when (and (valid? proc process #f #f 0) + (nonzero? (-> (the process proc) pid)) + (-> (the process proc) event-hook)) (let ((pp-backup pp)) (set! pp (the process proc)) (let ((result ((-> (the process proc) event-hook) (-> msg from) (-> msg num-params) (-> msg message) msg))) diff --git a/goal_src/jak2/kernel/gstate.gc b/goal_src/jak2/kernel/gstate.gc index db94c4fb61..c00c37af62 100644 --- a/goal_src/jak2/kernel/gstate.gc +++ b/goal_src/jak2/kernel/gstate.gc @@ -501,7 +501,11 @@ It type checks the arguments for the entry function. (defun send-event-function ((arg0 process-tree) (arg1 event-message-block)) "Send an event block to a process." (with-pp - (when (and arg0 (!= (-> arg0 type) process-tree) (-> (the-as process arg0) event-hook) (-> arg1 from)) + ;; og:preserve-this check that we have a _valid_ process. originally this just checked + ;; that type != process-tree, but sometimes we might get stale process ref (jak1 qbert-plat-master) + (when (and (valid? arg0 process (the-as string #f) #f 0) + (nonzero? (-> (the-as process arg0) pid)) + (-> (the-as process arg0) event-hook) (-> arg1 from)) (let ((gp-0 pp)) (set! pp (the-as process arg0)) (let ((v0-0 ((-> (the-as process arg0) event-hook) (-> arg1 from 0) (-> arg1 num-params) (-> arg1 message) arg1))) diff --git a/goal_src/jak3/kernel/gstate.gc b/goal_src/jak3/kernel/gstate.gc index 50d5ec6e55..f2b0e6c027 100644 --- a/goal_src/jak3/kernel/gstate.gc +++ b/goal_src/jak3/kernel/gstate.gc @@ -461,7 +461,11 @@ (defun send-event-function ((arg0 process-tree) (arg1 event-message-block)) (with-pp - (when (and arg0 (!= (-> arg0 type) process-tree) (-> (the-as process arg0) event-hook) (-> arg1 from)) + ;; og:preserve-this check that we have a _valid_ process. originally this just checked + ;; that type != process-tree, but sometimes we might get stale process ref (jak1 qbert-plat-master) + (when (and (valid? arg0 process (the-as string #f) #f 0) + (nonzero? (-> (the-as process arg0) pid)) + (-> (the-as process arg0) event-hook) (-> arg1 from)) (let ((gp-0 pp)) (set! pp (the-as process arg0)) (let ((v0-0 ((-> (the-as process arg0) event-hook) (-> arg1 from 0) (-> arg1 num-params) (-> arg1 message) arg1)))