mirror of
https://github.com/open-goal/jak-project
synced 2026-07-30 16:04:33 -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.
181 lines
4.9 KiB
Common Lisp
181 lines
4.9 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
(bundles "ENGINE.CGO" "GAME.CGO")
|
|
|
|
(require "engine/entity/res-h.gc")
|
|
(require "kernel/gcommon.gc")
|
|
(require "engine/util/types-h.gc")
|
|
|
|
;; name: entity-h.gc
|
|
;; name in dgo: entity-h
|
|
;; dgos: GAME, ENGINE
|
|
|
|
(defun-extern entity-by-name string entity)
|
|
(defun-extern entity-by-type type entity-actor)
|
|
(defun-extern entity-by-aid uint entity)
|
|
(define-extern reset-actors (function symbol none))
|
|
(define-extern *spawn-actors* symbol)
|
|
;; TODO - for cam-start
|
|
(define-extern reset-cameras (function none))
|
|
(define-extern process-by-ename (function string process))
|
|
(define-extern entity-birth-no-kill (function entity none))
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
(define *generate-actor-vis* #f)
|
|
|
|
(define *generate-actor-vis-start* #f)
|
|
|
|
(define *generate-actor-vis-output* #f)
|
|
|
|
(deftype entity-perm (structure)
|
|
((user-object object 2)
|
|
(user-uint64 uint64 :overlay-at (-> user-object 0))
|
|
(user-float float 2 :overlay-at (-> user-object 0))
|
|
(user-int32 int32 2 :overlay-at (-> user-object 0))
|
|
(user-uint32 uint32 2 :overlay-at (-> user-object 0))
|
|
(user-int16 int16 4 :overlay-at (-> user-object 0))
|
|
(user-uint16 uint16 4 :overlay-at (-> user-object 0))
|
|
(user-int8 int8 8 :overlay-at (-> user-object 0))
|
|
(user-uint8 uint8 8 :overlay-at (-> user-object 0))
|
|
(status entity-perm-status)
|
|
(dummy uint8 1)
|
|
(task game-task)
|
|
(aid actor-id)
|
|
(quad uint128 :overlay-at (-> user-object 0))
|
|
)
|
|
:pack-me
|
|
(:methods
|
|
(update-perm! (_type_ symbol entity-perm-status) _type_)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype entity-links (structure)
|
|
((prev-link entity-links)
|
|
(next-link entity-links)
|
|
(entity entity)
|
|
(process process)
|
|
(level level)
|
|
(vis-id int32)
|
|
(trans vector :inline)
|
|
(perm entity-perm :inline)
|
|
(status uint16 :overlay-at (-> perm status))
|
|
(aid actor-id :overlay-at (-> perm aid))
|
|
(task game-task :overlay-at (-> perm task))
|
|
)
|
|
(:methods
|
|
(birth? (_type_ vector) symbol)
|
|
)
|
|
)
|
|
|
|
|
|
(deftype entity-perm-array (inline-array-class)
|
|
((data entity-perm :inline :dynamic)
|
|
)
|
|
)
|
|
|
|
|
|
(set! (-> entity-perm-array heap-base) (the-as uint 16))
|
|
|
|
(deftype entity-links-array (inline-array-class)
|
|
((data entity-links :inline :dynamic)
|
|
)
|
|
)
|
|
|
|
|
|
(set! (-> entity-links-array heap-base) (the-as uint 64))
|
|
|
|
(deftype entity (res-lump)
|
|
((trans vector :inline)
|
|
(aid uint32)
|
|
)
|
|
(:methods
|
|
(birth! (_type_) _type_)
|
|
(kill! (_type_) _type_)
|
|
(add-to-level! (_type_ level-group level actor-id) none)
|
|
(remove-from-level! (_type_ level-group) _type_)
|
|
(get-level (_type_) level)
|
|
)
|
|
)
|
|
|
|
(deftype entity-camera (entity)
|
|
((connect connectable :inline)
|
|
)
|
|
)
|
|
|
|
(deftype entity-ambient-data (structure)
|
|
((user-object object 3)
|
|
(function (function drawable-ambient vector none))
|
|
(quad uint128 :overlay-at (-> user-object 0))
|
|
(user-uint64 uint64 1 :overlay-at (-> user-object 0))
|
|
(user-float float 3 :overlay-at (-> user-object 0))
|
|
(user-int32 int32 3 :overlay-at (-> user-object 0))
|
|
(user-uint32 uint32 3 :overlay-at (-> user-object 0))
|
|
(user-int16 int16 6 :overlay-at (-> user-object 0))
|
|
(user-uint16 uint16 6 :overlay-at (-> user-object 0))
|
|
(user-int8 int8 12 :overlay-at (-> user-object 0))
|
|
(user-uint8 uint8 12 :overlay-at (-> user-object 0))
|
|
)
|
|
)
|
|
|
|
|
|
(deftype entity-ambient-data-array (inline-array-class)
|
|
((data entity-ambient-data :inline :dynamic)
|
|
)
|
|
)
|
|
|
|
|
|
(set! (-> entity-ambient-data-array heap-base) (the-as uint 16))
|
|
|
|
(deftype entity-ambient (entity)
|
|
((ambient-data entity-ambient-data :overlay-at extra)
|
|
)
|
|
(:methods
|
|
(draw-debug (_type_) none)
|
|
(birth-ambient! (_type_) none)
|
|
)
|
|
)
|
|
|
|
(deftype entity-actor (entity)
|
|
((nav-mesh nav-mesh)
|
|
(etype type)
|
|
(task game-task)
|
|
(vis-id uint16)
|
|
(vis-id-signed int16 :overlay-at vis-id)
|
|
(quat quaternion :inline)
|
|
)
|
|
(:methods
|
|
(next-actor (_type_) entity-actor)
|
|
(prev-actor (_type_) entity-actor)
|
|
(debug-print (_type_ symbol type) none)
|
|
(set-or-clear-status! (_type_ entity-perm-status symbol) none)
|
|
)
|
|
)
|
|
|
|
(deftype entity-info (basic)
|
|
((ptype type)
|
|
(package basic)
|
|
(art-group pair)
|
|
(pool basic)
|
|
(heap-size int32)
|
|
)
|
|
)
|
|
|
|
;; NOTE - this is a strange pattern...this symbol isn't defined until a later file 'navigate'
|
|
;; But this seems to be setting the symbol to nothing if it's not found, but of course, our compiler freaks out
|
|
(define-extern entity-nav-login (function entity-actor none))
|
|
(if (zero? entity-nav-login)
|
|
(set! entity-nav-login (the-as (function entity-actor none) nothing))
|
|
)
|
|
|
|
(deftype actor-bank (basic)
|
|
((pause-dist float)
|
|
(birth-dist float)
|
|
(birth-max int32)
|
|
)
|
|
)
|
|
|
|
|
|
(define *ACTOR-bank* (new 'static 'actor-bank :pause-dist (meters 50) :birth-dist (meters 220) :birth-max 10))
|