diff --git a/Cargo.lock b/Cargo.lock index 9bbedca..944a480 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -543,8 +543,8 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reliquary" -version = "3.0.0" -source = "git+https://github.com/IceDynamix/reliquary?tag=v3.0.0#6ab4524b01ce7c02b731ba74877e9edb5060aa7c" +version = "3.1.0" +source = "git+https://github.com/IceDynamix/reliquary?tag=v3.1.0#0c96b3c1cdaf589bb9d48f21d5d7bd5d25cd352c" dependencies = [ "base64", "etherparse", @@ -577,7 +577,7 @@ dependencies = [ [[package]] name = "reliquary-proc-macro" version = "0.1.0" -source = "git+https://github.com/IceDynamix/reliquary?tag=v3.0.0#6ab4524b01ce7c02b731ba74877e9edb5060aa7c" +source = "git+https://github.com/IceDynamix/reliquary?tag=v3.1.0#0c96b3c1cdaf589bb9d48f21d5d7bd5d25cd352c" dependencies = [ "quote", "syn", diff --git a/Cargo.toml b/Cargo.toml index 607575f..b37379c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ ureq = { version = "2.10.1", features = ["json"] } [dependencies.reliquary] git = "https://github.com/IceDynamix/reliquary" -tag = "v3.0.0" +tag = "v3.1.0" [profile.release] opt-level = "z" # optimize for size diff --git a/src/export/fribbels.rs b/src/export/fribbels.rs index 945514f..746fc30 100644 --- a/src/export/fribbels.rs +++ b/src/export/fribbels.rs @@ -57,6 +57,7 @@ pub struct OptimizerExporter { relics: Vec, characters: Vec, multipath_characters: Vec, + multipath_base_avatars: HashMap, } impl OptimizerExporter { @@ -69,6 +70,7 @@ impl OptimizerExporter { relics: vec![], characters: vec![], multipath_characters: vec![], + multipath_base_avatars: HashMap::new(), } } @@ -76,8 +78,6 @@ impl OptimizerExporter { self.uid = Some(uid); } - // TODO: add_multipath_avatars - pub fn add_inventory(&mut self, bag: GetBagScRsp) { let mut relics: Vec = bag.relic_list.iter() .filter_map(|r| export_proto_relic(&self.database, r)) @@ -95,13 +95,18 @@ impl OptimizerExporter { } pub fn add_characters(&mut self, characters: GetAvatarDataScRsp) { - let mut characters: Vec = characters.avatar_list.iter() - .filter(|a| MultiPathAvatarType::from_i32(a.base_avatar_id as i32).is_none() ) // skip multipath characters + let (characters, multipath_characters) = characters.avatar_list.iter() + .partition::, _>(|a| MultiPathAvatarType::from_i32(a.base_avatar_id as i32).is_none() ); + + let mut characters: Vec = characters.iter() .filter_map(|char| export_proto_character(&self.database, char)) .collect(); info!(num=characters.len(), "found characters"); self.characters.append(&mut characters); + + info!(num=multipath_characters.len(), "found multipath base avatars"); + self.multipath_base_avatars.extend(multipath_characters.into_iter().map(|c| (c.base_avatar_id, c.clone()))); } pub fn add_multipath_characters(&mut self, characters: GetMultiPathAvatarInfoScRsp) { @@ -121,6 +126,18 @@ impl OptimizerExporter { info!(num=characters.len(), "found multipath characters"); self.multipath_characters.append(&mut characters); } + + pub fn finalize_multipath_characters(&mut self) { + // Fetch level & ascension + for character in self.multipath_characters.iter_mut() { + if let Some(config) = self.database.multipath_avatar_config.get(&character.id.parse().unwrap()) { + if let Some(base_avatar) = self.multipath_base_avatars.get(&config.BaseAvatarID) { + character.level = base_avatar.level; + character.ascension = base_avatar.promotion; + } + } + } + } } impl Exporter for OptimizerExporter { @@ -192,7 +209,7 @@ impl Exporter for OptimizerExporter { } #[instrument(skip_all)] - fn export(self) -> Self::Export { + fn export(mut self) -> Self::Export { info!("exporting collected data"); if self.trailblazer.is_none() { @@ -219,6 +236,8 @@ impl Exporter for OptimizerExporter { warn!("characters were not recorded"); } + self.finalize_multipath_characters(); + Export { source: "reliquary_archiver", build: env!("CARGO_PKG_VERSION"), @@ -240,6 +259,7 @@ pub struct Database { avatar_config: AvatarConfigMap, avatar_skill_tree_config: AvatarSkillTreeConfigMap, equipment_config: EquipmentConfigMap, + multipath_avatar_config: MultiplePathAvatarConfigMap, relic_config: RelicConfigMap, relic_set_config: RelicSetConfigMap, relic_main_affix_config: RelicMainAffixConfigMap, @@ -256,6 +276,7 @@ impl Database { avatar_config: Self::load_online_config(), avatar_skill_tree_config: Self::load_online_config(), equipment_config: Self::load_online_config(), + multipath_avatar_config: Self::load_online_config(), relic_config: Self::load_online_config(), relic_set_config: Self::load_online_config(), relic_main_affix_config: Self::load_online_config(),