1
0
Fork 0
mirror of https://codeberg.org/demostf/parser.git synced 2026-06-04 02:24:12 +02:00

gamestate improvements

This commit is contained in:
Robin Appelman 2022-08-25 23:54:46 +02:00
commit 307a6cf953
7 changed files with 1710 additions and 65 deletions

31
src/bin/gamestate.rs Normal file
View file

@ -0,0 +1,31 @@
use std::env;
use std::fs;
use main_error::MainError;
use tf_demo_parser::demo::parser::gamestateanalyser::GameStateAnalyser;
pub use tf_demo_parser::{Demo, DemoParser, Parse, ParseError, ParserState, Stream};
#[cfg(feature = "jemallocator")]
#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
fn main() -> Result<(), MainError> {
#[cfg(feature = "better_panic")]
better_panic::install();
#[cfg(feature = "trace")]
tracing_subscriber::fmt::init();
let args: Vec<_> = env::args().collect();
if args.len() < 2 {
println!("1 argument required");
return Ok(());
}
let path = args[1].clone();
let file = fs::read(path)?;
let demo = Demo::new(&file);
let parser = DemoParser::new_with_analyser(demo.get_stream(), GameStateAnalyser::new());
let (_, state) = parser.parse()?;
println!("{}", serde_json::to_string_pretty(&state.players)?);
Ok(())
}