From 56b8381c40c690518e53a7864d5821c2bec26f37 Mon Sep 17 00:00:00 2001 From: Jeroen Schweitzer Date: Mon, 23 Feb 2026 21:06:29 +0100 Subject: [PATCH] fix(client): guard null texture and warn on unknown octant (#540 review) Add push_error on null texture at create time, keep previous texture on null at update time (entity stays visible mid-game). Add push_warning on unrecognised octant in _octant_to_direction fallback. Co-Authored-By: Claude Opus 4.6 --- client/scripts/rendering/entity_renderer.gd | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/client/scripts/rendering/entity_renderer.gd b/client/scripts/rendering/entity_renderer.gd index f32061438..91586f77f 100644 --- a/client/scripts/rendering/entity_renderer.gd +++ b/client/scripts/rendering/entity_renderer.gd @@ -109,7 +109,10 @@ func _create_entity_node(entity_id: int, entity_data: Dictionary) -> void: # Load sprite for current facing direction var direction := _entity_direction(entity_id, entity_data) _entity_facing[entity_id] = direction - entity_node.texture = _load_sprite_texture(direction) + var tex := _load_sprite_texture(direction) + if tex == null: + push_error("EntityRenderer: no texture for entity %d direction '%s' — entity will be invisible" % [entity_id, direction]) + entity_node.texture = tex # D-033: self_modulate for relationship tinting; modulate.a is reserved for D-015 dimming. entity_node.self_modulate = _color_for_kind(entity_data) @@ -153,7 +156,10 @@ func _update_entity_node(entity_id: int, entity_data: Dictionary) -> void: var new_dir := _entity_direction(entity_id, entity_data) if new_dir != _entity_facing.get(entity_id, ""): _entity_facing[entity_id] = new_dir - (node as Sprite2D).texture = _load_sprite_texture(new_dir) + var new_tex := _load_sprite_texture(new_dir) + if new_tex != null: + (node as Sprite2D).texture = new_tex + # null: keep previous texture rather than going invisible mid-game # #521: Detect relationship change → fade D-033 self_modulate (0.5s via _process) var new_rel: String = entity_data.get("relationship", "Unknown") @@ -218,7 +224,9 @@ static func _octant_to_direction(octant: String) -> String: "Northeast", "East": return "east" "Southeast", "South": return "south" "Southwest", "West": return "west" - _: return "south" + _: + push_warning("EntityRenderer: unrecognised octant '%s' — defaulting to south" % octant) + return "south" # Load the sprite texture for the given 4-direction key.