fix(simulation): use non-blocking TCP to prevent game loop stall
read_framed() called read_exact() which blocked the entire bevy Update schedule waiting for client input — no systems ran until a keystroke arrived. Switch TcpStream to non-blocking mode so receive_inputs() returns Ok(vec![]) on WouldBlock instead of blocking. Toggle to blocking for snapshot writes (reliable delivery). Add 50ms frame throttle (~20 ticks/sec) since the non-blocking loop would otherwise spin. Downgrade input receive logging to trace, add error logging for missing bridge resource and failed observer queries. Fixes bug #1 (server never sends snapshots) and #2 (camera doesn't center until first keystroke). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -33,6 +33,7 @@ pub fn compute_visibility_geometry(
|
||||
mut geometry: ResMut<VisibilityGeometry>,
|
||||
) {
|
||||
let Ok((observer_pos, facing_opt)) = observer_query.single() else {
|
||||
tracing::error!("compute_visibility_geometry: PlayerCharacter query failed");
|
||||
return;
|
||||
};
|
||||
|
||||
@@ -90,6 +91,7 @@ pub fn compute_observer_snapshot(
|
||||
cognitive_delay_opt,
|
||||
)) = observer_query.single_mut()
|
||||
else {
|
||||
tracing::error!("compute_observer_snapshot: PlayerCharacter query failed");
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user