[jak1] Fix speedrun mode bug where loading a save is counted as new run (#3960)

Fixes a small bug introduced in #3902. 

Without this change, whenever you load a save it is treated as if you
started a new game and resets the autosplitter back to 0s.
This commit is contained in:
Matt Dallmeyer
2025-06-19 08:47:42 -07:00
committed by GitHub
parent f5453b96e4
commit 0ab252d39d
2 changed files with 9 additions and 1 deletions
+4
View File
@@ -16,6 +16,7 @@
;; Having two state machines, one in C++ and one in GOAL is kind of a questionable and confusing design.
(define-extern mark-speedrun-started (function none))
;; DECOMP BEGINS
;; version identifier
@@ -607,6 +608,9 @@
(set! save-data
(the-as game-save-tag
(&+ (the-as pointer save-data) (logand -16 (+ (* (the-as int (-> save-data elt-size)) (-> save-data elt-count)) 31)))))))
;; og:preserve-this make sure loading a save doesn't reset speedrun state
(when (and (-> *pc-settings* speedrunner-mode?) (zero? (-> save new-game)))
(mark-speedrun-started))
;; if we're a new game, set our checkpoint.
(when (nonzero? (-> save new-game))
(set-continue! this "game-start")
+5 -1
View File
@@ -385,6 +385,10 @@
(set! (-> *speedrun-info* should-display?) #f)
(none))
(defun mark-speedrun-started ()
(true! (-> *speedrun-info* has-started?))
(none))
(defun speedrun-mode-update ()
"A per frame update for speedrunning related stuff"
(when (-> *pc-settings* speedrunner-mode?)
@@ -397,7 +401,7 @@
;; target has landed on ground/water, or we're about to enter target-hit-ground state
(or (logtest? (-> *target* control status) (cshape-moving-flags onground onsurf on-water))
(= (-> *target* next-state name) 'target-hit-ground)))
(true! (-> *speedrun-info* has-started?))
(mark-speedrun-started)
;; spawn a process that resets autosplitter after suspending for 1 frame
(process-spawn-function process
(lambda ()