1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//! File format handling for DayZ: PBO archives, rapified configs, P3D models, PAA textures and BI
//! keys and signatures, plus the preprocessor and `__EVAL` evaluator the config pipeline needs.
//!
//! # Modules
//!
//! - [`pbo`]: read, build, pack, unpack and selectively read PBO archives ([`pbo::PBO`]).
//! - [`extract`]: extract a whole install or mod into one tree by prefix.
//! - [`config`], [`preprocess`]: config parsing, rapification and derapification.
//! - [`p3d`]: MLOD model reading and inspection (ODOL is only detected there).
//! - [`odol`]: binarized ODOL v56 models, read for what a listing needs (LODs, textures, materials, proxies).
//! - [`paa`]: PAA textures, with conversion from and to images (feature `image`).
//! - `sign`: BI keys and `.bisign` signatures (feature `sign`).
//! - `navmesh`: DayZ navmesh generation: data-server client, tile builder and `.nm` reader and writer (feature `navmesh`).
//! - [`binarize`]: BI's `binarize.exe`, natively on Windows or under Proton.
//! - [`warning`]: the warnings library calls raise.
//!
//! The library never prints and never exits the process; every reader treats its input as hostile and
//! returns errors instead of panicking.
//!
//! # Warnings
//!
//! Calls that can warn take a `&mut dyn` [`warning::WarningSink`]. [`warning::Warnings`]
//! is the ready-made sink: it collects [`warning::Warning`]s (and plain notes), can mute
//! warnings by name and caps repeats. Warnings are never global: give every thread or job its own sink and
//! its warnings stay with it.
//!
//! # Binarizing
//!
//! [`binarize::Binarizer`] owns the Proton sandbox, if any. Pass it to
//! [`pbo::PBO::from_directory`] and call [`binarize::Binarizer::close`] when done so the
//! sandbox is removed and its warnings reach your sink; dropping it also cleans up, but cannot report.
//!
//! # Features
//!
//! - `sign` (default): the `sign` module.
//! - `image` (default): `Paa::from_dynamic_image`, `Paa::to_dynamic_image` and the
//! re-exported `image` crate.
//! - `navmesh` (default): the `navmesh` module.
//!
//! # Licence
//!
//! GPL-2.0-or-later, inherited from armake2. Projects under GPLv3 or AGPL-3.0 may link it.
//!
//! # Example
//!
//! Generate a key, convert an image to PAA, pack and sign a mod folder, and verify the result:
//!
//! ```
//! # #[cfg(all(feature = "sign", feature = "image"))]
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! use std::fs::{self, File};
//! use dayzmake_core::image::{DynamicImage, RgbaImage};
//! use dayzmake_core::paa::{Paa, PaaFormat};
//! use dayzmake_core::pbo::{PBO, PackOptions};
//! use dayzmake_core::sign::{BIPrivateKey, BISignVersion, signature_path};
//! use dayzmake_core::warning::Warnings;
//!
//! let tmp = tempfile::tempdir()?;
//! let stage = tmp.path().join("stage");
//! fs::create_dir_all(stage.join("data"))?;
//!
//! // A satellite tile as DXT1.
//! let image = DynamicImage::ImageRgba8(RgbaImage::new(64, 64));
//! let paa = Paa::from_dynamic_image(&image, PaaFormat::Dxt1)?;
//! paa.write(&mut File::create(stage.join("data/s_0.paa"))?)?;
//!
//! // Pack, sign, verify. Each job has its own warnings.
//! let mut warnings = Warnings::new();
//! let pbo = PBO::from_directory(&stage, &PackOptions::pack(), None, &mut warnings)?;
//! let key = BIPrivateKey::generate(1024, "example".to_string())?;
//! let signature = key.sign(&pbo, BISignVersion::V3)?;
//! let pbo_path = tmp.path().join("example.pbo");
//! pbo.write(&mut File::create(&pbo_path)?)?;
//! signature.write(&mut File::create(signature_path(&pbo_path, key.name())?)?)?;
//! key.to_public_key()?.verify(&pbo, &signature)?;
//! # Ok(())
//! # }
//! # #[cfg(not(all(feature = "sign", feature = "image")))]
//! # fn main() {}
//! ```
/// The `image` crate the PAA conversion API uses, so consumers build against the same version.
pub use image;
/// Binarization through BI's `binarize.exe` (Windows or Proton).
/// Config parsing and rapification/derapification.
/// Error types and the `error!` macro.
/// Evaluator for config `__EVAL` / `__EXEC` expressions.
pub
/// File identity (the same file under different spellings).
/// I/O helpers for the binary formats.
pub
/// Bohemia's LZSS compression.
pub
/// Binarized ODOL v56 model reading.
/// P3D model reading and inspection.
/// PAA texture conversion.
/// PBO archive packing, unpacking and inspection.
/// Config preprocessing (macros, includes, conditionals).
/// BI signature (`.bisign`) creation and verification.
/// Warnings raised by library calls and the sinks that receive them.