pub enum CompressionFormat {
None,
Lzma1,
Lz4,
Zstd,
}Expand description
Compression formats supported by TW Games.
Not all games support all formats. Check their game info to know what formats each game support.
Variants§
None
Dummy variant to disable compression.
Lzma1
Legacy format. Supported by all PFH5 games (all Post-WH2 games).
Specifically, Total War games use the Non-Streamed LZMA1 format with the following custom header:
| Bytes | Type | Data |
|---|---|---|
| 4 | u32 | Uncompressed size (as u32, max at 4GB). |
| 1 | u8 | LZMA model properties (lc, lp, pb) in encoded form… I think. Usually it’s 0x5D. |
| 4 | u32 | Dictionary size (as u32)… I think. It’s usually [0x00, 0x00, 0x40, 0x00]. |
For reference, a normal Non-Streamed LZMA1 header (from the original spec) contains:
| Bytes | Type | Data |
|---|---|---|
| 1 | u8 | LZMA model properties (lc, lp, pb) in encoded form. |
| 4 | u32 | Dictionary size (32-bit unsigned integer, little-endian). |
| 8 | u64 | Uncompressed size (64-bit unsigned integer, little-endian). |
This means one has to move the uncompressed size to the correct place in order for a compressed file to be readable, and one has to remove the uncompressed size and prepend it to the file in order for the game to read the compressed file.
Lz4
New format introduced in WH3 6.2.
This is a standard Lz4 implementation, with the following tweaks:
Zstd
New format introduced in WH3 6.2.
This is a standard Zstd implementation, with the following tweaks:
| Bytes | Type | Data |
|---|---|---|
| 4 | u32 | Uncompressed size (as u32, max at 4GB). |
| * | &[u8] | Zstd data, starting with the Zstd Magic Number. |
By default the Zstd compression is done with the checksum and content size flags enabled.
Trait Implementations§
Source§impl Clone for CompressionFormat
impl Clone for CompressionFormat
Source§fn clone(&self) -> CompressionFormat
fn clone(&self) -> CompressionFormat
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CompressionFormat
impl Debug for CompressionFormat
Source§impl Default for CompressionFormat
impl Default for CompressionFormat
Source§fn default() -> CompressionFormat
fn default() -> CompressionFormat
Source§impl<'de> Deserialize<'de> for CompressionFormat
impl<'de> Deserialize<'de> for CompressionFormat
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for CompressionFormat
impl Display for CompressionFormat
Source§impl From<&str> for CompressionFormat
impl From<&str> for CompressionFormat
Source§impl PartialEq for CompressionFormat
impl PartialEq for CompressionFormat
Source§impl Serialize for CompressionFormat
impl Serialize for CompressionFormat
impl Copy for CompressionFormat
impl StructuralPartialEq for CompressionFormat
Auto Trait Implementations§
impl Freeze for CompressionFormat
impl RefUnwindSafe for CompressionFormat
impl Send for CompressionFormat
impl Sync for CompressionFormat
impl Unpin for CompressionFormat
impl UnsafeUnpin for CompressionFormat
impl UnwindSafe for CompressionFormat
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.