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 <noreply@anthropic.com>
This commit is contained in:
2026-02-23 21:06:29 +01:00
co-authored by Claude Opus 4.6
parent f67f13ac95
commit 56b8381c40
+11 -3
View File
@@ -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.