mirror of
https://github.com/open-goal/jak-project
synced 2026-07-31 00:14:38 -04:00
d1ece445d4
Relates to #1353 This adds no new functionality or overhead to the compiler, yet. This is the preliminary work that has: - added code to the compiler in several spots to flag when something is used without being properly required/imported/whatever (disabled by default) - that was used to generate project wide file dependencies (some circulars were manually fixed) - then that graph underwent a transitive reduction and the result was written to all `jak1` source files. The next step will be making this actually produce and use a dependency graph. Some of the reasons why I'm working on this: - eliminates more `game.gp` boilerplate. This includes the `.gd` files to some extent (`*-ag` files and `tpage` files will still need to be handled) this is the point of the new `bundles` form. This should make it even easier to add a new file into the source tree. - a build order that is actually informed from something real and compiler warnings that tell you when you are using something that won't be available at build time. - narrows the search space for doing LSP actions -- like searching for references. Since it would be way too much work to store in the compiler every location where every symbol/function/etc is used, I have to do ad-hoc searches. By having a dependency graph i can significantly reduce that search space. - opens the doors for common shared code with a legitimate pattern. Right now jak 2 shares code from the jak 1 folder. This is basically a hack -- but by having an explicit require syntax, it would be possible to reference arbitrary file paths, such as a `common` folder. Some stats: - Jak 1 has about 2500 edges between files, including transitives - With transitives reduced at the source code level, each file seems to have a modest amount of explicit requirements. Known issues: - Tracking the location for where `defmacro`s and virtual state definitions were defined (and therefore the file) is still problematic. Because those forms are in a macro environment, the reader does not track them. I'm wondering if a workaround could be to search the reader's text_db by not just the `goos::Object` but by the text position. But for the purposes of finishing this work, I just statically analyzed and searched the code with throwaway python code.
180 lines
5.2 KiB
Common Lisp
180 lines
5.2 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
(bundles "ENGINE.CGO" "GAME.CGO")
|
|
|
|
(require "engine/game/game-h.gc")
|
|
|
|
;; name: task-control-h.gc
|
|
;; name in dgo: task-control-h
|
|
;; dgos: GAME, ENGINE
|
|
|
|
;; for process-taskable
|
|
(declare-type process-taskable process-drawable)
|
|
(define-extern othercam-init-by-other (function process-taskable symbol symbol symbol none :behavior othercam))
|
|
|
|
;; There are a fixed number of game tasks. Most are just getting a power cell,
|
|
;; but there are also ones for using the levitator etc.
|
|
|
|
;; The list of all tasks is the game-task enum in game-info-h.gc
|
|
|
|
;; the task control contains a list of all cstage.
|
|
;; Each task may have multiple cstages.
|
|
;; Each cstage corresponds to a game-task and a task-status.
|
|
|
|
;; There is a concept of a "current stage" being played, but it may sometimes be invalid (-1).
|
|
;; it is an index into the task-control list
|
|
|
|
;; names from task-status->string function
|
|
;; the status value will increase.
|
|
;; some tasks may do their own thing and not use these values.
|
|
(defenum task-status
|
|
:type uint64
|
|
(invalid 0)
|
|
(unknown 1)
|
|
(need-hint 2)
|
|
(need-introduction 3)
|
|
(need-reminder-a 4)
|
|
(need-reminder 5)
|
|
(need-reward-speech 6)
|
|
(need-resolution 7)
|
|
)
|
|
|
|
;; our names
|
|
(defenum task-flags
|
|
:type uint8
|
|
:bitfield #t
|
|
(closed 0)
|
|
(has-entity 1)
|
|
(closed-by-default 2)
|
|
)
|
|
|
|
(declare-type task-control basic)
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
(deftype task-cstage (structure)
|
|
((game-task game-task)
|
|
(status task-status)
|
|
(flags task-flags)
|
|
(condition (function task-control symbol))
|
|
)
|
|
(:methods
|
|
(get-task (_type_) game-task)
|
|
(get-status (_type_) task-status)
|
|
(task-available? (_type_ task-control) symbol)
|
|
(closed? (_type_) symbol)
|
|
(closed-by-default? (_type_) symbol)
|
|
(close-task! (_type_) int)
|
|
(open-task! (_type_) int)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype task-control (basic)
|
|
((current-stage int16)
|
|
(stage (array task-cstage))
|
|
)
|
|
(:methods
|
|
(current-task (_type_) game-task)
|
|
(current-status (_type_) task-status)
|
|
(close-current! (_type_) game-task)
|
|
(close-status! (_type_ task-status) game-task)
|
|
(first-any (_type_ symbol) game-task)
|
|
(reset! (_type_ symbol symbol) int)
|
|
(closed? (_type_ game-task task-status) symbol)
|
|
(get-reminder (_type_ int) int)
|
|
(save-reminder (_type_ int int) int)
|
|
(exists? (_type_ game-task task-status) symbol)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype ambient-control (structure)
|
|
((last-ambient-time time-frame)
|
|
(last-ambient string)
|
|
(last-ambient-id sound-id)
|
|
)
|
|
:pack-me
|
|
(:methods
|
|
(ambient-control-method-9 (_type_) none)
|
|
(ambient-control-method-10 (_type_ vector time-frame float process-drawable) vector)
|
|
(play-ambient (_type_ string symbol vector) symbol)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype process-taskable (process-drawable)
|
|
((root collide-shape :override)
|
|
(tasks task-control)
|
|
(query gui-query :inline)
|
|
(old-target-pos transformq :inline)
|
|
(cell-for-task game-task)
|
|
(cell-x handle)
|
|
(cam-joint-index int32)
|
|
(skippable symbol)
|
|
(blend-on-exit art-joint-anim)
|
|
(camera handle)
|
|
(will-talk symbol)
|
|
(talk-message text-id)
|
|
(last-talk time-frame)
|
|
(bounce-away symbol)
|
|
(ambient ambient-control :inline)
|
|
(center-joint-index int32)
|
|
(draw-bounds-y-offset float)
|
|
(neck-joint-index int32)
|
|
(fuel-cell-anim spool-anim)
|
|
(sound-flava music-flava)
|
|
(have-flava symbol)
|
|
(music symbol)
|
|
(have-music symbol)
|
|
(been-kicked symbol)
|
|
(cur-trans-hook (function none))
|
|
(shadow-backup shadow-geo)
|
|
)
|
|
(:state-methods
|
|
release
|
|
give-cell
|
|
lose
|
|
enter-playing
|
|
play-accept
|
|
play-reject
|
|
query
|
|
play-anim
|
|
hidden
|
|
(be-clone handle)
|
|
idle
|
|
)
|
|
(:methods
|
|
(get-art-elem (_type_) art-element)
|
|
(play-anim! (_type_ symbol) basic)
|
|
(process-taskable-method-33 (_type_) none)
|
|
(get-accept-anim (_type_ symbol) spool-anim)
|
|
(push-accept-anim (_type_) none)
|
|
(get-reject-anim (_type_ symbol) spool-anim)
|
|
(push-reject-anim (_type_) none)
|
|
(process-taskable-method-38 (_type_) none)
|
|
(should-display? (_type_) symbol)
|
|
(process-taskable-method-40 (_type_ object skeleton-group int int vector int) none)
|
|
(initialize-collision (_type_ int vector) none)
|
|
(process-taskable-method-42 (_type_) none)
|
|
(process-taskable-method-43 (_type_) symbol)
|
|
(play-reminder (_type_) symbol)
|
|
(process-taskable-method-45 (_type_) symbol)
|
|
(process-taskable-method-46 (_type_) none)
|
|
(target-above-threshold? (_type_) symbol)
|
|
(draw-npc-shadow (_type_) none)
|
|
(hidden-other () _type_ :state)
|
|
(process-taskable-method-50 (_type_) symbol)
|
|
(close-anim-file! (_type_) symbol)
|
|
(process-taskable-method-52 (_type_) none)
|
|
)
|
|
)
|
|
|
|
(defun-extern task-known? game-task symbol)
|
|
(defun-extern task-control-reset symbol none)
|
|
|
|
(define-extern task-closed? (function game-task task-status symbol))
|
|
(define-extern get-task-status (function game-task task-status))
|
|
(define-extern get-task-control (function game-task task-control))
|
|
(define-extern close-specific-task! (function game-task task-status game-task))
|