mgx
mgx is a parser for Age of Empires II recorded games.
Supported version
- AoK(
.mgl) - AoC 1.0(
.mgx) - AoC 1.0c(
.mgx) - Userpatch 1.5 or earlier(
.mgz)
Note: mgx doesn't support game records of HD/DE versions.
Usage(as a binary)
# mgx --help
A parser for Age of Empires II recorded games.
Usage: mgx [OPTIONS] <RECORD_PATH>
Arguments:
<RECORD_PATH> Path to the record file. Only AoK(.mgl)/AoC(.mgx)/UP1.5(.mgz) are supported
Options:
-m <MAP> Generate a map image as a .png image. Rotated 45° counterclockwise and change height to 50% to get a in-game look
-j, --json Dump game info into a JSON string
--zh Use Chinese language for output
--header <HEADER> Dump header section to specified file
--body <BODY> Dump body section to specified file
-h, --help Print help
-V, --version Print version
Usage(as a library)
Parse from a buffer if you need more control over the parsing.
Create aRecordmanually and pass it to aParser. Extracted data will persists in theRecordeven if theParserreturns an error.mgx::from_file()will result in nothing if any error occurs.
Parse a file directly
let filename = "path-to-test-record.mgx";
let = from_file.unwrap;
// See src/record.rs for more available fields
println!;
// Generate a map image as a .png image.
// Rotated 45° counterclockwise and change height to 50% to get a in-game look.
draw_map.unwrap;
// Encoding of in game strings are guessed from instructions, may not be correct. `GBK` is used as a fallback.
println!;
// .convert_encoding() calls .detect_encoding() first.
rec.convert_encoding;
// Some info like civilizations are stored as numeric raw data, `.translate()` converts these to human-readable strings. Only "zh"/"en" are supported now.
rec.translate;
// Dump comprehensive info into a JSON string. Check `null` values before using them.
// This method calls .convert_encoding() first.
println!;
Parse a memory buffer
use ;
let mut buffer = Vecnew;
// Prepare filename and last_modified manually
let mut record = new;
// Parsing process won't start until `parse_to()` is called.
let mut parser = new.unwrap;
parser.parse_to?;