Expand description

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

A completely parsed (raw) EVTC file.

EVTC file header.

A partially-parsed EVTC file, containing everything but the events.

Enums

Any error that can occur during parsing.

Functions

Finish a partial EVTC by reading the events.

Parse a single agent.

Parse the agent array.

Parse a single combat event.

Parse a single combat event.

Parse all combat events.

Parse a complete EVTC file.

Parse the header of an evtc file.

Parse a partial EVTC file.

Parse a single skill.

Parse the skill array.

Type Definitions

A type indicating the parse result.