diff --git a/Settings.py b/Settings.py index 1753d9c91d..eb8860224d 100644 --- a/Settings.py +++ b/Settings.py @@ -205,6 +205,12 @@ def update_with_settings_string(self, text: str) -> None: index = 0 for b in range(setting.bitwidth): index |= cur_bits[b] << b + if index >= len(setting.choice_list): + raise ValueError( + f"Settings string is invalid or was generated by a different version " + f"of the randomizer. Setting '{setting.name}' contains index " + f"{index} but only {len(setting.choice_list)} choices are available." + ) value = setting.choice_list[index] elif setting.type == int: value = 0 @@ -225,7 +231,12 @@ def update_with_settings_string(self, text: str) -> None: if index == max_index: value = [item for item in setting.choice_list if item not in value] break - + if index - 1 >= len(setting.choice_list): + raise ValueError( + f"Settings string is invalid or was generated by a different version " + f"of the randomizer. Setting '{setting.name}' contains index " + f"{index} but only {len(setting.choice_list)} choices are available." + ) value.append(setting.choice_list[index-1]) cur_bits = bits[:setting.bitwidth] bits = bits[setting.bitwidth:]