### Rust: Replay Server Setup and Usage Source: https://context7.com/lkolbly/wows-replays/llms.txt Sets up and runs a web server for browsing and analyzing World of Warships replay files. The server automatically watches a specified directory for new replays, parses and indexes them, and provides endpoints for downloading original replays, JSON Lines data, and visualizations. ```rust // In replayserver/src/main.rs - automatically loaded // Run the server: // Command line usage: // cargo run --bin replayserver -- --replays /path/to/replays --root / // Available endpoints: // GET /page/{pageid} - Browse replay list // GET /download/{replay_hash} - Download original replay file // GET /decoded/{replay_hash} - Download as JSON lines // GET /trails/{replay_hash} - Generate ship trail visualization // GET /damage_trails/{replay_hash} - Generate damage trail visualization ``` ```bash # Start the replay server cargo build --release ./target/release/replayserver --replays ./replays --root / # Server will: # - Watch the replay directory for new files # - Parse and index replays automatically # - Serve web interface on default Rocket port (8000) # - Provide download and visualization endpoints # Access in browser: ``` -------------------------------- ### Run World of Warships Replay Parser Help Command Source: https://github.com/lkolbly/wows-replays/blob/master/README.md Executes the `replayshark` command-line utility with the 'help' argument to display available commands and usage instructions. This is a common way to interact with the tool after building it. ```bash "./target/release/replayshark help" ``` -------------------------------- ### Build World of Warships Replay Parser Release Binary Source: https://github.com/lkolbly/wows-replays/blob/master/README.md Builds the release version of the `replayshark` executable using Cargo. This command compiles the Rust project, optimizing it for performance. The resulting executable will be found in the `target/release` directory. ```bash $"cargo build --release" ``` -------------------------------- ### Bash: Command Line Tools for Replay Analysis Source: https://context7.com/lkolbly/wows-replays/llms.txt Provides command-line interface (CLI) tools for interacting with World of Warships replay files using the 'replayshark' executable. These tools enable dumping replays to JSON Lines, extracting chat logs, generating game summaries, surveying multiple replays for statistics, and investigating specific packets. ```bash # Basic dump to stdout ./replayshark dump replay.wowsreplay # Output to file ./replayshark dump --output replay.jl replay.wowsreplay # Skip metadata line ./replayshark dump --no-meta replay.wowsreplay # Example output format (first line is metadata): # {"matchGroup":"pvp","gameMode":2,"playerName":"ExamplePlayer",...} # {"clock":0.0,"packet_type":8,"payload":{"EntityCreate":{...}}} # {"clock":1.2,"packet_type":15,"payload":{"DamageReceived":{...}}} # Extract chat log ./replayshark chat replay.wowsreplay # Example output: # [00:23] PlayerName (Team 1): Need intelligence data! # [01:45] AllyPlayer (Team 1): Wilco! # [05:32] PlayerName (Team 1): Well done! # Get game summary with player performance stats ./replayshark summary replay.wowsreplay # Example output includes: # - Player listings with teams # - Damage statistics # - Battle results # - Ribbon counts (citadels, penetrations, etc.) # Survey all replays in directory ./replayshark survey /path/to/replays/**/*.wowsreplay # Skip decoding step for faster survey ./replayshark survey --skip-decode /path/to/replays/*.wowsreplay # Example output: # Parsing replay_001.wowsreplay: OK (1234 packets) # Parsing replay_002.wowsreplay: OK (2456 packets, 3 invalid) # Found 150 replay files # - 145 (96%) were parsed # - Of which 12 (8%) contained invalid packets # - 2 (1%) had a parse error # - 3 (2%) are an unrecognized version # Show metadata (player IDs and names) ./replayshark investigate --meta replay.wowsreplay # Filter by packet type ./replayshark investigate --filter-packet 0x15 replay.wowsreplay # Filter by entity method name ./replayshark investigate --filter-method receiveDamage replay.wowsreplay # Filter by entity ID ./replayshark investigate --entity-id 576272 --filter-method onHealthChanged replay.wowsreplay # Show timestamps in human-readable format (hh:mm:ss) ./replayshark investigate --timestamp 00:00:00+0 replay.wowsreplay # Example output with timestamp: # 00:02:15: {"clock":135.0,"packet_type":15,"payload":{"DamageReceived":{...}}} ``` -------------------------------- ### Parse Game Script Definitions in Rust Source: https://context7.com/lkolbly/wows-replays/llms.txt Loads and inspects entity definitions and RPC specifications from World of Warships game data files. This function requires the `wows_replays` crate, specifically `parse_scripts`, `version::{Version, Datafiles}`, and `std::path::PathBuf`. It outputs counts of entities, properties, and methods, and lists the first few properties and methods for each entity. ```rust use wows_replays::{parse_scripts, version::{Version, Datafiles}}; use std::path::PathBuf; fn inspect_game_definitions() -> Result<(), wows_replays::ErrorKind> { // Load game definition files let version = Version::from_client_exe("0,10,10,0"); let datafiles = Datafiles::new(PathBuf::from("versions"), version)?; let specs = parse_scripts(&datafiles)?; // Inspect entities println!("Found {} entity types", specs.len()); for entity in specs.iter() { println!("\nEntity: {}", entity.name); println!(" Properties: {}", entity.properties.len()); println!(" Internal Properties: {}", entity.internal_properties.len()); println!(" Base Methods: {}", entity.base_methods.len()); println!(" Cell Methods: {}", entity.cell_methods.len()); println!(" Client Methods: {}", entity.client_methods.len()); // Show first few properties for (i, prop) in entity.properties.iter().take(3).enumerate() { println!(" Property[{}]: {} (type: {:?})", i, prop.name, prop.prop_type); } // Show first few methods for (i, method) in entity.client_methods.iter().take(3).enumerate() { println!(" Method[{}]: {} with {} args", i, method.name, method.args.len()); } } Ok(()) } ``` -------------------------------- ### Dump World of Warships Replay to JSON Lines Source: https://github.com/lkolbly/wows-replays/blob/master/README.md Uses the `replayshark` command-line tool to convert a World of Warships replay file into JSON lines format. The output includes meta-information and subsequent JSON-encoded packets, which can be easily processed by other tools. ```bash "./replayshark dump " ``` -------------------------------- ### Rust: Convert Replay to JSON Lines Source: https://context7.com/lkolbly/wows-replays/llms.txt Converts a World of Warships replay file (.wowsreplay) into JSON Lines format, suitable for external processing. It loads game definitions based on the client version and parses packet data, outputting decoded information. Dependencies include the 'wows-replays' crate and game version data files. ```rust use wows_replays::{parse_scripts, ReplayFile}; use wows_replays::analyzer::decoder::DecoderBuilder; use wows_replays::analyzer::{AnalyzerAdapter, AnalyzerBuilder}; use wows_replays::packet2::Parser; use wows_replays::version::{Version, Datafiles}; use std::path::PathBuf; fn dump_replay(input: &str, output: Option<&str>) -> Result<(), wows_replays::ErrorKind> { let replay_file = ReplayFile::from_file(&PathBuf::from(input))?; // Load version-specific game definitions let version = Version::from_client_exe(&replay_file.meta.clientVersionFromExe); let datafiles = Datafiles::new(PathBuf::from("versions"), version)?; let specs = parse_scripts(&datafiles)?; // Create decoder (silent=false, no_meta=false, output_file) let decoder_builder = DecoderBuilder::new(false, false, output); let decoder = decoder_builder.build(&replay_file.meta); // Parse and dump let mut analyzer_set = AnalyzerAdapter::new(vec![decoder]); let mut parser = Parser::new(&specs); parser.parse_packets(&replay_file.packet_data, &mut analyzer_set)?; analyzer_set.finish(); Ok(()) } fn main() { // Dump to stdout dump_replay("replay.wowsreplay", None).unwrap(); // Dump to file dump_replay("replay.wowsreplay", Some("output.jl")).unwrap(); } ``` -------------------------------- ### Parse Packets with Custom Analyzer in Rust Source: https://context7.com/lkolbly/wows-replays/llms.txt Processes replay packets using a custom analyzer to extract specific game events, such as damage received. It demonstrates how to load game data files, initialize a custom analyzer (`DamageTracker`), and use the `Parser` to iterate through and process all packets in a replay file. The custom analyzer can track and report specific events like "receiveDamage". ```rust use wows_replays::{parse_scripts, ReplayFile}; use wows_replays::analyzer::{Analyzer, AnalyzerBuilder, AnalyzerAdapter}; use wows_replays::packet2::{Packet, Parser}; use wows_replays::version::{Version, Datafiles}; use std::path::PathBuf; // Custom analyzer implementation struct DamageTracker { total_damage: f32, } impl Analyzer for DamageTracker { fn process(&mut self, packet: &Packet<'_, '_>) { // Process each packet match &packet.payload { wows_replays::packet2::PacketType::EntityMethod(method) => { if method.method == "receiveDamage" { // Extract damage from method arguments println!("Damage event at {:.1}s", packet.clock); } } _ => {} } } fn finish(&self) { println!("Total damage tracked: {}", self.total_damage); } } struct DamageTrackerBuilder; impl AnalyzerBuilder for DamageTrackerBuilder { fn build(&self, meta: &wows_replays::ReplayMeta) -> Box { println!("Analyzing replay for: {}", meta.playerName); Box::new(DamageTracker { total_damage: 0.0 }) } } fn main() -> Result<(), wows_replays::ErrorKind> { let replay_path = PathBuf::from("replay.wowsreplay"); let replay_file = ReplayFile::from_file(&replay_path)?; // Load game data files for this version let version = Version::from_client_exe(&replay_file.meta.clientVersionFromExe); let datafiles = Datafiles::new(PathBuf::from("versions"), version)?; let specs = parse_scripts(&datafiles)?; // Create analyzer and parser let builder = DamageTrackerBuilder; let analyzer = builder.build(&replay_file.meta); let mut analyzer_set = AnalyzerAdapter::new(vec![analyzer]); // Parse all packets let mut parser = Parser::new(&specs); parser.parse_packets(&replay_file.packet_data, &mut analyzer_set)?; analyzer_set.finish(); Ok(()) } ``` -------------------------------- ### Extract Ship Position and Movement Data in Rust Source: https://context7.com/lkolbly/wows-replays/llms.txt This Rust code snippet demonstrates how to track ship positions and rotations by implementing the `PacketProcessor` trait. It specifically handles `Position` and `PlayerOrientation` packets to log entity movements and calculate distances traveled. Dependencies include the `wows_replays` crate. ```rust use wows_replays::packet2::{Packet, PacketType, PacketProcessor}; use wows_replays::analyzer::decoder::DecodedPacket; use std::collections::HashMap; struct PositionTracker { positions: HashMap>, } impl PacketProcessor for PositionTracker { fn process(&mut self, packet: Packet<'_, '_>) { match &packet.payload { PacketType::Position(pos_packet) => { let entry = self.positions.entry(pos_packet.pid).or_insert(vec![]); entry.push(( packet.clock, pos_packet.position.x, pos_packet.position.y, pos_packet.position.z, )); } PacketType::PlayerOrientation(orient_packet) => { println!("Player orientation at {:.1}s:", packet.clock); println!(" Position: ({:.1}, {:.1}, {:.1})", orient_packet.position.x, orient_packet.position.y, orient_packet.position.z); println!(" Rotation: roll={:.2}, pitch={:.2}, yaw={:.2}", orient_packet.rotation.roll, orient_packet.rotation.pitch, orient_packet.rotation.yaw); } _ => {} } } } fn main() { let mut tracker = PositionTracker { positions: HashMap::new(), }; // Use with parser... // After parsing, analyze movement: for (entity_id, positions) in &tracker.positions { if positions.len() > 1 { let start = positions.first().unwrap(); let end = positions.last().unwrap(); let distance = ((end.1 - start.1).powi(2) + (end.2 - start.2).powi(2) + (end.3 - start.3).powi(2)).sqrt(); println!("Entity {} moved {:.1} units over {:.1}s", entity_id, distance, end.0 - start.0); } } } ``` -------------------------------- ### Parse Replay File from Disk in Rust Source: https://context7.com/lkolbly/wows-replays/llms.txt Loads and decrypts a World of Warships replay file from disk using the `wows_replays` library. It extracts and prints basic match metadata such as player name, ship, map, date, and duration. The raw packet data is also accessible for further processing. ```rust use wows_replays::ReplayFile; use std::path::PathBuf; fn main() -> Result<(), wows_replays::ErrorKind> { // Load replay file let replay_path = PathBuf::from("path/to/replay.wowsreplay"); let replay_file = ReplayFile::from_file(&replay_path)?; // Access metadata println!("Player: {}", replay_file.meta.playerName); println!("Ship: {}", replay_file.meta.playerVehicle); println!("Map: {}", replay_file.meta.mapDisplayName); println!("Date: {}", replay_file.meta.dateTime); println!("Duration: {}s", replay_file.meta.duration); // Raw packet data is available for parsing println!("Packet data size: {} bytes", replay_file.packet_data.len()); Ok(()) } ``` -------------------------------- ### Decode Packet Payloads with Type-Safe Enums in Rust Source: https://context7.com/lkolbly/wows-replays/llms.txt Analyzes and decodes packet payloads from World of Warships replays using type-safe enums for various packet types like damage, arena state, and battle end. It leverages the `wows_replays` crate and requires `wows_replays::analyzer::decoder`, `wows_replays::packet2::Packet`, and `wows_replays::version::Version`. ```rust use wows_replays::analyzer::decoder::{DecodedPacket, DecodedPacketPayload}; use wows_replays::packet2::Packet; use wows_replays::version::Version; fn analyze_packet(packet: &Packet, version: &Version) { let decoded = DecodedPacket::from(version, false, packet); match &decoded.payload { DecodedPacketPayload::DamageReceived { victim, aggressors } => { println!("Entity {} received damage at {:.1}s", victim, decoded.clock); for aggressor in aggressors { println!(" - {} dealt {} damage", aggressor.aggressor, aggressor.damage); } } DecodedPacketPayload::OnArenaStateReceived { players, ..} => { println!("Battle participants:"); for player in players { println!(" - {} (Team {}) in ship {}", player.username, player.teamid, player.shipid); } } DecodedPacketPayload::BattleEnd { winning_team, .. } => { println!("Battle ended. Winner: Team {}", winning_team); } DecodedPacketPayload::EntityProperty { entity_id, property, value } => { println!("Entity {} property '{}' = {:?}", entity_id, property, value); } DecodedPacketPayload::EntityMethod { entity_id, method, args } => { println!("Entity {} method '{}' called with {} args", entity_id, method, args.len()); } _ => {} // Ignore other packet types } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.