add in type checks for existing blocks

This commit is contained in:
endernon 2025-01-01 20:20:27 +00:00
parent a2c6317474
commit 700f40fba7

View file

@ -118,37 +118,66 @@ fn cook(out: &mut Vec<u8>, debug_mode: &bool, ver: TransformVersion, json_config
fr_ver: ver, fr_ver: ver,
}; };
// StartData and TypeData are always present // ENCODE: StartData and TypeData, ALWAYS
encode_startdata(&mut fr_params); encode_startdata(&mut fr_params);
encode_typedata(&mut fr_params, json_config.item_type); encode_typedata(&mut fr_params, json_config.item_type);
// ENCODE: NameData // ENCODE: NameData, if ItemType is Gear, Tome, Charm
if let Some(real_name) = json_config.name { match json_config.item_type {
encode_namedata(&mut fr_params, &real_name) ItemTypeDeser::Gear | ItemTypeDeser::Tome | ItemTypeDeser::Charm => {
} if let Some(real_name) = json_config.name {
encode_namedata(&mut fr_params, &real_name)
// json identification data handling for type GEAR (0) }
// only occurs if identifications block is present },
if let Some(real_ids) = json_config.ids { _ => {}
encode_ids(&mut fr_params, real_ids, idsmap)
}
// json powder data handling
if let Some(real_powders) = json_config.powders {
encode_powder(&mut fr_params, real_powders)
} }
if let Some(rerollcount) = json_config.rerolls { // ENCODE: IdentificationData
// rerolldata match json_config.item_type {
encode_reroll(&mut fr_params, rerollcount) ItemTypeDeser::Gear | ItemTypeDeser::Tome | ItemTypeDeser::Charm => {
}; if let Some(real_ids) = json_config.ids {
encode_ids(&mut fr_params, real_ids, idsmap)
if let Some(shiny) = json_config.shiny { }
encode_shiny(&mut fr_params, shiny, json_shiny) },
_ => {}
} }
// EndData is ALWAYS present. If its gone it literally doesn't work
// ENCODE: PowderData if ItemType is Gear, CraftedGear
match json_config.item_type {
ItemTypeDeser::Gear | ItemTypeDeser::CraftedGear => {
if let Some(real_powders) = json_config.powders {
encode_powder(&mut fr_params, real_powders)
}
},
_ => {}
}
// ENCODE: RerollData if ItemType is Gear, Tome, Charm
match json_config.item_type {
ItemTypeDeser::Gear | ItemTypeDeser::Tome | ItemTypeDeser::Charm => {
if let Some(rerollcount) = json_config.rerolls {
// rerolldata
encode_reroll(&mut fr_params, rerollcount)
}
},
_ => {}
}
// ENCODE: ShinyData if ItemType is Gear
match json_config.item_type {
ItemTypeDeser::Gear => {
if let Some(shiny) = json_config.shiny {
encode_shiny(&mut fr_params, shiny, json_shiny)
}
},
_ => {}
}
// ENCODE: EndData, ALWAYS
encode_enddata(&mut fr_params); encode_enddata(&mut fr_params);
Ok(()) Ok(())