pub struct ModuleFileEntry {Show 26 fields
unknown: u8,
pub flags: FileEntryFlags,
block_count: u16,
block_index: i32,
pub(super) resource_index: i32,
pub tag_group: String,
data_offset: u64,
pub(super) data_offset_flags: DataOffsetType,
total_compressed_size: u32,
total_uncompressed_size: u32,
pub tag_id: i32,
pub(super) uncompressed_header_size: u32,
uncompressed_tag_data_size: u32,
uncompressed_resource_data_size: u32,
uncompressed_actual_resource_size: u32,
header_alignment: u8,
tag_data_alignment: u8,
resource_data_alignment: u8,
actual_resource_data_alignment: u8,
name_offset: u32,
parent_index: i32,
asset_hash: i128,
pub(super) resource_count: i32,
pub data_stream: Option<BufReader<Cursor<Vec<u8>>>>,
pub tag_info: Option<TagFile>,
is_loaded: bool,
}
Expand description
Module file entry structure containing metadata relating to file and required buffer sizes and offsets for the decompressor, as well as global tag ID, resource references and class.
Fields§
§unknown: u8
Unknown, some sort of size?
flags: FileEntryFlags
Determine how the file should be read.
block_count: u16
Number of blocks that make up the file.
block_index: i32
Index of the first block in the module.
resource_index: i32
Index of the first resource in the module’s resource list.
tag_group: String
4 byte-long string for tag group, stored as big endian. This determines how the rest of the tag is read. Example:
bitm
: Bitmapmat
: Material
data_offset: u64
Offset of compressed/uncompressed data in from the start of compressed data in the module.
data_offset_flags: DataOffsetType
Where the offset is located. 1 if in HD1.
total_compressed_size: u32
Size in bytes of compressed buffer in module.
total_uncompressed_size: u32
Size in bytes of buffer to decompress into.
tag_id: i32
MurmurHash3_x86_64
32 bit hash of tag path.
Referred to in-memory as “global tag id”
Is set to -1 if file is resource.
uncompressed_header_size: u32
Size in bytes of header in decompressed buffer.
uncompressed_tag_data_size: u32
Size in bytes of actual tag data in decompressed buffer.
uncompressed_resource_data_size: u32
Size in bytes of resource data in decompressed buffer.
uncompressed_actual_resource_size: u32
Size in bytes of “external” resource data in decompressed buffer. (for instance, havok data or bitmaps)
header_alignment: u8
Power of 2 to align the header buffer to (ex w. 4 = align to a multiple of 16 bytes).
tag_data_alignment: u8
Power of 2 to align the tag data buffer to.
resource_data_alignment: u8
Power of 2 to align the resource data buffer to.
actual_resource_data_alignment: u8
Power of 2 to align the actual resource data buffer to.
name_offset: u32
Offset where the name of the file is located in the string table. This is no longer valid as of module version 52.
parent_index: i32
Used with resources to point back to the parent file. -1 = none
asset_hash: i128
Murmur3_x64_128
hash of (what appears to be) the original file that this file was built from.
This is not always the same thing as the file stored in the module.
Only verified if the HasBlocks
flag is not set.
resource_count: i32
Number of resources owned by the file.
data_stream: Option<BufReader<Cursor<Vec<u8>>>>
Data stream containing a buffer of bytes to read/seek.
tag_info: Option<TagFile>
The actual tag file read from the contents (including header), only valid if file is not a resource.
is_loaded: bool
Indicates if file is cached (has data stream) or not.
Implementations§
Source§impl ModuleFileEntry
impl ModuleFileEntry
Sourcepub(super) fn read_tag(
&mut self,
reader: &mut BufReader<File>,
data_offset: u64,
blocks: &[ModuleBlockEntry],
) -> Result<()>
pub(super) fn read_tag( &mut self, reader: &mut BufReader<File>, data_offset: u64, blocks: &[ModuleBlockEntry], ) -> Result<()>
Reads and loads tag data from a file.
§Arguments
reader
- A mutable reference to aBufReader<File>
from which to read the data.data_offset
- Starting offset in bytes of the data in the file.blocks
- Metadata for data blocks.
§Returns
Returns Ok(())
if the read operation is successful, or an Error
containing
the I/O error if any reading operation fails.
Sourcefn read_multiple_blocks(
&self,
reader: &mut BufReader<File>,
blocks: &[ModuleBlockEntry],
file_offset: u64,
data: &mut [u8],
) -> Result<()>
fn read_multiple_blocks( &self, reader: &mut BufReader<File>, blocks: &[ModuleBlockEntry], file_offset: u64, data: &mut [u8], ) -> Result<()>
Reads multiple blocks of data from the file.
This function reads multiple blocks of data, which can be either compressed or uncompressed, from the file and stores them in the provided data buffer.
§Arguments
reader
- A mutable reference to aBufReader<File>
from which to read the data.blocks
- A slice ofModuleBlockEntry
containing metadata about each block.file_offset
- The offset in the file where the data blocks start.data
- A mutable slice where the (decompressed) data will be stored.
§Returns
Returns Ok(())
if the read operation is successful, or an Error
containing
the I/O error if any reading operation fails.
Sourcepub fn read_metadata<T: Default + TagStructure>(
&mut self,
struct_type: &mut T,
) -> Result<T>
pub fn read_metadata<T: Default + TagStructure>( &mut self, struct_type: &mut T, ) -> Result<T>
Reads a specified structure implementing TagStructure
from the tag data.
This function exhausts the inner data_stream
buffer to read the contents of the specified
struct. It first looks for the main struct definition of the file, then gets the referenced
data block and creates a reader for it. The initial contents of the struct are read, and
field block definitions are loaded recursively.
§Arguments
struct_type
- A mutable reference to the struct implementingTagStructure
to read the data into.
§Returns
Returns Ok(())
if the read operation is successful, or an Error
containing
the I/O error if any reading operation fails.
Examples found in repository?
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
fn main() -> infinite_rs::Result<()> {
let mut pc_modules =
load_modules(String::from("C:/XboxGames/Halo Infinite/Content/deploy/pc"))?;
let mut any_modules = load_modules(String::from(
"C:/XboxGames/Halo Infinite/Content/deploy/any",
))?;
let mut modules = pc_modules.iter_mut().chain(any_modules.iter_mut());
for module in &mut modules {
for index in 0..module.files.len() {
module.read_tag(index as u32)?;
let tag = &mut module.files[index];
if tag.tag_group == "mat " {
let mut mat = MaterialTag::default();
tag.read_metadata(&mut mat)?;
println!("{:#?}", mat.style_info);
}
}
}
Ok(())
}