From e254cd8ee846aece0d5f53807f0bfbe73490abf4 Mon Sep 17 00:00:00 2001 From: dingo Date: Sun, 15 Mar 2026 20:29:39 -0400 Subject: [PATCH] Fix: BFS path type error Array vs Array[Vector2i] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Queue entries store paths as plain Array (nested in an untyped Array). GDScript cannot implicitly upcast Array → Array[Vector2i] on pop_front. Keep path variables untyped while building; use Array.assign() to produce a typed Array[Vector2i] only at the final return point. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- Client/origin-client/scenes/game/game_screen.gd | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Client/origin-client/scenes/game/game_screen.gd b/Client/origin-client/scenes/game/game_screen.gd index 9e943d0..3d50781 100644 --- a/Client/origin-client/scenes/game/game_screen.gd +++ b/Client/origin-client/scenes/game/game_screen.gd @@ -801,7 +801,7 @@ func _update_prev_state(state: Dictionary) -> void: _prev_unit_hp.clear() _prev_unit_pos.clear() for player: Dictionary in state.get("players", []): - var arch := player.get("archSpirit", {}) + var arch : Dictionary = player.get("archSpirit", {}) for unit: Dictionary in ([arch] + player.get("field", [])): if unit.is_empty(): continue var iid := str(unit.get("instanceId", "")) @@ -828,9 +828,9 @@ func _bfs_path(from: Vector2i, to: Vector2i, blocked: Dictionary) -> Array[Vecto # Queue entries: [pos: Vector2i, path: Array[Vector2i]] var queue : Array = [[from, []]] while not queue.is_empty(): - var front = queue.pop_front() - var cur : Vector2i = front[0] - var path : Array[Vector2i] = front[1] + var front = queue.pop_front() + var cur : Vector2i = front[0] + var path : Array = front[1] # untyped — stored in a plain Array queue for d : Vector2i in DIRS: var nxt := cur + d if nxt.x < 0 or nxt.x >= bw or nxt.y < 0 or nxt.y >= bh: @@ -840,10 +840,12 @@ func _bfs_path(from: Vector2i, to: Vector2i, blocked: Dictionary) -> Array[Vecto if blocked.has(nxt) and nxt != to: continue visited[nxt] = true - var new_path : Array[Vector2i] = path.duplicate() + var new_path : Array = path.duplicate() new_path.append(nxt) if nxt == to: - return new_path + var typed : Array[Vector2i] = [] + typed.assign(new_path) + return typed queue.append([nxt, new_path]) return [to] # fallback: direct jump @@ -892,7 +894,7 @@ func _play_move_animations(state: Dictionary) -> float: blocked[_prev_unit_pos[prev_iid]] = true var max_dur := 0.0 for player: Dictionary in state.get("players", []): - var arch := player.get("archSpirit", {}) + var arch : Dictionary = player.get("archSpirit", {}) for unit: Dictionary in ([arch] + player.get("field", [])): if unit.is_empty(): continue var iid := str(unit.get("instanceId", ""))