From 4f9ce252e760049a0e17b0b046ffc6ec1ecf09a0 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Thu, 16 Nov 2023 15:48:32 -0500 Subject: [PATCH] Fixes a potential crash with saves made on older commit. I had an Off By One Bug in a previous commit, and saves made on that commit ended up crashing on boot due to attempting to access a negative index of an array. Added a bounds check to prevent attempting to load that data. --- soh/soh/SaveManager.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/soh/soh/SaveManager.cpp b/soh/soh/SaveManager.cpp index a3ce45d29..10e35ae2f 100644 --- a/soh/soh/SaveManager.cpp +++ b/soh/soh/SaveManager.cpp @@ -231,9 +231,11 @@ void SaveManager::LoadRandomizerVersion2() { SaveManager::Instance->LoadStruct("", [&]() { RandomizerCheck rc = RC_UNKNOWN_CHECK; SaveManager::Instance->LoadData("check", rc); - std::string hintText; - SaveManager::Instance->LoadData("hintText", hintText); - randoContext->AddHint(RandomizerHintKey(rc - RC_COLOSSUS_GOSSIP_STONE + 1), Text(hintText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, Text()); + if (rc != RC_UNKNOWN_CHECK) { + std::string hintText; + SaveManager::Instance->LoadData("hintText", hintText); + randoContext->AddHint(RandomizerHintKey(rc - RC_COLOSSUS_GOSSIP_STONE + 1), Text(hintText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, Text()); + } }); });