From 807b00a058be1d9b9f19e1b787e93c6dba5803d1 Mon Sep 17 00:00:00 2001 From: Pepe20129 <72659707+Pepe20129@users.noreply.github.com> Date: Fri, 29 Dec 2023 19:36:56 +0100 Subject: [PATCH] Fix crashing when creating a new file (#3764) --- soh/soh/Enhancements/mods.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/soh/soh/Enhancements/mods.cpp b/soh/soh/Enhancements/mods.cpp index 275057bcf..329a8ee48 100644 --- a/soh/soh/Enhancements/mods.cpp +++ b/soh/soh/Enhancements/mods.cpp @@ -1208,18 +1208,15 @@ void PatchToTMedallions() { } } -void RegisterToTMedallionsFromItem() { - GameInteractor::Instance->RegisterGameHook([](GetItemEntry _unused) { - if (!CVarGetInteger("gToTMedallionsColors", 0) && gPlayState->sceneNum != SCENE_TEMPLE_OF_TIME) { +void RegisterToTMedallions() { + GameInteractor::Instance->RegisterGameHook([](GetItemEntry _unused) { + if (!CVarGetInteger("gToTMedallionsColors", 0) || !gPlayState || gPlayState->sceneNum != SCENE_TEMPLE_OF_TIME) { return; } PatchToTMedallions(); }); -} - -void RegisterToTMedallionsFromScene() { - GameInteractor::Instance->RegisterGameHook([](int16_t sceneNum) { - if (!CVarGetInteger("gToTMedallionsColors", 0) && gPlayState->sceneNum != SCENE_TEMPLE_OF_TIME) { + GameInteractor::Instance->RegisterGameHook([](int16_t sceneNum) { + if (!CVarGetInteger("gToTMedallionsColors", 0) || sceneNum != SCENE_TEMPLE_OF_TIME) { return; } PatchToTMedallions(); @@ -1257,7 +1254,6 @@ void InitMods() { RegisterAltTrapTypes(); RegisterRandomizerSheikSpawn(); RegisterRandomizedEnemySizes(); - RegisterToTMedallionsFromItem(); - RegisterToTMedallionsFromScene(); + RegisterToTMedallions(); NameTag_RegisterHooks(); }