mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-03 10:14:06 +02:00
parser api wip
This commit is contained in:
parent
81f7ce8df9
commit
42358f243b
12 changed files with 52 additions and 56 deletions
|
|
@ -107,7 +107,7 @@ impl MessageHandler for EntityDumper {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_output(self, state: &ParserState) -> Self::Output {
|
||||
fn into_output(self, state: &ParserState) -> Self::Output {
|
||||
self.entities
|
||||
.into_iter()
|
||||
.map(|(tick, entity)| EntityDump::from_entity(entity, tick, &state.server_classes))
|
||||
|
|
@ -119,7 +119,7 @@ fn entity_test(input_file: &str, snapshot_file: &str) {
|
|||
let file = fs::read(input_file).expect("Unable to read file");
|
||||
let demo = Demo::new(file);
|
||||
let (_, entities) =
|
||||
DemoParser::parse_with_analyser(demo.get_stream(), EntityDumper::new()).unwrap();
|
||||
DemoParser::new_with_analyser(demo.get_stream(), EntityDumper::new()).unwrap();
|
||||
|
||||
let json_file = File::open(snapshot_file).expect("Unable to read file");
|
||||
let mut reader = BufReader::new(json_file);
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ impl MessageHandler for SendPropAnalyser {
|
|||
self.tables = tables.to_vec()
|
||||
}
|
||||
|
||||
fn get_output(self, state: &ParserState) -> Self::Output {
|
||||
fn into_output(self, state: &ParserState) -> Self::Output {
|
||||
self.tables
|
||||
}
|
||||
}
|
||||
|
|
@ -45,7 +45,7 @@ fn flatten_test(input_file: &str, snapshot_file: &str) {
|
|||
let file = fs::read(input_file).expect("Unable to read file");
|
||||
let demo = Demo::new(file);
|
||||
let (_, send_tables) =
|
||||
DemoParser::parse_with_analyser(demo.get_stream(), SendPropAnalyser::new())
|
||||
DemoParser::new_with_analyser(demo.get_stream(), SendPropAnalyser::new())
|
||||
.expect("Failed to parse");
|
||||
let flat_props: HashMap<SendTableName, Vec<String>> = send_tables
|
||||
.iter()
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use tf_demo_parser::{Demo, DemoParser, MatchState, MessageType, MessageTypeAnaly
|
|||
fn snapshot_test(input_file: &str, snapshot_file: &str) {
|
||||
let file = fs::read(input_file).expect("Unable to read file");
|
||||
let demo = Demo::new(file);
|
||||
let (_, state) = DemoParser::parse_demo(demo.get_stream()).unwrap();
|
||||
let (_, state) = DemoParser::new(demo.get_stream()).unwrap();
|
||||
|
||||
let expected: MatchState = serde_json::from_slice(
|
||||
fs::read(snapshot_file)
|
||||
|
|
@ -22,7 +22,7 @@ fn test_message_types(input_file: &str, snapshot_file: &str) {
|
|||
let file = fs::read(input_file).expect("Unable to read file");
|
||||
let demo = Demo::new(file);
|
||||
let (_, message_types) =
|
||||
DemoParser::parse_with_analyser(demo.get_stream(), MessageTypeAnalyser::default()).unwrap();
|
||||
DemoParser::new_with_analyser(demo.get_stream(), MessageTypeAnalyser::default()).unwrap();
|
||||
|
||||
let expected: Vec<MessageType> = serde_json::from_slice(
|
||||
fs::read(snapshot_file)
|
||||
|
|
@ -37,7 +37,7 @@ fn game_state_test(input_file: &str, snapshot_file: &str) {
|
|||
let file = fs::read(input_file).expect("Unable to read file");
|
||||
let demo = Demo::new(file);
|
||||
let (_, state) =
|
||||
DemoParser::parse_with_analyser(demo.get_stream(), GameStateAnalyser::new()).unwrap();
|
||||
DemoParser::new_with_analyser(demo.get_stream(), GameStateAnalyser::new()).unwrap();
|
||||
|
||||
let expected: GameState = serde_json::from_slice(
|
||||
fs::read(snapshot_file)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue