From 170cbd7e6ca6a68040d2cc250014d9a4bcac3c76 Mon Sep 17 00:00:00 2001 From: ManDude <7569514+ManDude@users.noreply.github.com> Date: Wed, 27 Sep 2023 00:59:07 +0100 Subject: [PATCH] misc low hanging fruit fixes (#3034) Fixes #2235 Fixes #2236 Fixes #2963 Fixes #3027 --- .../opengl_renderer/loader/Loader.cpp | 17 +++++++++----- goal_src/jak1/engine/game/settings.gc | 23 ------------------- goal_src/jak1/engine/ps2/pad.gc | 14 +++++++++++ goal_src/jak1/pc/debug/default-menu-pc.gc | 11 +++++++++ goal_src/jak1/pc/progress-pc.gc | 4 ++-- goalc/compiler/IR.cpp | 2 +- goalc/compiler/compilation/ControlFlow.cpp | 2 +- 7 files changed, 40 insertions(+), 33 deletions(-) diff --git a/game/graphics/opengl_renderer/loader/Loader.cpp b/game/graphics/opengl_renderer/loader/Loader.cpp index 63fa71eb4b5..785a89012b5 100644 --- a/game/graphics/opengl_renderer/loader/Loader.cpp +++ b/game/graphics/opengl_renderer/loader/Loader.cpp @@ -384,12 +384,17 @@ const std::string* Loader::get_most_unloadable_level() { void Loader::update(TexturePool& texture_pool) { Timer loader_timer; - // only main thread can touch this. - for (auto& [name, lev] : m_loaded_tfrag3_levels) { - if (std::find(m_active_levels.begin(), m_active_levels.end(), name) == m_active_levels.end()) { - lev->frames_since_last_used++; - } else { - lev->frames_since_last_used = 0; + { + // lock because we're accessing m_active_levels + std::unique_lock lk(m_loader_mutex); + // only main thread can touch this. + for (auto& [name, lev] : m_loaded_tfrag3_levels) { + if (std::find(m_active_levels.begin(), m_active_levels.end(), name) == + m_active_levels.end()) { + lev->frames_since_last_used++; + } else { + lev->frames_since_last_used = 0; + } } } diff --git a/goal_src/jak1/engine/game/settings.gc b/goal_src/jak1/engine/game/settings.gc index 40f79ef3cc5..a239c2a7ca3 100644 --- a/goal_src/jak1/engine/game/settings.gc +++ b/goal_src/jak1/engine/game/settings.gc @@ -488,26 +488,3 @@ ) ) - -;; og:preserve-this -(#when PC_PORT -;;;;;;;;;;;;;;;;;;;;;; -;; opengoal territory override -;;;;;;;;;;;;;;;;;;;;;; - -(defun scf-get-territory () - "this overrides the kernel version which usually has a hardcoded value." - - (if (not *debug-segment*) - (return *default-territory*)) - (case (-> *setting-control* default language) - (((language-enum japanese)) - GAME_TERRITORY_SCEI) - (((language-enum english)) - GAME_TERRITORY_SCEA) - (else - GAME_TERRITORY_SCEE) - ) - ) - -) \ No newline at end of file diff --git a/goal_src/jak1/engine/ps2/pad.gc b/goal_src/jak1/engine/ps2/pad.gc index b36692ec803..942ef2b99d6 100644 --- a/goal_src/jak1/engine/ps2/pad.gc +++ b/goal_src/jak1/engine/ps2/pad.gc @@ -14,6 +14,20 @@ (define-extern get-current-time (function time-frame)) (define-extern get-integral-current-time (function time-frame)) +(#when PC_PORT +;;;;;;;;;;;;;;;;;;;;;; +;; opengoal territory override +;;;;;;;;;;;;;;;;;;;;;; + +(define *debug-territory* GAME_TERRITORY_SCEA) +(defun scf-get-territory () + "redefined from C kernel for convenience" + (if *debug-segment* + *debug-territory* + *default-territory*) + ) +) + ;; DECOMP BEGINS (defenum pad-buttons diff --git a/goal_src/jak1/pc/debug/default-menu-pc.gc b/goal_src/jak1/pc/debug/default-menu-pc.gc index d2fb2d3dc72..db283608b5b 100644 --- a/goal_src/jak1/pc/debug/default-menu-pc.gc +++ b/goal_src/jak1/pc/debug/default-menu-pc.gc @@ -625,6 +625,12 @@ (set! (-> *pc-settings* gfx-msaa) msaa)) (= (-> *pc-settings* gfx-msaa) msaa))) +(defun dm-territory-pick-func ((bterr int) (msg debug-menu-msg)) + (let ((terr (/ bterr 8))) + (when (= msg (debug-menu-msg press)) + (set! *debug-territory* terr)) + (= *debug-territory* terr))) + (defun dm-pc-cheats-pick-func ((bcheat int) (msg debug-menu-msg)) (let ((cheat (the pc-cheats (/ bcheat 8)))) (when (= msg (debug-menu-msg press)) @@ -818,6 +824,11 @@ (flag "eco" #f ,(dm-lambda-boolean-flag (-> *pc-settings* controller-eco-led?))) (flag "heat" #f ,(dm-lambda-boolean-flag (-> *pc-settings* controller-heat-led?))) ) + (menu "Territory" + (flag "GAME_TERRITORY_SCEA" (the binteger GAME_TERRITORY_SCEA) dm-territory-pick-func) + (flag "GAME_TERRITORY_SCEE" (the binteger GAME_TERRITORY_SCEE) dm-territory-pick-func) + (flag "GAME_TERRITORY_SCEI" (the binteger GAME_TERRITORY_SCEI) dm-territory-pick-func) + ) (flag "V-sync" #f ,(dm-lambda-boolean-flag (-> *pc-settings* vsync?))) (flag "PS2 Actor vis" #f ,(dm-lambda-boolean-flag (-> *pc-settings* ps2-actor-vis?))) (flag "Display actor counts" *display-actor-counts* dm-boolean-toggle-pick-func) diff --git a/goal_src/jak1/pc/progress-pc.gc b/goal_src/jak1/pc/progress-pc.gc index f079a885bc9..0ff65fd135f 100644 --- a/goal_src/jak1/pc/progress-pc.gc +++ b/goal_src/jak1/pc/progress-pc.gc @@ -379,7 +379,7 @@ (define *secrets* (new 'static 'boxed-array :type game-option (new 'static 'game-option :option-type (game-option-type menu) :name (text-id cheats) :scale #t :param3 (game-option-menu cheats)) (new 'static 'game-option :option-type (game-option-type menu) :name (text-id checkpoint-select) :scale #t :param3 (game-option-menu checkpoint-select) - :option-disabled-func (lambda () (not (task-closed? (game-task finalboss-movies) (task-status need-reminder))))) + :option-disabled-func (lambda () (not (>= (calculate-completion (the progress #f)) 100.0)))) (new 'static 'game-option :option-type (game-option-type button) :name (text-id back) :scale #t) ) ) @@ -1387,7 +1387,7 @@ (when (and (nonzero? (-> options (-> obj option-index) option-disabled-func)) (!= (-> options (-> obj option-index) option-disabled-func) #f) ((-> options (-> obj option-index) option-disabled-func))) - (sound-play "menu-stats") + (sound-play "cursor-options") (return #f)) (cond ((not (-> obj selected-option)) diff --git a/goalc/compiler/IR.cpp b/goalc/compiler/IR.cpp index 624acf98e09..37d81a340ad 100644 --- a/goalc/compiler/IR.cpp +++ b/goalc/compiler/IR.cpp @@ -423,7 +423,7 @@ RegAllocInstr IR_FunctionCall::to_rai() { } for (int i = 0; i < emitter::RegisterInfo::N_REGS; i++) { - auto info = emitter::gRegInfo.get_info(i); + auto& info = emitter::gRegInfo.get_info(i); if (info.temp()) { rai.clobber.emplace_back(i); } diff --git a/goalc/compiler/compilation/ControlFlow.cpp b/goalc/compiler/compilation/ControlFlow.cpp index 08ab604408f..c750662bbee 100644 --- a/goalc/compiler/compilation/ControlFlow.cpp +++ b/goalc/compiler/compilation/ControlFlow.cpp @@ -198,7 +198,7 @@ Val* Compiler::compile_cond(const goos::Object& form, const goos::Object& rest, throw_compiler_error(form, "Cond from cannot have any cases after else."); } - if (test.is_symbol() && symbol_string(test) == "else") { + if (test.is_symbol("else")) { got_else = true; }