Skip to content

Commit 4dc93d9

Browse files
committed
Merge 'Improve settings string parse error message' (#2532)
2 parents 7947bba + d775bee commit 4dc93d9

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* Fix a vanilla bug where playing the ocarina with vibrato before recording the Scarecrow's Song could prevent Pierre from spawning.
1919
* Fix unshuffled treasure box shop keys showing the wrong item model while inside the chests if `Key Appearance Matches Dungeon` is enabled.
2020
* Add two missing locations: `Ganons Castle MQ Shadow Trial Explosives Wonderitem` and a `Bombable Fairy` in MQ Jabu.
21+
* Improve the error message when a settings string from the wrong randomizer version is imported.
2122

2223
# 9.0
2324

Settings.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ def update_with_settings_string(self, text: str) -> None:
205205
index = 0
206206
for b in range(setting.bitwidth):
207207
index |= cur_bits[b] << b
208+
if index >= len(setting.choice_list):
209+
raise ValueError(
210+
f"Settings string is invalid or was generated by a different version "
211+
f"of the randomizer. Setting '{setting.name}' contains index "
212+
f"{index} but only {len(setting.choice_list)} choices are available."
213+
)
208214
value = setting.choice_list[index]
209215
elif setting.type == int:
210216
value = 0
@@ -225,7 +231,12 @@ def update_with_settings_string(self, text: str) -> None:
225231
if index == max_index:
226232
value = [item for item in setting.choice_list if item not in value]
227233
break
228-
234+
if index - 1 >= len(setting.choice_list):
235+
raise ValueError(
236+
f"Settings string is invalid or was generated by a different version "
237+
f"of the randomizer. Setting '{setting.name}' contains index "
238+
f"{index} but only {len(setting.choice_list)} choices are available."
239+
)
229240
value.append(setting.choice_list[index-1])
230241
cur_bits = bits[:setting.bitwidth]
231242
bits = bits[setting.bitwidth:]

version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '9.0.19'
1+
__version__ = '9.0.20'
22

33
# This is a supplemental version number for branches based off of main dev.
44
supplementary_version = 0

0 commit comments

Comments
 (0)