Skip to content

Commit

Permalink
Avoid unit8 overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Zedb0T committed Jan 30, 2025
1 parent 22592e0 commit 9208c5c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion decompiler/config/jak1/all-types.gc
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@
(sidekick-hint-rounddoor #x23c)
(sidekick-hint-lurkerm #x23d)
(sidekick-hint-tower #x23e)

(sidekick-reminder-fish #x240)

(firecanyon-need-cells #x24f)
Expand Down
18 changes: 14 additions & 4 deletions goal_src/jak1/engine/game/game-info.gc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
;; The "perm" data is saved to the memory card.

;; orb count for purposes of the shop
;;(-> *game-info* money-per-level 25)
;;(get-spendable-orbs)

(defconstant NUM_UNLOCKS 7)

Expand Down Expand Up @@ -67,16 +67,27 @@
(defun get-shop-price ((item microtransaction-item))
(if (-> *pc-settings* shop-hard?) (-> item hard-price) (-> item price)))

(defun get-spendable-orbs ()
(let* ((spent-orbs 0)
(total-orbs (-> *game-info* money-total)))
(dotimes (i (-> *microtransaction-info* num-items))
(let* ((item (-> *microtransaction-info* items i))
(task (-> item task))
(price (get-shop-price item))
(task-status-value (task-status need-hint))
(task-closed (task-closed? task task-status-value)))
(if task-closed (begin (set! spent-orbs (+ spent-orbs price))))))
(let ((remaining (- total-orbs spent-orbs))) (the int remaining))))

(defun buy ((item microtransaction-item))
"purchase the item"
(cond
((task-closed? (-> item task) (task-status need-hint))
;; already purchased
(sound-play "cursor-options"))
((>= (-> *game-info* money-per-level 25) (get-shop-price item))
((>= (get-spendable-orbs) (get-shop-price item))
;; have the orbs
(sound-play "money-pickup")
(-! (-> *game-info* money-per-level 25) (get-shop-price item))
(close-specific-task! (-> item task) (task-status need-hint)))
(else
;; you broke MFer
Expand Down Expand Up @@ -356,7 +367,6 @@
;; if we have all the money in our level, display the all orbs graphic
(if (= (-> this money-per-level level-idx) (-> (get-game-count level-idx) money-count)) (activate-orb-all level-idx)))))))
;; increment our current money count
(+! (-> *game-info* money-per-level 25) amount)
(+! (-> this money) amount))
(('fuel-cell)
;; got a power cell!
Expand Down
2 changes: 1 addition & 1 deletion goal_src/jak1/engine/ui/progress/progress-draw.gc
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@
(let* ((s3-0 (-> *display* frames (-> *display* on-screen) frame global-buf))
(s4-0 (-> s3-0 base)))
(let ((s2-0 draw-string-xy))
(format (clear *temp-string*) "~D" (-> *game-info* money-per-level 25))
(format (clear *temp-string*) "~D" (get-spendable-orbs))
(s2-0 *temp-string*
s3-0
(the int (+ 428.0 (the float s5-0) f30-0))
Expand Down

0 comments on commit 9208c5c

Please sign in to comment.