From fcd84fdb356948cbf35a20d091dbc2f6c0e3c6e0 Mon Sep 17 00:00:00 2001 From: Adrien Ufferte Date: Sat, 6 Jun 2026 18:11:45 +0200 Subject: [PATCH] Protect against out of bounds for minigame index --- sources/gardens/gardens.gd | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sources/gardens/gardens.gd b/sources/gardens/gardens.gd index 9bfd1d66..71deb8cd 100644 --- a/sources/gardens/gardens.gd +++ b/sources/gardens/gardens.gd @@ -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 exercise_type: int = exercises[wedge_index] 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 wedge: MinigameWedge = MINIGAME_WEDGE_SCENE.instantiate() wedges_container.add_child(wedge)