diff options
Diffstat (limited to 'src/classes')
-rw-r--r-- | src/classes/pptr.rs | 19 | ||||
-rw-r--r-- | src/classes/streaminginfo.rs | 2 |
2 files changed, 10 insertions, 11 deletions
diff --git a/src/classes/pptr.rs b/src/classes/pptr.rs index 9b54cbb..366e17c 100644 --- a/src/classes/pptr.rs +++ b/src/classes/pptr.rs @@ -1,6 +1,6 @@ use crate::{ + assetbundle::AssetBundle, object::{Value, parser::FromValue}, - serialized_file::SerializedFile, }; use anyhow::{Result, anyhow, bail}; use log::debug; @@ -13,7 +13,7 @@ use std::{ #[derive(Debug, Serialize)] pub struct PPtr<T = Value> { #[serde(skip, default)] - _class: PhantomData<T>, + pub(crate) _class: PhantomData<T>, pub class: String, pub file_id: i32, pub path_id: i64, @@ -54,27 +54,26 @@ impl<T: FromValue> PPtr<T> { pub fn is_null(&self) -> bool { self.path_id == 0 && self.file_id == 0 } - pub fn load( - &self, - file: &mut SerializedFile<impl Read + Seek>, - shared_assets: Option<&mut SerializedFile<impl Read + Seek>>, - ) -> Result<T> { + pub fn load(&self, bundle: &mut AssetBundle<impl Read + Seek>) -> Result<T> { debug!( "loading PPtr<{}> file_id={} path_id={}", self.class, self.file_id, self.path_id ); match self.file_id { 0 => { - let ob = file + let ob = bundle + .main .objects .iter() .find(|o| o.path_id == self.path_id) .ok_or(anyhow!("object with path id {} not found", self.path_id))? .to_owned(); - file.read_object(ob)?.parse() + bundle.main.read_object(ob)?.parse() } 1 => { - let file = shared_assets.unwrap(); + let file = bundle.shared_assets.as_mut().ok_or(anyhow!( + "shared assets referenced but not included in bundle" + ))?; let ob = file .objects .iter() diff --git a/src/classes/streaminginfo.rs b/src/classes/streaminginfo.rs index 21029f4..e308f1c 100644 --- a/src/classes/streaminginfo.rs +++ b/src/classes/streaminginfo.rs @@ -26,7 +26,7 @@ impl FromValue for StreamingInfo { } impl StreamingInfo { - pub fn read(&self, fs: &mut UnityFS<impl Read + Seek>) -> Result<Vec<u8>> { + pub fn read(&self, fs: &UnityFS<impl Read + Seek>) -> Result<Vec<u8>> { if !self.path.starts_with("archive:") { bail!("StreamingInfo path does not start on archive:") } |