fix(client): address PR #34 review — 8 items from Hoshe and Tyre
- Cast Variant to String via str() before passing to _on_room_change - Clear _current_room_id on null room transition (fixes re-entry skip) - Add push_error for failed dir creation and file writes in _save_report - Fix docstring: tests/gauntlet-stats.json → user://dev/gauntlet-stats.json - Namespace stats path to user://dev/ to avoid save data collision - Replace print() with push_warning in _save_report (codebase consistency) - Downgrade client-only wire guard from push_warning to silent return Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -255,13 +255,9 @@ static func _action_enum_to_wire(action: int) -> String:
|
||||
InputMapper.Action.TOGGLE_STANCE_UP: return "ToggleStanceUp"
|
||||
InputMapper.Action.TOGGLE_STANCE_DOWN: return "ToggleStanceDown"
|
||||
InputMapper.Action.OPEN_MENU:
|
||||
# Client-only action, not part of wire protocol
|
||||
push_warning("SimBridge: OPEN_MENU is client-only, not sent to server")
|
||||
return ""
|
||||
return "" # Client-only action, not part of wire protocol
|
||||
InputMapper.Action.BUG_REPORT:
|
||||
# Client-only action (#495), not part of wire protocol
|
||||
push_warning("SimBridge: BUG_REPORT is client-only, not sent to server")
|
||||
return ""
|
||||
return "" # Client-only action (#495), not part of wire protocol
|
||||
_:
|
||||
push_warning("SimBridge: unknown action enum %s" % action)
|
||||
return ""
|
||||
|
||||
@@ -87,7 +87,12 @@ func _save_report(description: String) -> void:
|
||||
var base_path := "user://bug-reports/" + dir_name
|
||||
|
||||
# Ensure directory exists
|
||||
DirAccess.make_dir_recursive_absolute(base_path)
|
||||
var dir_err := DirAccess.make_dir_recursive_absolute(base_path)
|
||||
if dir_err != OK:
|
||||
push_error("BugReport: failed to create directory %s (error %d)" % [base_path, dir_err])
|
||||
return
|
||||
|
||||
var files_saved := 0
|
||||
|
||||
# 1. snapshot.json — full current snapshot as JSON
|
||||
var snapshot_path := base_path + "/snapshot.json"
|
||||
@@ -95,6 +100,9 @@ func _save_report(description: String) -> void:
|
||||
if snapshot_file:
|
||||
snapshot_file.store_string(JSON.stringify(GameState.current_snapshot, "\t"))
|
||||
snapshot_file.close()
|
||||
files_saved += 1
|
||||
else:
|
||||
push_error("BugReport: failed to write %s" % snapshot_path)
|
||||
|
||||
# 2. render.txt — simplified client-side text render of snapshot
|
||||
var render_path := base_path + "/render.txt"
|
||||
@@ -102,6 +110,9 @@ func _save_report(description: String) -> void:
|
||||
if render_file:
|
||||
render_file.store_string(_render_snapshot_text())
|
||||
render_file.close()
|
||||
files_saved += 1
|
||||
else:
|
||||
push_error("BugReport: failed to write %s" % render_path)
|
||||
|
||||
# 3. description.txt — tester description + metadata
|
||||
var desc_path := base_path + "/description.txt"
|
||||
@@ -115,8 +126,11 @@ func _save_report(description: String) -> void:
|
||||
desc_file.store_string("Position: %s\n" % str(GameState.player_position))
|
||||
desc_file.store_string("Timestamp: %s\n" % Time.get_datetime_string_from_system())
|
||||
desc_file.close()
|
||||
files_saved += 1
|
||||
else:
|
||||
push_error("BugReport: failed to write %s" % desc_path)
|
||||
|
||||
print("BugReport: saved to %s" % base_path)
|
||||
push_warning("BugReport: saved %d/3 files to %s" % [files_saved, base_path])
|
||||
|
||||
|
||||
## Simplified client-side text render of the current snapshot.
|
||||
|
||||
@@ -2,7 +2,7 @@ extends Control
|
||||
|
||||
## #496: Gauntlet HUD — room timer + personal bests.
|
||||
## Shows TIMER: MM:SS (PB: MM:SS) in top-right, below StanceIndicator.
|
||||
## Hidden in non-gauntlet mode. Stats persisted to tests/gauntlet-stats.json.
|
||||
## Hidden in non-gauntlet mode. Stats persisted to user://dev/gauntlet-stats.json.
|
||||
|
||||
const BG_COLOR := Color(0.05, 0.05, 0.08, 0.5)
|
||||
const TIMER_COLOR := Color("#c8d0e0") # Default insert text
|
||||
@@ -10,7 +10,7 @@ const PB_COLOR := Color("#6bc9a6") # Friendly green — personal best
|
||||
const NEW_PB_COLOR := Color("#e8c547") # Amber flash on new PB
|
||||
const FONT_SIZE := 13
|
||||
const PADDING := Vector2(10, 6)
|
||||
const STATS_PATH := "user://gauntlet-stats.json"
|
||||
const STATS_PATH := "user://dev/gauntlet-stats.json"
|
||||
|
||||
var _timer_seconds: float = 0.0
|
||||
var _timer_running: bool = false
|
||||
@@ -49,12 +49,14 @@ func update_from_state() -> void:
|
||||
|
||||
var new_room_id: Variant = GameState.room_id
|
||||
if new_room_id == null:
|
||||
# Gauntlet mode but no room yet — stop timer, wait
|
||||
# Gauntlet mode but no room yet — stop timer, clear tracked room
|
||||
# so re-entry to the same room after null triggers a restart.
|
||||
_timer_running = false
|
||||
_current_room_id = null
|
||||
return
|
||||
|
||||
if new_room_id != _current_room_id:
|
||||
_on_room_change(new_room_id)
|
||||
_on_room_change(str(new_room_id))
|
||||
|
||||
|
||||
func _on_room_change(new_room_id: String) -> void:
|
||||
|
||||
Reference in New Issue
Block a user