FAF Replay Parser
A Supreme Commander: Forged Alliance replay parser based on https://github.com/FAForever/faf-scfa-replay-parser.
This project aims to provide a fast parser for the Supreme Commander Forged Alliance (SCFA) replay data format. These replay files are relatively small by today's standards, however, performance still matters when you need to parse a large number of replays.
This repository includes the parser implementation as a Rust crate, as well as command line utility and Python3 bindings.
Usage
The easiest way to use the parser is through the Python module. Note that pre-compiled binaries are only distributed for Linux. If you need to compile for a different operating system, the Building section may be helpful.
Install using pip:
$ pip install faf-replay-parser
Parse replays through the Parser
class:
=
# Or create a parser with default arguments (turn off save_commands though)
# parser = Parser(save_commands=False)
# Read replay to a `bytes` object
=
# Parse to a python dictionary. Data must by exactly of type `bytes`
=
The Command Line Utility
Disclaimer: The cli is a work in progress, and some parts of it may currently print out excess amounts of debug information.
Installing
You can get the cli by cloning this repository and building it with:
$ cargo build --release --features cli
This will produce an executable in target/release/
. Copy this to some location
in your $PATH
, for instance ~/.local/bin/
.
Alternatively, a Linux binary is available in the GitLab CI build artifacts of every tagged release.
Functionality
The cli currently performs 3 main functions. Printing a summary of the replay
(mostly header information), inspecting the contents of the command stream, and
converting fafreplay
files into scfareplay
files. For detailed information
on the cli parameters use the --help
command.
Building
To build the command line utility:
$ cargo build --release --features cli
To build the Python extension module:
$ cargo +nightly build --lib --features python --release
Note: If you forget the --lib
flag you may end up with some linker errors,
however, the dynamic library should still have been compiled correctly.
Development
For developing the python bindings it may be useful to simlink the compiled library to the root project directory.
$ ln -s target/release/libfafreplay.so ./fafreplay.so
Python will then be able to find the module fafreplay
when the interpreter is
run from the project root.
Related Projects
Looking for a parser in a different language? Check out these other replay parser implementations:
- faf-scfa-replay-parser a library implementation in pure Python
- ReplayParser a library implementation in C#
- fafafaf.bitbucket.org a JavaScript application for viewing replay stats
- Replay Sync Tool a PyQT application for synchronized replay playback with a rudimentary Python 2 parser implementation.
- (Bonus) https://pastebin.com/H4hazWFp the beginnings of a Python implementation by ZePilot