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
|
||||
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 {
|
||||
if let Some(row) = page.read_row(&self.item_exh, item_id) {
|
||||
let item_row = &row[0];
|
||||
|
@ -116,13 +116,10 @@ impl GameData {
|
|||
panic!("Unexpected type!");
|
||||
};
|
||||
|
||||
return *id as u16;
|
||||
return Some(*id as u16);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: just turn this into an Option<>
|
||||
tracing::warn!("Failed to get model id for {item_id}, this is most likely a bug!");
|
||||
|
||||
0
|
||||
None
|
||||
}
|
||||
}
|
||||
|
|
|
@ -577,16 +577,36 @@ impl ZoneConnection {
|
|||
crest_enable: 0,
|
||||
pattern_invalid: 0,
|
||||
model_ids: [
|
||||
game_data.get_primary_model_id(equipped.head.id) as u32,
|
||||
game_data.get_primary_model_id(equipped.body.id) as u32,
|
||||
game_data.get_primary_model_id(equipped.hands.id) as u32,
|
||||
game_data.get_primary_model_id(equipped.legs.id) as u32,
|
||||
game_data.get_primary_model_id(equipped.feet.id) as u32,
|
||||
game_data.get_primary_model_id(equipped.ears.id) as u32,
|
||||
game_data.get_primary_model_id(equipped.neck.id) as u32,
|
||||
game_data.get_primary_model_id(equipped.wrists.id) as u32,
|
||||
game_data.get_primary_model_id(equipped.left_ring.id) as u32,
|
||||
game_data.get_primary_model_id(equipped.right_ring.id) as u32,
|
||||
game_data
|
||||
.get_primary_model_id(equipped.head.id)
|
||||
.unwrap_or(0) as u32,
|
||||
game_data
|
||||
.get_primary_model_id(equipped.body.id)
|
||||
.unwrap_or(0) as u32,
|
||||
game_data
|
||||
.get_primary_model_id(equipped.hands.id)
|
||||
.unwrap_or(0) 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()
|
||||
|
@ -729,16 +749,36 @@ impl ZoneConnection {
|
|||
look: chara_details.chara_make.customize,
|
||||
display_flags: DisplayFlag::UNK,
|
||||
models: [
|
||||
game_data.get_primary_model_id(equipped.head.id) as u32,
|
||||
game_data.get_primary_model_id(equipped.body.id) as u32,
|
||||
game_data.get_primary_model_id(equipped.hands.id) as u32,
|
||||
game_data.get_primary_model_id(equipped.legs.id) as u32,
|
||||
game_data.get_primary_model_id(equipped.feet.id) as u32,
|
||||
game_data.get_primary_model_id(equipped.ears.id) as u32,
|
||||
game_data.get_primary_model_id(equipped.neck.id) as u32,
|
||||
game_data.get_primary_model_id(equipped.wrists.id) as u32,
|
||||
game_data.get_primary_model_id(equipped.left_ring.id) as u32,
|
||||
game_data.get_primary_model_id(equipped.right_ring.id) as u32,
|
||||
game_data
|
||||
.get_primary_model_id(equipped.head.id)
|
||||
.unwrap_or(0) as u32,
|
||||
game_data
|
||||
.get_primary_model_id(equipped.body.id)
|
||||
.unwrap_or(0) as u32,
|
||||
game_data
|
||||
.get_primary_model_id(equipped.hands.id)
|
||||
.unwrap_or(0) 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(),
|
||||
rotation: exit_rotation.unwrap_or(0.0),
|
||||
|
|
Loading…
Add table
Reference in a new issue