Skip to content

Commit

Permalink
Fix build errors from incorrect enum usage on Armor records
Browse files Browse the repository at this point in the history
  • Loading branch information
magicaldave committed Feb 27, 2024
1 parent d755d38 commit 18b7caa
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/game_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ pub fn armor(
mesh: mesh_name.to_owned(),
icon: get_prop("Icon", entity_props),
enchanting: get_prop("Enchantment", entity_props),
biped_objects: collect_biped_objects(entity_props),
data: ArmorData {
armor_type: get_prop("ArmorType", entity_props),
armor_type: get_prop("ArmorType", entity_props)
.parse::<u32>()
.unwrap_or_default()
.try_into()
.expect("Invalid Armor Type!"),
armor_rating: get_prop("ArmorRating", entity_props)
.parse::<u32>()
.unwrap_or_default(),
Expand All @@ -53,13 +58,17 @@ pub fn armor(
})
}

fn collect_biped_objects(prop_map: &HashMap<&String, &String>) -> Vec<String> {
fn collect_biped_objects(prop_map: &HashMap<&String, &String>) -> Vec<BipedObject> {
let mut biped_objects = Vec::new();

for count in 1..8 {
match prop_map.get(&format!("SlotType{count}")) {
Some(biped_object) => biped_objects.push(BipedObject {
biped_object_type: biped_object,
biped_object_type: biped_object
.parse::<u8>()
.unwrap_or_default()
.try_into()
.expect("Invalid Biped Object Type!"),
male_bodypart: prop_map
.get(&format!("male_part{count}"))
.unwrap_or(&&String::default())
Expand Down

0 comments on commit 18b7caa

Please sign in to comment.