Protect against out of bounds for minigame index

This commit is contained in:
Adrien Ufferte
2026-06-06 18:11:45 +02:00
parent fe696c8b20
commit fcd84fdb35
+7
View File
@@ -784,6 +784,13 @@ func _build_wheel(exercises: Array[int], lesson_unlocks: Dictionary) -> void:
var layout: Dictionary = _get_wedge_layout(minigame_count, wedge_index) var layout: Dictionary = _get_wedge_layout(minigame_count, wedge_index)
var exercise_type: int = exercises[wedge_index] var exercise_type: int = exercises[wedge_index]
var icon_index: int = exercise_type - 1 var icon_index: int = exercise_type - 1
# Guard against exercise types with no matching wheel icon (e.g. the
# removed fish minigame, type 10): fall back to the highest available one
# so we never index past the icon arrays.
var max_icon_index: int = minigames_body_icons.size() - 1
if icon_index < 0 or icon_index > max_icon_index:
Log.error("Gardens: Exercise type %d has no wheel icon (%d available); using the highest available minigame instead." % [exercise_type, minigames_body_icons.size()])
icon_index = clampi(icon_index, 0, max_icon_index)
var status: StudentProgression.Status = lesson_unlocks["games"][wedge_index] as StudentProgression.Status var status: StudentProgression.Status = lesson_unlocks["games"][wedge_index] as StudentProgression.Status
var wedge: MinigameWedge = MINIGAME_WEDGE_SCENE.instantiate() var wedge: MinigameWedge = MINIGAME_WEDGE_SCENE.instantiate()
wedges_container.add_child(wedge) wedges_container.add_child(wedge)