// JSONL replay file loader for test-client. // Each line is a JSON array of PlayerInput for one tick. // Empty array = idle tick (no input sent). use settled_reach_server::bridge::types::PlayerInput; use std::path::Path; /// Load a JSONL replay file. Returns one Vec per tick. pub fn load_replay(path: &Path) -> Result>, String> { let content = std::fs::read_to_string(path) .map_err(|e| format!("failed to read replay file {}: {}", path.display(), e))?; let mut ticks = Vec::new(); for (i, line) in content.lines().enumerate() { let line = line.trim(); if line.is_empty() { continue; } let inputs: Vec = serde_json::from_str(line).map_err(|e| format!("replay line {}: {}", i + 1, e))?; ticks.push(inputs); } Ok(ticks) }