;;-*-Lisp-*-
(in-package goal)

;; name: prototype.gc
;; name in dgo: prototype
;; dgos: ENGINE, GAME

;; DECOMP BEGINS

(defmethod login ((this prototype-inline-array-shrub))
  (let ((bsp-header (-> *level* level *level-index* bsp)))
    (dotimes (shrub-idx (-> this length))
      (let ((shrub (-> this data shrub-idx)))
        (when (and *debug-segment* (-> *screen-shot-work* highres-enable))
          (dotimes (shrub-i 4)
            (+! (-> shrub dists data shrub-i) 40960000.0)
            (set! (-> shrub rdists data shrub-i) (/ 1.0 (-> shrub dists data shrub-i)))
            )
          )
        (set! *texture-masks* (-> bsp-header shrub-masks data (-> shrub texture-masks-index)))
        (dotimes (geo-i 4)
          (let ((geo (-> shrub geometry geo-i)))
            (if (nonzero? geo)
                (login geo)
                )
            )
          )
        )
      )
    )
  this
  )

(defmethod mem-usage ((this prototype-array-tie) (usage memory-usage-block) (arg2 int))
  (set! (-> usage length) (max 1 (-> usage length)))
  (set! (-> usage data 0 name) (symbol->string 'drawable-group))
  (+! (-> usage data 0 count) 1)
  (let ((size-of-tie (asize-of this)))
    (+! (-> usage data 0 used) size-of-tie)
    (+! (-> usage data 0 total) (logand -16 (+ size-of-tie 15)))
    )
  (dotimes (tie-idx (-> this length))
    (mem-usage (-> this array-data tie-idx) usage arg2)
    )
  this
  )

(defmethod mem-usage ((this prototype-bucket-tie) (usage memory-usage-block) (arg2 int))
  (dotimes (idx 4)
    (let ((tie-geom (-> this tie-geom idx)))
      (if (nonzero? tie-geom)
          (mem-usage tie-geom usage (logior arg2 1))
          )
      )
    )
  (set! (-> usage length) (max 84 (-> usage length)))
  (set! (-> usage data 83 name) "string")
  (+! (-> usage data 83 count) 1)
  (let ((name-size (asize-of (-> this name))))
    (+! (-> usage data 83 used) name-size)
    (+! (-> usage data 83 total) (logand -16 (+ name-size 15)))
    )
  (when (nonzero? (-> this tie-colors))
    (set! (-> usage length) (max 17 (-> usage length)))
    (set! (-> usage data 16 name) "tie-pal")
    (+! (-> usage data 16 count) 1)
    (let ((color-size (asize-of (-> this tie-colors))))
      (+! (-> usage data 16 used) color-size)
      (+! (-> usage data 16 total) (logand -16 (+ color-size 15)))
      )
    )
  (if (nonzero? (-> this collide-hash-fragment-array))
      (mem-usage (-> this collide-hash-fragment-array) usage (logior arg2 1))
      )
  this
  )

(defmethod mem-usage ((this prototype-inline-array-shrub) (usage memory-usage-block) (arg2 int))
  (set! (-> usage length) (max 1 (-> usage length)))
  (set! (-> usage data 0 name) (symbol->string 'drawable-group))
  (+! (-> usage data 0 count) 1)
  (let ((shrub-size (asize-of this)))
    (+! (-> usage data 0 used) shrub-size)
    (+! (-> usage data 0 total) (logand -16 (+ shrub-size 15)))
    )
  (dotimes (idx (-> this length))
    (mem-usage (-> this data idx) usage arg2)
    )
  this
  )

(defmethod mem-usage ((this prototype-bucket-shrub) (usage memory-usage-block) (arg2 int))
  (set! (-> usage length) (max 25 (-> usage length)))
  (set! (-> usage data 24 name) "prototype-bucket-shrub")
  (+! (-> usage data 24 count) 1)
  (let ((proto-shrub-size 112))
    (+! (-> usage data 24 used) proto-shrub-size)
    (+! (-> usage data 24 total) (logand -16 (+ proto-shrub-size 15)))
    )
  (dotimes (idx 4)
    (let ((geo (-> this geometry idx)))
      (if (nonzero? geo)
          (mem-usage geo usage (logior arg2 1))
          )
      )
    )
  (set! (-> usage length) (max 84 (-> usage length)))
  (set! (-> usage data 83 name) "string")
  (+! (-> usage data 83 count) 1)
  (let ((name-size (asize-of (-> this name))))
    (+! (-> usage data 83 used) name-size)
    (+! (-> usage data 83 total) (logand -16 (+ name-size 15)))
    )
  this
  )
