infinite-rs
Simple and fast deserialization library for Halo Infinite.
This crate currently is in early-development. Please let me know via Github issues about any issues you encounter using this project.
Documentation
- Documentation on this project can be found at docs.rs.
Examples/Usage
Getting Started: Loading a Module file
Modules are the file format that store "tags" in Halo Infinite. These files are used to store all the assets in the game, including models, textures, metadata, and more. infinite-rs
provides a simple interface to load these tags, starting with loading the module files themselves.
use ;
Loading a tag file
After we have loaded a module file, we can now use the read_tag
function to load a specific tag by index from the module file. This populates the data_stream
and tag_info
properties in a module entry that we can use later.
The read_tag_from_id
function is also available to load a tag by its global ID, returning the index in which it was found in the module file.
use ;
Creating a custom structure and reading it
infinite-rs
also allows you to read data directly into structures, using the read_metadata
function. This functionality requires the derive
feature.
Defining Structures
To define a structure that can be read from a tag data stream, you must first derive the TagStructure
trait. To ensure proper padding and alignment, you can use the data
attribute to specify the size of the structure in bytes. Each field also must contain a data
attribute specifying the offset in bytes from the start of the structure.
[!TIP] Padding between fields are automatically calculated. Any data between two offsets are skipped.
use TagStructure;
use ;
// Size can be any u64 value.
Reading structures
use TagStructure;
use ;
use ;
// Size can be any u64 value.
Reading enums and flags
infinite-rs
also supports the usage of enums and flags as fields, available on the common types: FieldCharEnum
, FieldShortEnum
, FieldLongEnum
, FieldLongFlags
, FieldWordFlags
and FieldByteFlags
.
For enums, this requires TryFromPrimitive
to be implemented.
For flags, you can use the bitflags
crate.
use TagStructure;
use ;
use TryFromPrimitive;
use bitflags;
bitflags!
Credits
- libinfinite by Coreforge, which this project is mostly based on.
- Reclaimer by Gravemind2401, which helped me get familiar with Blam file formats.
- AusarDocs by Shockfire, a very useful resource on Ausar/Slipspace file formats.
- Kraken by Wolvenkit team, a re-implementation of Oodle Kraken, removing the need for any binary blobs being required for decompression.
- TagFramework by Codename Atriox, which was a common reference point for Slipspace internals.
- red4lib by rfuzzo, acting as the main inspiration for this project.
- HIRT by urium1186, which was very useful in debugging and verifying output from this project.