use super::LITTLE_ENDIAN;
use crate::dbg_dmp;
use nom::number::complete::{i16, i64};
use nom::*;
#[derive(Debug, PartialEq, Default, Clone, Copy)]
pub struct MPQFileHeaderExt {
extended_block_table_offset: i64,
hash_table_offset_high: i16,
block_table_offset_high: i16,
}
impl MPQFileHeaderExt {
pub fn parse(input: &[u8]) -> IResult<&[u8], MPQFileHeaderExt> {
let (input, extended_block_table_offset) = Self::parse_extended_block_table_offset(input)?;
let (input, hash_table_offset_high) = Self::parse_hash_table_offset_high(input)?;
let (input, block_table_offset_high) = Self::parse_block_table_offset_high(input)?;
Ok((
input,
MPQFileHeaderExt {
extended_block_table_offset,
hash_table_offset_high,
block_table_offset_high,
},
))
}
pub fn parse_extended_block_table_offset(input: &[u8]) -> IResult<&[u8], i64> {
dbg_dmp(i64(LITTLE_ENDIAN), "extended_block_table_offset")(input)
}
pub fn parse_hash_table_offset_high(input: &[u8]) -> IResult<&[u8], i16> {
dbg_dmp(i16(LITTLE_ENDIAN), "hash_table_offset_high")(input)
}
pub fn parse_block_table_offset_high(input: &[u8]) -> IResult<&[u8], i16> {
dbg_dmp(i16(LITTLE_ENDIAN), "block_table_offset_high")(input)
}
}