From c5b491da67f871a457832ba7cb51b13e23897507 Mon Sep 17 00:00:00 2001 From: Zerthox Date: Thu, 14 Dec 2023 02:13:08 +0100 Subject: [PATCH] Update arcdps bindings --- Cargo.lock | 89 +++++++++++++++++++++++++++----------------- Cargo.toml | 4 +- src/combat/agent.rs | 4 +- src/combat/cast.rs | 2 +- src/history/fight.rs | 2 +- src/plugin/event.rs | 55 +++++++++++++-------------- 6 files changed, 86 insertions(+), 70 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e30a89b..d248562 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,8 +19,8 @@ dependencies = [ [[package]] name = "arc_util" -version = "0.10.5" -source = "git+https://github.com/zerthox/arcdps-utils#3ace578805d4bac20d9dfa8db024b9a790b4deb3" +version = "0.11.0" +source = "git+https://github.com/zerthox/arcdps-utils#ad18645de6d331b2e7f3eb99e76653367f052708" dependencies = [ "arcdps", "minreq", @@ -33,13 +33,13 @@ dependencies = [ [[package]] name = "arcdps" -version = "0.12.4" -source = "git+https://github.com/zerthox/arcdps-bindings#8a47beda644cb7e3faa94a250f6f18107b1ab0d4" +version = "0.13.0" +source = "git+https://github.com/zerthox/arcdps-rs#eb5711e80333aa93b2643883a8466cbaf303e3fc" dependencies = [ "arcdps-imgui", "arcdps_codegen", - "arcdps_evtc", "chrono", + "evtc", "log", "num_enum", "serde", @@ -70,7 +70,7 @@ dependencies = [ [[package]] name = "arcdps_buddy" -version = "0.6.1" +version = "0.6.2" dependencies = [ "arc_util", "arcdps", @@ -88,8 +88,8 @@ dependencies = [ [[package]] name = "arcdps_codegen" -version = "0.10.2" -source = "git+https://github.com/zerthox/arcdps-bindings#8a47beda644cb7e3faa94a250f6f18107b1ab0d4" +version = "0.10.3" +source = "git+https://github.com/zerthox/arcdps-rs#eb5711e80333aa93b2643883a8466cbaf303e3fc" dependencies = [ "cfg-if", "paste", @@ -98,16 +98,6 @@ dependencies = [ "syn", ] -[[package]] -name = "arcdps_evtc" -version = "0.6.3" -source = "git+https://github.com/zerthox/arcdps-bindings#8a47beda644cb7e3faa94a250f6f18107b1ab0d4" -dependencies = [ - "num_enum", - "serde", - "strum", -] - [[package]] name = "autocfg" version = "1.1.0" @@ -200,6 +190,17 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "evtc" +version = "0.7.0" +source = "git+https://github.com/zerthox/arcdps-rs#eb5711e80333aa93b2643883a8466cbaf303e3fc" +dependencies = [ + "memoffset", + "num_enum", + "serde", + "strum", +] + [[package]] name = "fastrand" version = "2.0.1" @@ -244,7 +245,7 @@ dependencies = [ "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows-core", + "windows-core 0.51.1", ] [[package]] @@ -296,9 +297,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "js-sys" @@ -317,9 +318,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.150" +version = "0.2.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" +checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" [[package]] name = "linux-raw-sys" @@ -349,6 +350,15 @@ version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +[[package]] +name = "memoffset" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +dependencies = [ + "autocfg", +] + [[package]] name = "minreq" version = "2.11.0" @@ -618,9 +628,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.27" +version = "0.38.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfeae074e687625746172d639330f1de242a178bf3189b51e35a7a21573513ac" +checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" dependencies = [ "bitflags 2.4.1", "errno", @@ -637,9 +647,9 @@ checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" [[package]] name = "schannel" @@ -768,9 +778,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.39" +version = "2.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +checksum = "44c8b28c477cc3bf0e7966561e3460130e1255f7a1cf71931075f1c5e7a7e269" dependencies = [ "proc-macro2", "quote", @@ -903,12 +913,12 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows" -version = "0.51.1" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9" +checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" dependencies = [ - "windows-core", - "windows-targets 0.48.5", + "windows-core 0.52.0", + "windows-targets 0.52.0", ] [[package]] @@ -920,6 +930,15 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets 0.52.0", +] + [[package]] name = "windows-sys" version = "0.48.0" @@ -1054,9 +1073,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.26" +version = "0.5.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67b5f0a4e7a27a64c651977932b9dc5667ca7fc31ac44b03ed37a0cf42fdfff" +checksum = "6c830786f7720c2fd27a1a0e27a709dbd3c4d009b56d098fc742d4f4eab91fe2" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index 4b7e828..2066d81 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,13 +1,13 @@ [package] name = "arcdps_buddy" -version = "0.6.1" +version = "0.6.2" edition = "2021" authors = ["Zerthox"] repository = "https://github.com/zerthox/arcdps-buddy" [dependencies] arc_util = { git = "https://github.com/zerthox/arcdps-utils", features = ["serde", "settings", "update"] } -arcdps = { git = "https://github.com/zerthox/arcdps-bindings", features = ["log", "serde", "strum", "unwind"] } +arcdps = { git = "https://github.com/zerthox/arcdps-rs", features = ["log", "serde", "strum", "unwind"] } log = { version = "0.4.18", features = ["release_max_level_info"] } num_enum = "0.7.1" once_cell = "1.17.2" diff --git a/src/combat/agent.rs b/src/combat/agent.rs index a88c056..c1ac70e 100644 --- a/src/combat/agent.rs +++ b/src/combat/agent.rs @@ -30,10 +30,10 @@ impl Target { } } -impl From<&Agent<'_>> for Target { +impl From<&Agent> for Target { fn from(agent: &Agent) -> Self { let kind = agent.kind(); - let name = match agent.name { + let name = match agent.name() { Some(name) if !name.is_empty() => name.into(), _ => match kind { AgentKind::Player => format!("Player:{}", agent.id), diff --git a/src/combat/cast.rs b/src/combat/cast.rs index 7e9dd21..018a218 100644 --- a/src/combat/cast.rs +++ b/src/combat/cast.rs @@ -111,7 +111,7 @@ pub struct Hit { pub target: u32, } -impl From<&Agent<'_>> for Hit { +impl From<&Agent> for Hit { fn from(target: &Agent) -> Self { Self { target: match target.kind() { diff --git a/src/history/fight.rs b/src/history/fight.rs index 25231c6..9e0dea5 100644 --- a/src/history/fight.rs +++ b/src/history/fight.rs @@ -58,7 +58,7 @@ impl Fight { if species > 2 { self.target = Some(species); self.name = agent - .and_then(|agent| agent.name) + .and_then(|agent| agent.name()) .filter(|name| !name.is_empty()) .map(Into::into); } else { diff --git a/src/plugin/event.rs b/src/plugin/event.rs index 00d3517..da03953 100644 --- a/src/plugin/event.rs +++ b/src/plugin/event.rs @@ -6,15 +6,15 @@ use crate::combat::{ skill::Skill, transfer::{Apply, Condition, Remove}, }; -use arcdps::{evtc::EventKind, Activation, Agent, BuffRemove, CombatEvent, StateChange, Strike}; +use arcdps::{evtc::EventCategory, Activation, Agent, BuffRemove, Event, StateChange, Strike}; use log::debug; impl Plugin { /// Handles a combat event from area stats. pub fn area_event( - event: Option, - src: Option, - dst: Option, + event: Option<&Event>, + src: Option<&Agent>, + dst: Option<&Agent>, skill_name: Option<&str>, _event_id: u64, _revision: u64, @@ -22,36 +22,34 @@ impl Plugin { if let Some(src) = src { if let Some(event) = event { let src_self = src.is_self != 0; - match event.kind() { - EventKind::StateChange => match event.is_statechange { + match event.categorize() { + EventCategory::StateChange => match event.get_statechange() { StateChange::LogStart => Self::lock().start_fight(event, dst), StateChange::LogNPCUpdate => Self::lock().fight_target(event, dst), StateChange::LogEnd => Self::lock().end_fight(event, dst), _ => {} }, - EventKind::Activation if src_self => { + EventCategory::Activation if src_self => { let mut plugin = Self::lock(); if let Some(time) = plugin.history.relative_time(event.time) { if plugin.data.contains(event.skill_id) { - match event.is_activation { + match event.get_activation() { Activation::Start => { plugin.cast_start(&event, skill_name, time) } - Activation::CancelFire | Activation::CancelCancel | Activation::Reset => { plugin.cast_end(&event, skill_name, time) } - _ => {} } } } } - EventKind::BuffApply => { + EventCategory::BuffApply => { if let Some(dst) = dst { let buff = event.skill_id; if let Ok(buff) = buff.try_into() { @@ -61,17 +59,17 @@ impl Plugin { } } else if let Ok(condi) = buff.try_into() { // only care about condi applies from self to other and ignore extensions - if src_self && dst.is_self == 0 && event.is_off_cycle == 0 { + if src_self && dst.is_self == 0 && event.is_offcycle == 0 { Self::lock().apply_condi(&event, condi, &dst) } } } } - EventKind::BuffRemove => { + EventCategory::BuffRemove => { if let Some(dst) = dst { // only care about removes from self to self - if event.is_buff_remove == BuffRemove::Manual + if event.get_buffremove() == BuffRemove::Manual && src_self && dst.is_self != 0 { @@ -82,7 +80,7 @@ impl Plugin { } } - EventKind::DirectDamage => { + EventCategory::Strike => { let mut plugin = Self::lock(); let is_minion = plugin.is_own_minion(&event); if src_self || is_minion { @@ -108,29 +106,28 @@ impl Plugin { } } - fn is_own_minion(&self, event: &CombatEvent) -> bool { + fn is_own_minion(&self, event: &Event) -> bool { match self.self_instance_id { Some(id) => event.src_master_instance_id == id, None => false, } } - fn start_fight(&mut self, event: CombatEvent, target: Option) { + fn start_fight(&mut self, event: &Event, target: Option<&Agent>) { let species = event.src_agent as u32; debug!("log start for {species}, {target:?}"); - self.history - .add_fight_with_target(event.time, species, target.as_ref()); + .add_fight_with_target(event.time, species, target); } - fn fight_target(&mut self, event: CombatEvent, target: Option) { + fn fight_target(&mut self, event: &Event, target: Option<&Agent>) { let species = event.src_agent as u32; debug!("log target change to {species}, {target:?}"); self.history - .update_fight_target(event.time, species, target.as_ref()); + .update_fight_target(event.time, species, target); } - fn end_fight(&mut self, event: CombatEvent, target: Option) { + fn end_fight(&mut self, event: &Event, target: Option<&Agent>) { let species = event.src_agent; debug!("log end for {species}, {target:?}"); self.history.end_latest_fight(event.time); @@ -159,15 +156,15 @@ impl Plugin { } } - fn cast_start(&mut self, event: &CombatEvent, skill_name: Option<&str>, time: i32) { + fn cast_start(&mut self, event: &Event, skill_name: Option<&str>, time: i32) { let skill = Skill::new(event.skill_id, skill_name); debug!("start {skill:?}"); let cast = Cast::from_start(time, skill, CastState::Casting); self.add_cast(cast); } - fn cast_end(&mut self, event: &CombatEvent, skill_name: Option<&str>, time: i32) { - let state = event.is_activation.into(); + fn cast_end(&mut self, event: &Event, skill_name: Option<&str>, time: i32) { + let state = event.get_activation().into(); let duration = event.value; let skill = Skill::new(event.skill_id, skill_name); @@ -181,7 +178,7 @@ impl Plugin { } } - fn apply_buff(&mut self, event: &CombatEvent, buff: Buff, src: &Agent, dst: &Agent) { + fn apply_buff(&mut self, event: &Event, buff: Buff, src: &Agent, dst: &Agent) { if src.is_self != 0 || self.is_own_minion(event) { if let Some((time, fight)) = self.history.fight_and_time(event.time) { // TODO: "effective" duration excluding overstack? @@ -192,14 +189,14 @@ impl Plugin { } } - fn apply_condi(&mut self, event: &CombatEvent, condi: Condition, target: &Agent) { + fn apply_condi(&mut self, event: &Event, condi: Condition, target: &Agent) { if let Some((time, fight)) = self.history.fight_and_time(event.time) { let apply = Apply::new(time, condi, event.value, target.into()); fight.data.transfers.add_apply(apply); } } - fn remove_buff(&mut self, event: &CombatEvent, condi: Condition) { + fn remove_buff(&mut self, event: &Event, condi: Condition) { if let Some((time, fight)) = self.history.fight_and_time(event.time) { let remove = Remove::new(time, condi, event.value); fight.data.transfers.add_remove(remove) @@ -208,7 +205,7 @@ impl Plugin { fn strike( &mut self, - event: &CombatEvent, + event: &Event, is_minion: bool, skill_name: Option<&str>, target: &Agent,