clamp settings (#6786)

avoids segfaulting if options changed between versions
This commit is contained in:
Philip Dubé
2026-06-21 20:45:22 +00:00
committed by GitHub
parent 5926476496
commit e4b6f1ab87
+7 -1
View File
@@ -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<int32_t>(maxIndex));
if (this->GetOptionIndex() > maxIndex) {
CVarSetInteger(cvarName.c_str(), static_cast<int32_t>(maxIndex));
}
sliderOpts->Format(this->GetOptionText(this->GetOptionIndex()).c_str());
}
})
.CVar(cvarName.c_str())