diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/classes/pptr.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/classes/pptr.rs b/src/classes/pptr.rs index 332d3da..cf05439 100644 --- a/src/classes/pptr.rs +++ b/src/classes/pptr.rs @@ -60,6 +60,13 @@ impl<T: FromValue> PPtr<T> { pub fn is_null(&self) -> bool { self.path_id == 0 && self.file_id == 0 } + pub fn path(&self) -> &String { + if self.file_id == 0 { + &self.ecx.name + } else { + &self.ecx.externals[self.file_id as usize - 1].path_name + } + } pub fn load(&self, bundle: &mut AssetBundle<impl Read + Seek + 'static>) -> Result<T> { if self.is_null() { bail!("attempted to load null PPtr") @@ -68,11 +75,7 @@ impl<T: FromValue> PPtr<T> { "loading PPtr<{}> file_id={} path_id={}", self.class, self.file_id, self.path_id ); - let path = if self.file_id == 0 { - &self.ecx.name - } else { - &self.ecx.externals[self.file_id as usize - 1].path_name - }; + let path = self.path(); debug!("ref path {path:?}"); if let Some(path) = path.strip_prefix("archive:") { let path = path.split("/").last().unwrap_or(path); |