Modularize Reset Navi Timer hook (#5872)

* Modularize Reset Navi Timer hook

* Remove unnecessary sceneNum param name
This commit is contained in:
Jordan Longstaff
2025-10-25 16:25:50 -04:00
committed by GitHub
parent c4f9712eff
commit 248fe8cb13
2 changed files with 17 additions and 9 deletions

View File

@@ -0,0 +1,17 @@
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
#include "soh/ShipInit.hpp"
extern "C" {
#include "variables.h"
extern SaveContext gSaveContext;
}
static constexpr int32_t CVAR_RESET_NAVI_DEFAULT = 0;
#define CVAR_RESET_NAVI_NAME CVAR_ENHANCEMENT("ResetNaviTimer")
#define CVAR_RESET_NAVI_VALUE CVarGetInteger(CVAR_RESET_NAVI_NAME, CVAR_RESET_NAVI_DEFAULT)
static void RegisterResetNaviTimer() {
COND_HOOK(OnSceneInit, CVAR_RESET_NAVI_VALUE, [](int32_t) { gSaveContext.naviTimer = 0; });
}
static RegisterShipInitFunc initFunc(RegisterResetNaviTimer, { CVAR_RESET_NAVI_NAME });

View File

@@ -409,14 +409,6 @@ void RegisterPatchHandHandler() {
[](int32_t sceneNum) { UpdatePatchHand(); });
}
void RegisterResetNaviTimer() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnSceneInit>([](int32_t sceneNum) {
if (CVarGetInteger(CVAR_ENHANCEMENT("ResetNaviTimer"), 0)) {
gSaveContext.naviTimer = 0;
}
});
}
// this map is used for enemies that can be uniquely identified by their id
// and that are always counted
// enemies that can't be uniquely identified by their id
@@ -873,7 +865,6 @@ void InitMods() {
RegisterHyperBosses();
UpdateHyperEnemiesState();
RegisterMirrorModeHandler();
RegisterResetNaviTimer();
RegisterEnemyDefeatCounts();
RegisterBossDefeatTimestamps();
RegisterRandomizedEnemySizes();