fix(client): address PR #40 review — 13 suggestions
- Rename _insert to insert_state in main.gd (Hoshe #1) - Add after_each() to test_bug_report_ring_buffer.gd for GameState cleanup on assertion failure (Hoshe #2) - Add after_each() to test_insert_off_behavior.gd for stance/interaction restore on assertion failure (Hoshe #3) - Fix assertion message: "unknown" → "unavailable" (Hoshe #4) - Document memory ceiling of 60 JSON snapshots in ring buffer (Hoshe #5) - Add precision warning for u64 rng_seed via JSON float (Hoshe #6) - Promote _action_enum_to_wire to public action_enum_to_wire (Tyre #1) - Add @warning_ignore for unused _tick parameter (Tyre #5) - Document insert_active assumption for future no-insert characters (Tyre #4) - Restructure OQ-07 decision amendments as bullet points (Tyre #7) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -41,6 +41,9 @@ var _active: bool = false
|
||||
# Input ring: replay-format PlayerInput arrays, one per tick.
|
||||
# Snapshot ring: ObserverSnapshot JSON strings, one per tick.
|
||||
# Separate heads and counts so each buffer can be tested independently.
|
||||
# Memory ceiling: 60 snapshot JSON strings (each ~2-8KB depending on entity count)
|
||||
# + 60 input arrays (negligible). Worst case ~480KB resident. Acceptable for a
|
||||
# debug tool that is always active during Gauntlet play.
|
||||
var _input_ring: Array = [] # Array[Array] — each slot: Array of {tick, action} dicts
|
||||
var _input_head: int = 0 # Next write index (0..RING_SIZE-1)
|
||||
var _input_count: int = 0 # Filled slot count (0..RING_SIZE)
|
||||
@@ -91,8 +94,7 @@ func record_tick(tick: int, snapshot_json: String, mapper_inputs: Array) -> void
|
||||
|
||||
## Push replay-format inputs for one tick. inputs is Array of {tick, action} dicts.
|
||||
## Overwrites oldest entry when buffer is full (circular eviction).
|
||||
## tick param is unused here — each input dict carries its own tick field.
|
||||
## Kept in the signature so tests and callers can pass tick for symmetry with record_tick().
|
||||
@warning_ignore("unused_parameter")
|
||||
func _push_tick_inputs(_tick: int, inputs: Array) -> void:
|
||||
_input_ring[_input_head] = inputs
|
||||
_input_head = (_input_head + 1) % RING_SIZE
|
||||
@@ -133,6 +135,9 @@ func _format_snapshots_jsonl() -> String:
|
||||
|
||||
## Return the RNG seed for seed.txt. Never returns null.
|
||||
## Uses GameState.rng_seed if available; falls back to "unavailable" string.
|
||||
## Note: rng_seed is u64 on the server. JSON encodes u64 as a number, which
|
||||
## loses precision above 2^53 via float intermediary. When the server field
|
||||
## lands, consider string-encoding the seed to preserve all 64 bits.
|
||||
func _get_current_seed() -> Variant:
|
||||
if GameState.rng_seed != null:
|
||||
return GameState.rng_seed
|
||||
@@ -145,7 +150,7 @@ func _get_current_seed() -> Variant:
|
||||
## {"tick": N, "action": {"Interact": {"target_entity_id": ..., "verb": ...}}}
|
||||
func _to_replay_format(input: Dictionary, tick: int) -> Dictionary:
|
||||
var action_enum: int = input.get("action", -1)
|
||||
var wire: String = SimBridge._action_enum_to_wire(action_enum)
|
||||
var wire: String = SimBridge.action_enum_to_wire(action_enum)
|
||||
if wire.is_empty():
|
||||
return {} # Client-only action (BUG_REPORT, OPEN_MENU)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user