Skip to content

Commit

Permalink
Implement Skeleton Track Set Ref
Browse files Browse the repository at this point in the history
  • Loading branch information
anarelion committed Oct 30, 2023
1 parent f1c0cf7 commit e7c066d
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/wld/fragments/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod t4_texture;
mod t54_mesh;
mod t5_texture_list_wrapper;
mod t45_dm_sprite_ref;
mod t17_skeleton_ref;

pub use t18_track_def::WldTrackDef;
pub use t19_track::WldTrack;
Expand All @@ -19,3 +20,4 @@ pub use t4_texture::WldTextureList;
pub use t54_mesh::WldMesh;
pub use t5_texture_list_wrapper::WldTextureRef;
pub use t45_dm_sprite_ref::WldDmSpriteRef;
pub use t17_skeleton_ref::WldSkeletonRef;
32 changes: 32 additions & 0 deletions src/wld/fragments/t17_skeleton_ref.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use std::rc::Rc;

use bytes::{Bytes, Buf};

use crate::wld::names::WldNames;
use crate::Decoder;

#[derive(Clone, Debug)]
pub struct WldSkeletonRef {
pub name: Option<String>,
pub reference : u32,
pub params1: u32,
}

impl Decoder for WldSkeletonRef {
type Settings = Rc<WldNames>;

fn new(input: &mut Bytes, settings: Self::Settings) -> Result<Self, crate::EQFilesError>
where
Self: Sized,
{
let name = settings.get_name(input);
let reference = input.get_u32_le();
let params1 = input.get_u32_le();

Ok(Self {
name,
reference,
params1,
})
}
}
13 changes: 12 additions & 1 deletion src/wld/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub struct WldFile {
pub t3: HashMap<u32, WldTextureFilename>,
pub t4: HashMap<u32, WldTextureList>,
pub t5: HashMap<u32, WldTextureRef>,
pub t17: HashMap<u32, WldSkeletonRef>,
pub t18: HashMap<u32, WldTrackDef>,
pub t19: HashMap<u32, WldTrack>,
pub t20: HashMap<u32, WldModel>,
Expand Down Expand Up @@ -58,6 +59,7 @@ impl Decoder for WldFile {
let t3 = extract_fragments(&raw_fragments, 3, names.clone());
let t4 = extract_fragments(&raw_fragments, 4, names.clone());
let t5 = extract_fragments(&raw_fragments, 5, names.clone());
let t17 = extract_fragments(&raw_fragments, 17, names.clone());
let t18 = extract_fragments(&raw_fragments, 18, names.clone());
let t19 = extract_fragments(&raw_fragments, 19, names.clone());
let t20 = extract_fragments(&raw_fragments, 20, names.clone());
Expand All @@ -68,7 +70,7 @@ impl Decoder for WldFile {
let remaining: HashSet<u32> = raw_fragments
.iter()
.map(|(_, frag)| frag.0)
.filter(|a| ![3, 4, 5, 18, 19, 20, 45, 48, 49, 54].contains(a))
.filter(|a| ![3, 4, 5, 17, 18, 19, 20, 45, 48, 49, 54].contains(a))
.collect();
if !remaining.is_empty() {
info!("{:?}", remaining);
Expand All @@ -80,6 +82,7 @@ impl Decoder for WldFile {
t3,
t4,
t5,
t17,
t18,
t19,
t20,
Expand Down Expand Up @@ -130,4 +133,12 @@ impl WldFile {
pub fn get_texture_list_ref(&self, index: u32) -> WldTextureRef {
self.t5.get(&index).unwrap().clone()
}

pub fn get_skeleton_ref(&self, index: u32) -> WldSkeletonRef {
self.t17.get(&index).unwrap().clone()
}

pub fn get_fragment_type(&self, index:u32) -> u32 {
self.raw_fragments.get(&index).unwrap().0
}
}

0 comments on commit e7c066d

Please sign in to comment.