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.
This commit is contained in:
Christopher Leggett 2023-11-16 15:48:32 -05:00
parent 2698d453bb
commit 4f9ce252e7
No known key found for this signature in database
GPG Key ID: 7093AE5FF7037D79

View File

@ -231,9 +231,11 @@ void SaveManager::LoadRandomizerVersion2() {
SaveManager::Instance->LoadStruct("", [&]() { SaveManager::Instance->LoadStruct("", [&]() {
RandomizerCheck rc = RC_UNKNOWN_CHECK; RandomizerCheck rc = RC_UNKNOWN_CHECK;
SaveManager::Instance->LoadData("check", rc); SaveManager::Instance->LoadData("check", rc);
if (rc != RC_UNKNOWN_CHECK) {
std::string hintText; std::string hintText;
SaveManager::Instance->LoadData("hintText", hintText); SaveManager::Instance->LoadData("hintText", hintText);
randoContext->AddHint(RandomizerHintKey(rc - RC_COLOSSUS_GOSSIP_STONE + 1), Text(hintText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, Text()); randoContext->AddHint(RandomizerHintKey(rc - RC_COLOSSUS_GOSSIP_STONE + 1), Text(hintText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, Text());
}
}); });
}); });