mirror of
https://github.com/redstrate/Kawari.git
synced 2025-04-19 22:36:49 +00:00
Make get_primary_model_id return an Option
This commit is contained in:
parent
96bcdf1238
commit
e9ef724f05
2 changed files with 63 additions and 26 deletions
|
@ -107,7 +107,7 @@ impl GameData {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the primary model ID for a given item ID
|
/// Gets the primary model ID for a given item ID
|
||||||
pub fn get_primary_model_id(&mut self, item_id: u32) -> u16 {
|
pub fn get_primary_model_id(&mut self, item_id: u32) -> Option<u16> {
|
||||||
for page in &self.item_pages {
|
for page in &self.item_pages {
|
||||||
if let Some(row) = page.read_row(&self.item_exh, item_id) {
|
if let Some(row) = page.read_row(&self.item_exh, item_id) {
|
||||||
let item_row = &row[0];
|
let item_row = &row[0];
|
||||||
|
@ -116,13 +116,10 @@ impl GameData {
|
||||||
panic!("Unexpected type!");
|
panic!("Unexpected type!");
|
||||||
};
|
};
|
||||||
|
|
||||||
return *id as u16;
|
return Some(*id as u16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: just turn this into an Option<>
|
None
|
||||||
tracing::warn!("Failed to get model id for {item_id}, this is most likely a bug!");
|
|
||||||
|
|
||||||
0
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -577,16 +577,36 @@ impl ZoneConnection {
|
||||||
crest_enable: 0,
|
crest_enable: 0,
|
||||||
pattern_invalid: 0,
|
pattern_invalid: 0,
|
||||||
model_ids: [
|
model_ids: [
|
||||||
game_data.get_primary_model_id(equipped.head.id) as u32,
|
game_data
|
||||||
game_data.get_primary_model_id(equipped.body.id) as u32,
|
.get_primary_model_id(equipped.head.id)
|
||||||
game_data.get_primary_model_id(equipped.hands.id) as u32,
|
.unwrap_or(0) as u32,
|
||||||
game_data.get_primary_model_id(equipped.legs.id) as u32,
|
game_data
|
||||||
game_data.get_primary_model_id(equipped.feet.id) as u32,
|
.get_primary_model_id(equipped.body.id)
|
||||||
game_data.get_primary_model_id(equipped.ears.id) as u32,
|
.unwrap_or(0) as u32,
|
||||||
game_data.get_primary_model_id(equipped.neck.id) as u32,
|
game_data
|
||||||
game_data.get_primary_model_id(equipped.wrists.id) as u32,
|
.get_primary_model_id(equipped.hands.id)
|
||||||
game_data.get_primary_model_id(equipped.left_ring.id) as u32,
|
.unwrap_or(0) as u32,
|
||||||
game_data.get_primary_model_id(equipped.right_ring.id) as u32,
|
game_data
|
||||||
|
.get_primary_model_id(equipped.legs.id)
|
||||||
|
.unwrap_or(0) as u32,
|
||||||
|
game_data
|
||||||
|
.get_primary_model_id(equipped.feet.id)
|
||||||
|
.unwrap_or(0) as u32,
|
||||||
|
game_data
|
||||||
|
.get_primary_model_id(equipped.ears.id)
|
||||||
|
.unwrap_or(0) as u32,
|
||||||
|
game_data
|
||||||
|
.get_primary_model_id(equipped.neck.id)
|
||||||
|
.unwrap_or(0) as u32,
|
||||||
|
game_data
|
||||||
|
.get_primary_model_id(equipped.wrists.id)
|
||||||
|
.unwrap_or(0) as u32,
|
||||||
|
game_data
|
||||||
|
.get_primary_model_id(equipped.left_ring.id)
|
||||||
|
.unwrap_or(0) as u32,
|
||||||
|
game_data
|
||||||
|
.get_primary_model_id(equipped.right_ring.id)
|
||||||
|
.unwrap_or(0) as u32,
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
@ -729,16 +749,36 @@ impl ZoneConnection {
|
||||||
look: chara_details.chara_make.customize,
|
look: chara_details.chara_make.customize,
|
||||||
display_flags: DisplayFlag::UNK,
|
display_flags: DisplayFlag::UNK,
|
||||||
models: [
|
models: [
|
||||||
game_data.get_primary_model_id(equipped.head.id) as u32,
|
game_data
|
||||||
game_data.get_primary_model_id(equipped.body.id) as u32,
|
.get_primary_model_id(equipped.head.id)
|
||||||
game_data.get_primary_model_id(equipped.hands.id) as u32,
|
.unwrap_or(0) as u32,
|
||||||
game_data.get_primary_model_id(equipped.legs.id) as u32,
|
game_data
|
||||||
game_data.get_primary_model_id(equipped.feet.id) as u32,
|
.get_primary_model_id(equipped.body.id)
|
||||||
game_data.get_primary_model_id(equipped.ears.id) as u32,
|
.unwrap_or(0) as u32,
|
||||||
game_data.get_primary_model_id(equipped.neck.id) as u32,
|
game_data
|
||||||
game_data.get_primary_model_id(equipped.wrists.id) as u32,
|
.get_primary_model_id(equipped.hands.id)
|
||||||
game_data.get_primary_model_id(equipped.left_ring.id) as u32,
|
.unwrap_or(0) as u32,
|
||||||
game_data.get_primary_model_id(equipped.right_ring.id) as u32,
|
game_data
|
||||||
|
.get_primary_model_id(equipped.legs.id)
|
||||||
|
.unwrap_or(0) as u32,
|
||||||
|
game_data
|
||||||
|
.get_primary_model_id(equipped.feet.id)
|
||||||
|
.unwrap_or(0) as u32,
|
||||||
|
game_data
|
||||||
|
.get_primary_model_id(equipped.ears.id)
|
||||||
|
.unwrap_or(0) as u32,
|
||||||
|
game_data
|
||||||
|
.get_primary_model_id(equipped.neck.id)
|
||||||
|
.unwrap_or(0) as u32,
|
||||||
|
game_data
|
||||||
|
.get_primary_model_id(equipped.wrists.id)
|
||||||
|
.unwrap_or(0) as u32,
|
||||||
|
game_data
|
||||||
|
.get_primary_model_id(equipped.left_ring.id)
|
||||||
|
.unwrap_or(0) as u32,
|
||||||
|
game_data
|
||||||
|
.get_primary_model_id(equipped.right_ring.id)
|
||||||
|
.unwrap_or(0) as u32,
|
||||||
],
|
],
|
||||||
pos: exit_position.unwrap_or_default(),
|
pos: exit_position.unwrap_or_default(),
|
||||||
rotation: exit_rotation.unwrap_or(0.0),
|
rotation: exit_rotation.unwrap_or(0.0),
|
||||||
|
|
Loading…
Add table
Reference in a new issue