1
Fork 0
mirror of https://github.com/redstrate/Physis.git synced 2025-05-05 18:27:46 +00:00

Revert some of the EXD reading changes to fix Item sheet parsing

This commit is contained in:
Joshua Goins 2025-04-28 21:59:07 -04:00
parent 3049014247
commit e29e1bfde9

View file

@ -65,7 +65,7 @@ fn parse_rows(exh: &EXH, data_offsets: &Vec<ExcelDataOffset>) -> BinResult<Vec<E
subrow subrow
.columns .columns
.push(EXD::read_column(reader, exh, column).unwrap()); .push(EXD::read_column(reader, exh, row_offset, column).unwrap());
} }
Some(subrow) Some(subrow)
@ -182,7 +182,7 @@ pub struct EXD {
#[br(parse_with = parse_rows, args(&exh, &data_offsets))] #[br(parse_with = parse_rows, args(&exh, &data_offsets))]
#[bw(write_with = write_rows, args(&exh))] #[bw(write_with = write_rows, args(&exh))]
rows: Vec<ExcelRow>, pub rows: Vec<ExcelRow>,
} }
#[derive(Debug)] #[derive(Debug)]
@ -229,6 +229,7 @@ impl EXD {
fn read_column<T: Read + Seek>( fn read_column<T: Read + Seek>(
cursor: &mut T, cursor: &mut T,
exh: &EXH, exh: &EXH,
row_offset: u32,
column: &ExcelColumnDefinition, column: &ExcelColumnDefinition,
) -> Option<ColumnData> { ) -> Option<ColumnData> {
let mut read_packed_bool = |shift: i32| -> bool { let mut read_packed_bool = |shift: i32| -> bool {
@ -242,12 +243,9 @@ impl EXD {
ColumnDataType::String => { ColumnDataType::String => {
let string_offset: u32 = Self::read_data_raw(cursor).unwrap(); let string_offset: u32 = Self::read_data_raw(cursor).unwrap();
let old_pos = cursor.stream_position().unwrap();
// -4 to take into account reading string_offset
cursor cursor
.seek(SeekFrom::Current( .seek(SeekFrom::Start(
(exh.header.data_offset as u32 + string_offset - 4).into(), (row_offset + exh.header.data_offset as u32 + string_offset).into(),
)) ))
.ok()?; .ok()?;
@ -259,8 +257,6 @@ impl EXD {
byte = Self::read_data_raw(cursor).unwrap(); byte = Self::read_data_raw(cursor).unwrap();
} }
cursor.seek(SeekFrom::Start(old_pos)).unwrap();
Some(ColumnData::String(string)) Some(ColumnData::String(string))
} }
ColumnDataType::Bool => { ColumnDataType::Bool => {