Modularize scene-specific Dirt Path fix (#5871)
* Modularize scene-specific Dirt Path fix * Use macro in fix function * Condition hook on fix being enabled * Rename update function
This commit is contained in:
26
soh/soh/Enhancements/Fixes/DirtPathFix.cpp
Normal file
26
soh/soh/Enhancements/Fixes/DirtPathFix.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
|
||||
#include "soh/Enhancements/enhancementTypes.h"
|
||||
#include "soh/Enhancements/mods.h"
|
||||
#include "soh/ShipInit.hpp"
|
||||
|
||||
static constexpr ZFightingFixType CVAR_DIRT_PATH_DEFAULT = ZFIGHT_FIX_DISABLED;
|
||||
#define CVAR_DIRT_PATH_NAME CVAR_ENHANCEMENT("SceneSpecificDirtPathFix")
|
||||
#define CVAR_DIRT_PATH_VALUE CVarGetInteger(CVAR_DIRT_PATH_NAME, CVAR_DIRT_PATH_DEFAULT)
|
||||
|
||||
void DirtPathFix_UpdateZFightingMode(int32_t sceneNum) {
|
||||
switch (sceneNum) {
|
||||
case SCENE_HYRULE_FIELD:
|
||||
case SCENE_KOKIRI_FOREST:
|
||||
case SCENE_HYRULE_CASTLE:
|
||||
CVarSetInteger(CVAR_Z_FIGHTING_MODE, CVAR_DIRT_PATH_VALUE);
|
||||
return;
|
||||
default:
|
||||
CVarClear(CVAR_Z_FIGHTING_MODE);
|
||||
}
|
||||
}
|
||||
|
||||
static void RegisterDirtPathFix() {
|
||||
COND_HOOK(OnTransitionEnd, CVAR_DIRT_PATH_VALUE, DirtPathFix_UpdateZFightingMode);
|
||||
}
|
||||
|
||||
static RegisterShipInitFunc initFunc(RegisterDirtPathFix, { CVAR_DIRT_PATH_NAME });
|
||||
@@ -296,24 +296,6 @@ void UpdateHyperEnemiesState() {
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateDirtPathFixState(int32_t sceneNum) {
|
||||
switch (sceneNum) {
|
||||
case SCENE_HYRULE_FIELD:
|
||||
case SCENE_KOKIRI_FOREST:
|
||||
case SCENE_HYRULE_CASTLE:
|
||||
CVarSetInteger(CVAR_Z_FIGHTING_MODE,
|
||||
CVarGetInteger(CVAR_ENHANCEMENT("SceneSpecificDirtPathFix"), ZFIGHT_FIX_DISABLED));
|
||||
return;
|
||||
default:
|
||||
CVarClear(CVAR_Z_FIGHTING_MODE);
|
||||
}
|
||||
}
|
||||
|
||||
void RegisterMenuPathFix() {
|
||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnTransitionEnd>(
|
||||
[](int32_t sceneNum) { UpdateDirtPathFixState(sceneNum); });
|
||||
}
|
||||
|
||||
void UpdateMirrorModeState(int32_t sceneNum) {
|
||||
static bool prevMirroredWorld = false;
|
||||
bool nextMirroredWorld = false;
|
||||
@@ -890,7 +872,6 @@ void InitMods() {
|
||||
RegisterDeleteFileOnDeath();
|
||||
RegisterHyperBosses();
|
||||
UpdateHyperEnemiesState();
|
||||
RegisterMenuPathFix();
|
||||
RegisterMirrorModeHandler();
|
||||
RegisterResetNaviTimer();
|
||||
RegisterEnemyDefeatCounts();
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void UpdateDirtPathFixState(int32_t sceneNum);
|
||||
void DirtPathFix_UpdateZFightingMode(int32_t sceneNum);
|
||||
void UpdateMirrorModeState(int32_t sceneNum);
|
||||
void UpdateHurtContainerModeState(bool newState);
|
||||
void PatchToTMedallions();
|
||||
|
||||
@@ -1083,7 +1083,7 @@ void SohMenu::AddMenuEnhancements() {
|
||||
.RaceDisable(false)
|
||||
.Callback([](WidgetInfo& info) {
|
||||
if (gPlayState != NULL) {
|
||||
UpdateDirtPathFixState(gPlayState->sceneNum);
|
||||
DirtPathFix_UpdateZFightingMode(gPlayState->sceneNum);
|
||||
}
|
||||
})
|
||||
.Options(
|
||||
|
||||
Reference in New Issue
Block a user