mirror of
https://github.com/open-goal/jak-project
synced 2026-08-06 09:54:10 -04:00
fe491c2b5e
Previously, `object` and `none` were both top-level types. This made decompilation rather messy as they have no LCA and resulted in a lot of variables coming out as type `none` which is very very wrong and additionally there were plenty of casts to `object`. This changes it so `none` becomes a child of `object` (it is still represented by `NullType` which remains unusable in compilation). This change makes `object` the sole top-level type, and the type that can represent *any* GOAL object. I believe this matches the original GOAL built-in type structure. A function that has a return type of `object` can now return an integer or a `none` at the same time. However, keep in mind that the return value of `(none)` is still undefined, just as before. This also makes a cast to `object` meaningless in 90% of the situations it showed up in (as every single thing is already an `object`) and the decompiler will no longer emit them. Casts to `none` are also reduced. Yay! Additionally, state handlers also don't get the final `(none)` printed out anymore. The return type of a state handler is completely meaningless outside the event handler (which is return type `object` anyway) so there are no limitations on what the last form needs to be. I did this instead of making them return `object` to trick the decompiler into not trying to output a variable to be used as a return value (internally, in the decompiler they still have return type `none`, but they have `object` elsewhere). Fixes #1703 Fixes #830 Fixes #928
76 lines
2.1 KiB
Common Lisp
Vendored
Generated
76 lines
2.1 KiB
Common Lisp
Vendored
Generated
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; definition of type simple-focus
|
|
(deftype simple-focus (process-focusable)
|
|
((first-time? symbol :offset-assert 204)
|
|
)
|
|
:heap-base #x50
|
|
:method-count-assert 28
|
|
:size-assert #xd0
|
|
:flag-assert #x1c005000d0
|
|
(:methods
|
|
(idle () _type_ :state 27)
|
|
)
|
|
)
|
|
|
|
;; definition for method 3 of type simple-focus
|
|
(defmethod inspect simple-focus ((obj simple-focus))
|
|
(when (not obj)
|
|
(set! obj obj)
|
|
(goto cfg-4)
|
|
)
|
|
(let ((t9-0 (method-of-type process-focusable inspect)))
|
|
(t9-0 obj)
|
|
)
|
|
(format #t "~2Tfirst-time?: ~A~%" (-> obj first-time?))
|
|
(label cfg-4)
|
|
obj
|
|
)
|
|
|
|
;; definition for method 20 of type simple-focus
|
|
(defmethod get-trans simple-focus ((obj simple-focus) (arg0 int))
|
|
"@returns the `trans` [[vector]] from the process's `root` (typically either a [[trsqv]] or a [[collide-shape]])"
|
|
(-> obj root trans)
|
|
)
|
|
|
|
;; definition for method 12 of type simple-focus
|
|
(defmethod run-logic? simple-focus ((obj simple-focus))
|
|
(when (-> obj first-time?)
|
|
(set! (-> obj first-time?) #f)
|
|
#t
|
|
)
|
|
)
|
|
|
|
;; failed to figure out what this is:
|
|
(defstate idle (simple-focus)
|
|
:virtual #t
|
|
:event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
|
|
(case message
|
|
(('move-trans)
|
|
(let ((v0-0 (-> self root trans)))
|
|
(set! (-> v0-0 quad) (-> (the-as vector (-> block param 0)) quad))
|
|
v0-0
|
|
)
|
|
)
|
|
)
|
|
)
|
|
:code (the-as (function none :behavior simple-focus) sleep-code)
|
|
)
|
|
|
|
;; definition for function simple-focus-init-by-other
|
|
;; WARN: Return type mismatch object vs none.
|
|
(defbehavior simple-focus-init-by-other simple-focus ()
|
|
"Initializes the new [[simple-focus]]. `first-time?` will be set to [[#t]]"
|
|
(let ((root (new 'process 'trsqv)))
|
|
(set! (-> self root) (the-as collide-shape root))
|
|
(vector-identity! (-> root scale))
|
|
(quaternion-identity! (-> root quat))
|
|
)
|
|
(logclear! (-> self mask) (process-mask enemy))
|
|
(set! (-> self first-time?) #t)
|
|
(set! (-> self event-hook) (-> (method-of-object self idle) event))
|
|
(go-virtual idle)
|
|
(none)
|
|
)
|