diff --git a/soh/soh/Enhancements/randomizer/option.cpp b/soh/soh/Enhancements/randomizer/option.cpp index 3a712b5e6b..17e8a8cbaf 100644 --- a/soh/soh/Enhancements/randomizer/option.cpp +++ b/soh/soh/Enhancements/randomizer/option.cpp @@ -99,6 +99,9 @@ uint8_t Option::GetMenuOptionDefault() const { } const std::string& Option::GetOptionText(size_t index) const { + if (index >= options.size()) { + index = options.size() - 1; + } return options[index]; } @@ -229,7 +232,6 @@ void Option::AddWidget(WidgetPath& path) { if (info.type == WIDGET_CVAR_SLIDER_INT) { UIWidgets::IntSliderOptions* sliderOpts = (UIWidgets::IntSliderOptions*)info.options.get(); - sliderOpts->Format(this->GetOptionText(this->GetOptionIndex()).c_str()); size_t maxIndex = this->options.size() - 1; if (this->GetKey() == RSK_SHOPSANITY_COUNT && maxIndex > 7 && CVarGetInteger(CVAR_RANDOMIZER_SETTING("LogicRules"), RO_LOGIC_GLITCHLESS) != @@ -237,6 +239,10 @@ void Option::AddWidget(WidgetPath& path) { maxIndex = 7; } sliderOpts->Max(static_cast(maxIndex)); + if (this->GetOptionIndex() > maxIndex) { + CVarSetInteger(cvarName.c_str(), static_cast(maxIndex)); + } + sliderOpts->Format(this->GetOptionText(this->GetOptionIndex()).c_str()); } }) .CVar(cvarName.c_str())