1
Fork 0
mirror of https://github.com/redstrate/Physis.git synced 2025-04-20 03:37:47 +00:00

Clean up debugging stuff

This commit is contained in:
Joshua Goins 2025-04-13 18:30:06 -04:00
parent 670f8aa3dd
commit c0eb7aef9a
4 changed files with 6 additions and 22 deletions

View file

@ -63,7 +63,7 @@ pub(crate) fn string_from_offset(start: u64) -> BinResult<String> {
let old_pos = reader.stream_position()?; let old_pos = reader.stream_position()?;
reader.seek(SeekFrom::Start(start + offset as u64))?; reader.seek(SeekFrom::Start(start + offset as u64))?;
reader.seek(SeekFrom::Start(start as u64))?; reader.seek(SeekFrom::Start(start))?;
let mut next_char = reader.read_le::<u8>().unwrap() as char; let mut next_char = reader.read_le::<u8>().unwrap() as char;
while next_char != '\0' { while next_char != '\0' {
string.push(next_char); string.push(next_char);

View file

@ -8,7 +8,7 @@ use crate::common_file_operations::{
}; };
use crate::{ByteBuffer, ByteSpan}; use crate::{ByteBuffer, ByteSpan};
use binrw::{BinRead, BinReaderExt, BinWrite, binread}; use binrw::{BinRead, BinReaderExt, BinWrite, binread};
use binrw::{BinResult, Endian, Error, binrw, binwrite}; use binrw::{Endian, Error, binrw};
mod aetheryte; mod aetheryte;
pub use aetheryte::AetheryteInstanceObject; pub use aetheryte::AetheryteInstanceObject;
@ -79,12 +79,10 @@ const LGP1_ID: u32 = u32::from_le_bytes(*b"LGP1");
pub struct HeapString { pub struct HeapString {
#[br(temp)] #[br(temp)]
// TODO: this cast is stupid // TODO: this cast is stupid
#[bw(calc = string_heap.get_free_offset_string(&value) as u32)] #[bw(calc = string_heap.get_free_offset_string(value) as u32)]
#[br(dbg)]
pub offset: u32, pub offset: u32,
#[br(calc = string_heap.read_string(r, offset,))] #[br(calc = string_heap.read_string(r, offset,))]
#[bw(ignore)] #[bw(ignore)]
#[br(dbg)]
pub value: String, pub value: String,
} }
@ -120,8 +118,6 @@ impl StringHeap {
let old_pos = self.free_pos; let old_pos = self.free_pos;
self.free_pos += buffer.len() as u64; self.free_pos += buffer.len() as u64;
println!("free pos for {:#?} is {}!", obj, old_pos);
old_pos as i32 old_pos as i32
} }
@ -141,8 +137,6 @@ impl StringHeap {
let old_pos = self.free_pos; let old_pos = self.free_pos;
self.free_pos += buffer.len() as u64; self.free_pos += buffer.len() as u64;
println!("free pos for {:#?} is {}!", obj, old_pos);
old_pos as i32 old_pos as i32
} }
@ -189,7 +183,7 @@ impl StringHeap {
let old_pos = reader.stream_position().unwrap(); let old_pos = reader.stream_position().unwrap();
reader.seek(SeekFrom::Start(offset as u64)).unwrap(); reader.seek(SeekFrom::Start(offset)).unwrap();
let mut next_char = reader.read_le::<u8>().unwrap() as char; let mut next_char = reader.read_le::<u8>().unwrap() as char;
while next_char != '\0' { while next_char != '\0' {
string.push(next_char); string.push(next_char);
@ -526,7 +520,6 @@ struct LayerHeader {
pub festival_phase_id: u16, pub festival_phase_id: u16,
pub is_temporary: u8, pub is_temporary: u8,
pub is_housing: u8, pub is_housing: u8,
#[br(dbg)]
pub version_mask: u16, pub version_mask: u16,
#[brw(pad_before = 4)] #[brw(pad_before = 4)]
@ -663,16 +656,12 @@ impl LayerGroup {
return None; return None;
} }
dbg!(&file_header);
// yes, for some reason it begins at 8 bytes in?!?! // yes, for some reason it begins at 8 bytes in?!?!
let chunk_string_heap = StringHeap::from(cursor.position() + 8); let chunk_string_heap = StringHeap::from(cursor.position() + 8);
let chunk_header = let chunk_header =
LayerChunkHeader::read_le_args(&mut cursor, (&chunk_string_heap,)).unwrap(); LayerChunkHeader::read_le_args(&mut cursor, (&chunk_string_heap,)).unwrap();
dbg!(&chunk_header);
if chunk_header.chunk_size <= 0 { if chunk_header.chunk_size <= 0 {
return None; return None;
} }
@ -684,8 +673,6 @@ impl LayerGroup {
layer_offsets[i as usize] = cursor.read_le::<i32>().unwrap(); layer_offsets[i as usize] = cursor.read_le::<i32>().unwrap();
} }
dbg!(&layer_offsets);
let mut layers = Vec::new(); let mut layers = Vec::new();
for i in 0..chunk_header.layer_count { for i in 0..chunk_header.layer_count {
@ -836,9 +823,6 @@ impl LayerGroup {
free_pos: data_base + 4, free_pos: data_base + 4,
}; };
println!("FINAL STRING HEAP: {:#?}", chunk_string_heap);
println!("FINAL DATA HEAP: {:#?}", chunk_data_heap);
// write header now, because it has a string // write header now, because it has a string
cursor cursor
.seek(SeekFrom::Start(layer_chunk_header_pos)) .seek(SeekFrom::Start(layer_chunk_header_pos))

View file

@ -1,7 +1,7 @@
// SPDX-FileCopyrightText: 2025 Joshua Goins <josh@redstrate.com> // SPDX-FileCopyrightText: 2025 Joshua Goins <josh@redstrate.com>
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
use binrw::{binread, binrw}; use binrw::binread;
use super::common::RelativePositions; use super::common::RelativePositions;

View file

@ -1,7 +1,7 @@
// SPDX-FileCopyrightText: 2025 Joshua Goins <josh@redstrate.com> // SPDX-FileCopyrightText: 2025 Joshua Goins <josh@redstrate.com>
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
use binrw::{binread, binrw}; use binrw::binread;
use super::common::RelativePositions; use super::common::RelativePositions;