diff --git a/src/encode.rs b/src/encode.rs index ec847c6..99de242 100644 --- a/src/encode.rs +++ b/src/encode.rs @@ -56,7 +56,7 @@ pub fn encode_typedata_custom( } pub fn encode_duradata( general_params: &mut FuncParams, - real_dura: Durability, + real_dura: &Durability, ) -> Result<(), Errorfr> { let effect_strength_fr: u8; // but actually it should be 0 to 100, not 0 to 255. But i dunno how to use u7 data type. if let Some(effstr) = real_dura.effect_strength { @@ -155,7 +155,7 @@ pub fn encode_namedata(general_params: &mut FuncParams, real_name: &str) { } pub fn encode_iddata( general_params: &mut FuncParams, - real_ids: Vec, + real_ids: &Vec, idsmap: HashMap, ) { let mut idvec = Vec::new(); @@ -191,7 +191,7 @@ pub fn encode_iddata( .encode(general_params.fr_ver, general_params.fr_out) .unwrap(); } -pub fn encode_powderdata(general_params: &mut FuncParams, real_powders: Vec) { +pub fn encode_powderdata(general_params: &mut FuncParams, real_powders: &Vec) { let mut powdervec = Vec::new(); for eachpowder in real_powders { let powderamount: u8 = eachpowder.amount.unwrap_or(1); @@ -240,8 +240,8 @@ pub fn encode_rerolldata(general_params: &mut FuncParams, rerollcount: u8) { } pub fn encode_shinydata( general_params: &mut FuncParams, - shiny: Shinyjson, - json_shiny: Vec, + shiny: &Shinyjson, + json_shiny: &Vec, ) { let mut realshinykey: u8; let _shinykey = &shiny.key; diff --git a/src/main.rs b/src/main.rs index aeb4f76..dd431ab 100644 --- a/src/main.rs +++ b/src/main.rs @@ -132,7 +132,7 @@ fn cook( // ENCODE: CustomGearTypeData / CustomConsumableTypeData match json_config.item_type { ItemTypeDeser::CraftedGear | ItemTypeDeser::CraftedConsu => { - if let Some(real_crafted_type) = json_config.crafted_type { + if let Some(real_crafted_type) = &json_config.crafted_type { encode_typedata_custom(&mut fr_params, &real_crafted_type)?; } else { return Err(JsonNotFoundCraftedType); @@ -144,7 +144,7 @@ fn cook( // ENCODE: NameData, if ItemType is Gear, Tome, Charm match json_config.item_type { ItemTypeDeser::Gear | ItemTypeDeser::Tome | ItemTypeDeser::Charm => { - if let Some(real_name) = json_config.name { + if let Some(real_name) = &json_config.name { encode_namedata(&mut fr_params, &real_name) } else { return Err(Errorfr::JsonNotFoundName); @@ -156,7 +156,7 @@ fn cook( // ENCODE: IdentificationData match json_config.item_type { ItemTypeDeser::Gear | ItemTypeDeser::Tome | ItemTypeDeser::Charm => { - if let Some(real_ids) = json_config.ids { + if let Some(real_ids) = &json_config.ids { encode_iddata(&mut fr_params, real_ids, idsmap) } } @@ -166,7 +166,7 @@ fn cook( // ENCODE: DurabilityData (REQUIRED for CraftedGear) match json_config.item_type { ItemTypeDeser::CraftedGear => { - if let Some(real_dura) = json_config.durability { + if let Some(real_dura) = &json_config.durability { encode_duradata(&mut fr_params, real_dura)?; } else { return Err(Errorfr::JsonNotFoundDura); @@ -190,7 +190,7 @@ fn cook( // ENCODE: PowderData if ItemType is Gear, CraftedGear match json_config.item_type { ItemTypeDeser::Gear | ItemTypeDeser::CraftedGear => { - if let Some(real_powders) = json_config.powders { + if let Some(real_powders) = &json_config.powders { encode_powderdata(&mut fr_params, real_powders) } } @@ -211,8 +211,8 @@ fn cook( // ENCODE: ShinyData if ItemType is Gear match json_config.item_type { ItemTypeDeser::Gear => { - if let Some(shiny) = json_config.shiny { - encode_shinydata(&mut fr_params, shiny, json_shiny) + if let Some(shiny) = &json_config.shiny { + encode_shinydata(&mut fr_params, shiny, &json_shiny) } } _ => {}