fix(client): address PR #24 review — 5 critical bugs, 3 warnings, 8 suggestions
Critical: - Protocol test assertions updated v6→v7 (test_protocol_v6.gd) - Dialogue signal connections wired (option_selected→DialogueResponse, dialogue_dismissed→DialogueEnd sent to server via SimBridge) - Consume-once race fixed: _consume_dialogue() checks is_dialogue_active() before re-showing; dialogue_id tracking prevents re-trigger during fade - Dialogue box responsive: _update_layout() clamps width to MAX_WIDTH_PX (832px) or 65% viewport, height to 20% viewport (MAX_HEIGHT_RATIO) - Auto-pause added: SimBridge.send_input(PAUSE) on dialogue open/close Warnings: - Test coverage: 16 new tests in test_protocol_v7.gd (pending_recognitions decode, current_dialogue, GameState, SimBridge mock data, insert colors) - queue_redraw() optimization: early return when no entities and no pings - Fixed 200px height → responsive 20% viewport via _update_layout() Suggestions: - WASD detection refactored to _WALK_AWAY_ACTIONS array loop - Button colors reference Constants.INSERT_COLOR_TEXT/HOVER/ACTIVE - Named constants: COLOR_TRANSITION_START, SILHOUETTE_APPEAR_THRESHOLD, SILHOUETTE_SIZE with explanatory comments - Bounds check: MAX_PENDING_RECOGNITIONS=64 with truncation warning - Mock dialogue sustained across ticks (not 1-tick flash) - COLOR_PING coupling with cursor documented as intentional - Consume helpers extracted: _consume_monologue(), _consume_dialogue() Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -123,10 +123,17 @@ static func decode_snapshot(bytes: PackedByteArray) -> Variant:
|
||||
})
|
||||
|
||||
# v7: pending_recognitions (#431, D-059/D-060) — cognitive delay fog entities
|
||||
# Bounded: server sends at most ~50 pending recognitions per snapshot (practical limit
|
||||
# given perception range). Excessive arrays are truncated to prevent allocation abuse.
|
||||
const MAX_PENDING_RECOGNITIONS: int = 64
|
||||
var pending_recognitions: Array = []
|
||||
var raw_recognitions: Variant = raw.get("pending_recognitions")
|
||||
if raw_recognitions is Array:
|
||||
var count := 0
|
||||
for raw_pr in raw_recognitions:
|
||||
if count >= MAX_PENDING_RECOGNITIONS:
|
||||
push_warning("Protocol: pending_recognitions truncated at %d entries" % MAX_PENDING_RECOGNITIONS)
|
||||
break
|
||||
if raw_pr is Dictionary and raw_pr.has("entity_id") and raw_pr.has("x") and raw_pr.has("y"):
|
||||
pending_recognitions.append({
|
||||
"entity_id": int(raw_pr["entity_id"]),
|
||||
@@ -136,6 +143,7 @@ static func decode_snapshot(bytes: PackedByteArray) -> Variant:
|
||||
"remaining_ticks": int(raw_pr.get("remaining_ticks", 0)),
|
||||
"total_delay_ticks": int(raw_pr.get("total_delay_ticks", 1)),
|
||||
})
|
||||
count += 1
|
||||
|
||||
return {
|
||||
"tick": tick,
|
||||
|
||||
Reference in New Issue
Block a user