From 3765844efb47f5641a6b1420b475890c172ac6cb Mon Sep 17 00:00:00 2001 From: mykola2312 <49044616+mykola2312@users.noreply.github.com> Date: Wed, 30 Aug 2023 21:36:05 +0300 Subject: [PATCH] fix bug in read_bytes --- src/fot/sgd.rs | 1 + src/fot/world.rs | 29 +++++------------------------ 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/src/fot/sgd.rs b/src/fot/sgd.rs index 98710b7..8bc1718 100644 --- a/src/fot/sgd.rs +++ b/src/fot/sgd.rs @@ -8,6 +8,7 @@ use super::tag::Tag; use anyhow::Result; use indexmap::IndexMap; +#[derive(Debug)] pub struct SGD { tag: Tag, unk1: Vec, diff --git a/src/fot/world.rs b/src/fot/world.rs index 71c1395..689d714 100644 --- a/src/fot/world.rs +++ b/src/fot/world.rs @@ -1,8 +1,9 @@ use super::decoder::Decoder; +use super::stream::ReadStream; use super::fstring::FString; use super::raw::Raw; -use super::stream::ReadStream; use super::tag::Tag; +use super::sgd::SGD; use anyhow::anyhow; use anyhow::Result; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; @@ -24,29 +25,9 @@ impl World { pub fn test(&self) -> Result<()> { let sgd_start: usize = 0x4E; - let mut sgd = ReadStream::new(&self.data, sgd_start); - let _ = sgd.read::(0)?; - sgd.skip(0x48); - - let n = sgd.read_u32()?; - dbg!(sgd.offset(), n); - let mut names: Vec = Vec::with_capacity(n as usize); - for _ in 0..n { - names.push(sgd.read::(0)?); - } - dbg!(names); - - let unk1 = sgd.read_u32()?; - dbg!(unk1); - for _ in 0..n { - let m = sgd.read_u32()?; - let mut replics: Vec = Vec::with_capacity(m as usize); - for _ in 0..m { - replics.push(sgd.read::(0)?); - } - dbg!(replics); - } - + let sgd = SGD::decode(&self.data, sgd_start, 0)?; + dbg!(&sgd); + Ok(()) } }