fix(client): resolve GDScript autoload parse-order errors
Autoload scripts are parsed before regular scripts, so class_name types (CharacterVisualDescriptor, TestHarness, YamlParser) are not available at parse time. Replace type annotations with untyped vars and use load() for in-body class references. Fixes all 14 headless parse errors (9 pre-existing + 5 from Sprint 30 changes). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -100,7 +100,8 @@ var character_archetype: String = "detective"
|
||||
# #705: Character visual descriptor — set by character_creation.gd on confirmation.
|
||||
# Passed to EntityRenderer for the player entity's CharacterVisual on game start.
|
||||
# Null when no custom appearance has been selected (fallback: default descriptor).
|
||||
var character_visual_descriptor: CharacterVisualDescriptor = null
|
||||
# Type is CharacterVisualDescriptor — untyped to avoid autoload parse-order issue.
|
||||
var character_visual_descriptor = null
|
||||
|
||||
# #646: AI-Enhanced Dialogue enabled state (D-138).
|
||||
# Runtime toggle — true means the LLM re-voicing pipeline should run (server-side).
|
||||
@@ -366,7 +367,8 @@ func apply_snapshot(snapshot: Dictionary) -> void:
|
||||
# Server persists the descriptor and includes it in ObserverSnapshot after load.
|
||||
# Only update when field is present (null means no change).
|
||||
if snapshot.has("character_visual_descriptor") and snapshot.character_visual_descriptor is Dictionary:
|
||||
var restored := CharacterVisualDescriptor.from_dict(snapshot.character_visual_descriptor)
|
||||
var CVD := load("res://scripts/rendering/character_visual_descriptor.gd")
|
||||
var restored = CVD.from_dict(snapshot.character_visual_descriptor)
|
||||
if restored != null:
|
||||
character_visual_descriptor = restored
|
||||
|
||||
|
||||
@@ -5,7 +5,8 @@ enum ConnectionState { DISCONNECTED, CONNECTING, HANDSHAKING, CONNECTED, ERROR }
|
||||
|
||||
var state: ConnectionState = ConnectionState.DISCONNECTED
|
||||
var test_mode: bool = OS.get_environment("SR_LIVE") != "1" # SR_LIVE=1 connects to real server
|
||||
var harness: TestHarness = null # Test simulation (D-020: game logic lives outside production client)
|
||||
# Type is TestHarness — untyped to avoid autoload parse-order issue.
|
||||
var harness = null # Test simulation (D-020: game logic lives outside production client)
|
||||
var _last_snapshot: Variant = null # Most recent decoded snapshot (consumed by poll_snapshot)
|
||||
var _outbound_buffer: Array[Dictionary] = [] # Raw inputs awaiting batch encode + transport
|
||||
|
||||
@@ -33,7 +34,7 @@ signal handshake_failed(reason: String)
|
||||
|
||||
func _ready() -> void:
|
||||
if test_mode:
|
||||
harness = TestHarness.new()
|
||||
harness = load("res://scripts/protocol/test_harness.gd").new()
|
||||
print("SimBridge: Running in test mode (dynamic snapshot)")
|
||||
|
||||
|
||||
|
||||
@@ -51,4 +51,4 @@ func reload() -> void:
|
||||
## Returns flat Dictionary with dotted keys: { "section.sub.key": "value" }.
|
||||
## Delegates to YamlParser.parse_flat() (#560).
|
||||
static func _parse_yaml(text: String) -> Dictionary:
|
||||
return YamlParser.parse_flat(text)
|
||||
return load("res://scripts/util/yaml_parser.gd").parse_flat(text)
|
||||
|
||||
@@ -516,8 +516,8 @@ static func encode_startup_message(world_seed: int, character_archetype: String
|
||||
"world_seed": world_seed,
|
||||
"character_archetype": archetype_variant,
|
||||
}
|
||||
if character_visual != null and character_visual is CharacterVisualDescriptor:
|
||||
msg["character_visual_descriptor"] = (character_visual as CharacterVisualDescriptor).to_dict()
|
||||
if character_visual != null and character_visual.has_method("to_dict"):
|
||||
msg["character_visual_descriptor"] = character_visual.to_dict()
|
||||
var result = Messagepack.encode(msg)
|
||||
if result.status != null:
|
||||
push_error("Protocol: startup message encode failed: %s" % result.status)
|
||||
|
||||
@@ -62,7 +62,7 @@ func _show_character_creation() -> void:
|
||||
_char_creation.creation_cancelled.connect(_on_creation_cancelled)
|
||||
|
||||
|
||||
func _on_creation_confirmed(descriptor: CharacterVisualDescriptor) -> void:
|
||||
func _on_creation_confirmed(descriptor) -> void:
|
||||
if _char_creation != null and is_instance_valid(_char_creation):
|
||||
_char_creation.queue_free()
|
||||
_char_creation = null
|
||||
|
||||
Reference in New Issue
Block a user