From 18b7caaa676e93f973f044ec3a9c62bdbd230e77 Mon Sep 17 00:00:00 2001 From: Dave Corley Date: Tue, 27 Feb 2024 10:35:41 -0600 Subject: [PATCH] Fix build errors from incorrect enum usage on Armor records --- src/game_object.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/game_object.rs b/src/game_object.rs index 80bcaad..3c89388 100644 --- a/src/game_object.rs +++ b/src/game_object.rs @@ -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::() + .unwrap_or_default() + .try_into() + .expect("Invalid Armor Type!"), armor_rating: get_prop("ArmorRating", entity_props) .parse::() .unwrap_or_default(), @@ -53,13 +58,17 @@ pub fn armor( }) } -fn collect_biped_objects(prop_map: &HashMap<&String, &String>) -> Vec { +fn collect_biped_objects(prop_map: &HashMap<&String, &String>) -> Vec { 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::() + .unwrap_or_default() + .try_into() + .expect("Invalid Biped Object Type!"), male_bodypart: prop_map .get(&format!("male_part{count}")) .unwrap_or(&&String::default())