Modularize Reset Navi Timer hook (#5872)
* Modularize Reset Navi Timer hook * Remove unnecessary sceneNum param name
This commit is contained in:
17
soh/soh/Enhancements/QoL/ResetNaviTimer.cpp
Normal file
17
soh/soh/Enhancements/QoL/ResetNaviTimer.cpp
Normal 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 });
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user