mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-04 02:24:12 +02:00
gamestate improvements
This commit is contained in:
parent
74ab5072d2
commit
307a6cf953
7 changed files with 1710 additions and 65 deletions
31
src/bin/gamestate.rs
Normal file
31
src/bin/gamestate.rs
Normal 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(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue