Smarter send-event detection and fix touching-list bugs (#1320)

This commit is contained in:
ManDude
2022-04-18 23:31:59 +01:00
committed by GitHub
parent 1b03feac82
commit e4c2f81e3a
16 changed files with 210 additions and 184 deletions
+4 -8
View File
@@ -840,20 +840,16 @@
)
)
(defmacro send-event (proc msg &rest params)
(defmacro send-event (proc msg &key (from (with-pp pp)) &rest params)
"Send an event to a process. This should be used over send-event-function"
`(with-pp
(let ((event-data (new 'stack-singleton-no-clear 'event-message-block)))
(set! (-> event-data from) pp)
`(let ((event-data (new 'stack-no-clear 'event-message-block)))
(set! (-> event-data from) ,from)
(set! (-> event-data num-params) ,(length params))
(set! (-> event-data message) ,msg)
,@(let ((ep 0))
(apply (lambda (x) `(set! (-> event-data param ep) (the-as uint ,x)) (inc! ep)) params)
)
,@(apply-i (lambda (x i) `(set! (-> event-data param ,i) (the-as uint ,x))) params)
(send-event-function ,proc event-data)
)
)
)
;; vector-h
+2 -2
View File
@@ -380,8 +380,8 @@
(nav-flags nav-flags :offset-assert 145)
(pad-byte uint8 2 :offset-assert 146)
(pat-ignore-mask pat-surface :offset-assert 148)
(event-self basic :offset-assert 152)
(event-other basic :offset-assert 156)
(event-self symbol :offset-assert 152)
(event-other symbol :offset-assert 156)
(root-prim collide-shape-prim :offset-assert 160)
(riders collide-sticky-rider-group :offset-assert 164)
(backup-collide-as collide-kind :offset-assert 168)
+22 -46
View File
@@ -329,65 +329,41 @@
;; definition for method 12 of type touching-list
;; INFO: Return type mismatch int vs none.
(defmethod send-events-for-touching-shapes touching-list ((obj touching-list))
(let ((gp-0 (the-as object (-> obj touching-shapes))))
(countdown (s5-0 (-> obj num-touching-shapes))
(let ((s4-0 (-> (the-as touching-shapes-entry gp-0) cshape1)))
(when s4-0
(let ((s3-0 (-> (the-as touching-shapes-entry gp-0) cshape2)))
(when (= (-> s3-0 process type) target)
(let ((v1-2 s4-0))
(set! s4-0 s3-0)
(set! s3-0 v1-2)
(let ((entry (the-as touching-shapes-entry (-> obj touching-shapes))))
(countdown (i (-> obj num-touching-shapes))
(let ((c1 (-> entry cshape1)))
(when c1
(let ((c2 (-> entry cshape2)))
(when (= (-> c2 process type) target)
(let ((v1-2 c1))
(set! c1 c2)
(set! c2 v1-2)
)
)
(let ((v1-4 (-> s4-0 event-self)))
(when v1-4
(let ((a1-0 (new 'stack-no-clear 'event-message-block)))
(set! (-> a1-0 from) (-> s3-0 process))
(set! (-> a1-0 num-params) 1)
(set! (-> a1-0 message) (the-as symbol v1-4))
(set! (-> a1-0 param 0) (the-as uint gp-0))
(send-event-function (-> s4-0 process) a1-0)
(let ((v1-4 (-> c1 event-self)))
(if v1-4
(send-event (-> c1 process) v1-4 :from (-> c2 process) entry)
)
)
)
(let ((v1-5 (-> s4-0 event-other)))
(when v1-5
(let ((a1-1 (new 'stack-no-clear 'event-message-block)))
(set! (-> a1-1 from) (-> s4-0 process))
(set! (-> a1-1 num-params) 1)
(set! (-> a1-1 message) (the-as symbol v1-5))
(set! (-> a1-1 param 0) (the-as uint gp-0))
(send-event-function (-> s3-0 process) a1-1)
(let ((v1-5 (-> c1 event-other)))
(if v1-5
(send-event (-> c2 process) v1-5 :from (-> c1 process) entry)
)
)
)
(let ((v1-6 (-> s3-0 event-self)))
(when v1-6
(let ((a1-2 (new 'stack-no-clear 'event-message-block)))
(set! (-> a1-2 from) (-> s4-0 process))
(set! (-> a1-2 num-params) 1)
(set! (-> a1-2 message) (the-as symbol v1-6))
(set! (-> a1-2 param 0) (the-as uint gp-0))
(send-event-function (-> s3-0 process) a1-2)
(let ((v1-6 (-> c2 event-self)))
(if v1-6
(send-event (-> c2 process) v1-6 :from (-> c1 process) entry)
)
)
)
(let ((v1-7 (-> s3-0 event-other)))
(when v1-7
(let ((a1-3 (new 'stack-no-clear 'event-message-block)))
(set! (-> a1-3 from) (-> s3-0 process))
(set! (-> a1-3 num-params) 1)
(set! (-> a1-3 message) (the-as symbol v1-7))
(set! (-> a1-3 param 0) (the-as uint gp-0))
(send-event-function (-> s4-0 process) a1-3)
(let ((v1-7 (-> c2 event-other)))
(if v1-7
(send-event (-> c1 process) v1-7 :from (-> c2 process) entry)
)
)
)
)
)
)
(set! gp-0 (&+ (the-as touching-shapes-entry gp-0) 16))
(set! entry (-> (the-as (inline-array touching-shapes-entry) entry) 1))
)
)
0
+10 -15
View File
@@ -2384,15 +2384,15 @@
)
)
((= (-> v1-1 type) target)
(let ((a1-4 (new 'stack-no-clear 'event-message-block)))
(set! (-> a1-4 from) (the-as process v1-1))
(set! (-> a1-4 num-params) 4)
(set! (-> a1-4 message) (-> self event))
(set! (-> a1-4 param 0) (the-as uint #f))
(set! (-> a1-4 param 1) (the-as uint (-> self event-mode)))
(set! (-> a1-4 param 2) (the-as uint (-> *target* control unknown-dword50)))
(set! (-> a1-4 param 3) (the-as uint (-> *target* control unknown-dword51)))
(send-event-function arg0 a1-4)
(send-event
arg0
(-> self event)
:from
(the-as process v1-1)
#f
(-> self event-mode)
(-> *target* control unknown-dword50)
(-> *target* control unknown-dword51)
)
)
(else
@@ -2413,12 +2413,7 @@
)
)
((-> self event)
(let ((a1-6 (new 'stack-no-clear 'event-message-block)))
(set! (-> a1-6 from) (the-as process v1-1))
(set! (-> a1-6 num-params) 0)
(set! (-> a1-6 message) (-> self event))
(send-event-function arg0 a1-6)
)
(send-event arg0 (-> self event) :from (the-as process v1-1))
)
(else
(let ((t0-5 (new 'stack-no-clear 'event-message-block)))