From e7bf25759fb43ba5681aa5c10b31ae5cba6140f8 Mon Sep 17 00:00:00 2001 From: dingo Date: Wed, 20 May 2026 19:57:59 -0400 Subject: [PATCH] Fix 2: Guard against null archSpirit in get_unit_by_id and _apply_delta MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GDScript dict.get(key, fallback) only returns the fallback when the key is absent. When a player disconnects the server sets archSpirit to null (key present, value null), so .get("archSpirit", {}) returns null and the next .get("instanceId") call crashes with 'Nonexistent function get in base Nil'. - get_unit_by_id (~line 276): replace typed Dictionary assignment with Variant + 'is Dictionary' guard (same pattern already used correctly in get_all_enemy_units) - _apply_delta ยง7 (~line 633): replace typed Dictionary assignment with Variant + null/type guard before casting; null or non-Dictionary triggers request_sync() the same as an empty baseline would Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- Client/origin-client/autoloads/Game.gd | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Client/origin-client/autoloads/Game.gd b/Client/origin-client/autoloads/Game.gd index 7e07a72..46b5f69 100644 --- a/Client/origin-client/autoloads/Game.gd +++ b/Client/origin-client/autoloads/Game.gd @@ -273,9 +273,10 @@ func get_unit_by_id(instance_id: String) -> Dictionary: for u: Dictionary in p.get("field", []): if u.get("instanceId", "") == instance_id: return u - var arch: Dictionary = p.get("archSpirit", {}) - if arch.get("instanceId", "") == instance_id: - return arch + var arch_val: Variant = p.get("archSpirit") + if arch_val is Dictionary and not (arch_val as Dictionary).is_empty(): + if (arch_val as Dictionary).get("instanceId", "") == instance_id: + return arch_val return {} @@ -630,7 +631,11 @@ func _apply_delta(delta: Dictionary) -> void: var arch_delta := arch_update.get("delta") as Dictionary if arch_delta.is_empty(): continue - var arch: Dictionary = player.get("archSpirit", {}) + var arch_val: Variant = player.get("archSpirit") + if arch_val == null or not (arch_val is Dictionary): + request_sync() + continue + var arch := arch_val as Dictionary if arch.is_empty(): # Missing baseline (likely first sight of this arch). Ask for full sync. request_sync()