diff --git a/Cargo.lock b/Cargo.lock index 813ed2f..9b1dfd6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -778,9 +778,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.36" +version = "2.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e02e55d62894af2a08aca894c6577281f76769ba47c94d5756bec8ac6e7373" +checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" dependencies = [ "proc-macro2", "quote", diff --git a/build.rs b/build.rs index f51dc40..2a1c444 100644 --- a/build.rs +++ b/build.rs @@ -43,6 +43,7 @@ fn main() { } = skill; let hits = quote_option(hits); let expected = quote_option(expected); + let max_duration = quote_option(max_duration); quote! { SkillDef { id: #id, diff --git a/src/data/structs.rs b/src/data/structs.rs index aec8601..479e5ff 100644 --- a/src/data/structs.rs +++ b/src/data/structs.rs @@ -4,6 +4,9 @@ use serde::{Deserialize, Serialize}; // TODO: instead of hits allow counting buff apply? // TODO: support instant casts with buff apply? +/// Extra error margin for max duration. +const DURATION_EPSILON: i32 = 500; + /// Skill information. #[derive(Debug, Clone)] pub struct SkillInfo { @@ -37,7 +40,9 @@ impl From for SkillInfo { max, expected: expected.unwrap_or((max + 1) / 2), }), - max_duration, + max_duration: max_duration + .map(|dur| dur + DURATION_EPSILON) + .unwrap_or(i32::MAX), minion, } } @@ -74,18 +79,13 @@ pub struct SkillDef { pub expected: Option, /// Maximum duration (ms) to count as one cast. - #[serde(default = "default_as_max")] - pub max_duration: i32, + pub max_duration: Option, /// Whether to include minion hits. #[serde(default)] pub minion: bool, } -const fn default_as_true() -> bool { +fn default_as_true() -> bool { true } - -const fn default_as_max() -> i32 { - i32::MAX -} diff --git a/src/plugin/event.rs b/src/plugin/event.rs index b8edae3..55b3185 100644 --- a/src/plugin/event.rs +++ b/src/plugin/event.rs @@ -8,9 +8,6 @@ use crate::combat::{ use arcdps::{evtc::EventKind, Activation, Agent, CombatEvent, StateChange, Strike}; use log::debug; -/// Extra error margin for max duration. -const DURATION_EPSILON: i32 = 500; - impl Plugin { /// Handles a combat event from area stats. pub fn area_event( @@ -205,7 +202,7 @@ impl Plugin { // replace skill id skill.id = info.id; - let max = info.max_duration + DURATION_EPSILON; + let max = info.max_duration; match self.latest_cast_mut(skill.id) { Some(cast) if time - cast.time <= max => { cast.hit(target);