[−][src]Module evtclib::raw::parser
This module contains functions to parse an EVTC file.
Layout
The general layout of the EVTC file is as follows:
magic number: b'EVTC'
arcdps build: yyyymmdd
nullbyte
encounter id
nullbyte
agent count
agents
skill count
skills
events
(refer to example.cpp for the exact data types).
The parsing functions mirror the layout of the file and allow you to parse single parts of the data (as long as your file cursor is at the right position).
All numbers are stored as little endian.
arcdps stores the structs by just byte-dumping them. This means that you
have to be careful of the padding. parse_agent
reads 96 bytes, even though
the struct definition only has 92.
Error handling
Errors are wrapped in ParseError
. I/O errors are
wrapped as ParseError::Io
. EOF
is silently swallowed while reading the
events, as we expect the events to just go until the end of the file.
Compared to the "original" enum definitions, we also add
IFF::None
and
CbtResult::None
. This makes parsing easier, as
we can use those values instead of some other garbage. The other enums
already have the None
variant, and the corresponding byte is zeroed, so
there's no problem with those.
Buffering
Parsing the evtc
file does many small reads. If you supply a raw reader,
each read requires a system call, and the overhead will be massive. It is
advised that you wrap the readers in a BufReader
, if the underlying reader
does not do buffering on its own:
use std::io::BufReader; use std::fs::File; let mut input = BufReader::new(File::open("log.evtc").unwrap()); let parsed = evtclib::raw::parse_file(&mut input);
buffered: cargo run --release 0.22s user 0.04s system 94% cpu 0.275 total
raw file: cargo run --release 0.79s user 1.47s system 98% cpu 2.279 total
Resources
Structs
Evtc | A completely parsed (raw) EVTC file. |
Header | EVTC file header. |
PartialEvtc | A partially-parsed EVTC file, containing everything but the events. |
Enums
ParseError | Any error that can occur during parsing. |
Functions
finish_parsing | Finish a partial EVTC by reading the events. |
parse_agent | Parse a single agent. |
parse_agents | Parse the agent array. |
parse_event_rev0 | Parse a single combat event. |
parse_event_rev1 | Parse a single combat event. |
parse_events | Parse all combat events. |
parse_file | Parse a complete EVTC file. |
parse_header | Parse the header of an evtc file. |
parse_partial_file | Parse a partial EVTC file. |
parse_skill | Parse a single skill. |
parse_skills | Parse the skill array. |
Type Definitions
ParseResult | A type indicating the parse result. |