#ironman #hoi4

bin+lib hoi4save

Ergonomically work with HOI4 saves

7 releases

0.1.6 Jul 4, 2021
0.1.5 May 29, 2021
0.1.3 Apr 26, 2021
0.1.2 Mar 14, 2021
0.1.1 Feb 6, 2021

#342 in Game dev

Download history 106/week @ 2021-05-27 60/week @ 2021-06-03 50/week @ 2021-06-10 44/week @ 2021-06-17 43/week @ 2021-06-24 79/week @ 2021-07-01 51/week @ 2021-07-08 53/week @ 2021-07-15 56/week @ 2021-07-22 59/week @ 2021-07-29 57/week @ 2021-08-05 57/week @ 2021-08-12 43/week @ 2021-08-19 43/week @ 2021-08-26 27/week @ 2021-09-02 23/week @ 2021-09-09

273 downloads per month

MIT license

18KB
359 lines

ci Version

HOI4 Save

HOI4 Save is a library to ergonomically work with Hearts of Iron IV saves (plaintext + binary).

use hoi4save::{Hoi4Extractor, Encoding};

let data = std::fs::read("assets/saves/1.10-normal-text.hoi4")?;
let (save, encoding) = Hoi4Extractor::extract_save(&data[..])?;
assert_eq!(encoding, Encoding::Plaintext);
assert_eq!(save.player, String::from("FRA"));

The HOI4 binary format can be converted to plaintext with the help of hoi4save::Melter:

let data = std::fs::read("assets/saves/1.10-ironman.hoi4")?;
let (melted, _unknown_tokens) = hoi4save::Melter::new()
    .with_on_failed_resolve(hoi4save::FailedResolveStrategy::Stringify)
    .melt(&data[..])?;

Binary Saves

By default, binary saves will not be decoded properly.

To enable support, one must supply an environment variable (HOI4_IRONMAN_TOKENS) that points to a newline delimited text file of token descriptions. For instance:

0xffff my_test_token
0xeeee my_test_token2

In order to comply with legal restrictions, I cannot share the list of tokens. I am also restricted from divulging how the list of tokens can be derived.

Dependencies

~1–1.6MB
~38K SLoC