From 7bf28dc7b3df4d8663c97bedadbfb09f48e9db39 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Fri, 11 Dec 2020 22:02:53 +0100 Subject: add StackActive and StackReset events As it turns out, the padding bytes are not just padding, but for some events they contain useful information. Therefore, we've adjusted the parser to save those bytes (if available). --- src/event.rs | 23 ++++++++++++++++++++--- src/raw/parser.rs | 7 +++++-- src/raw/types.rs | 2 ++ 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/event.rs b/src/event.rs index 8004002..7cc5010 100644 --- a/src/event.rs +++ b/src/event.rs @@ -135,6 +135,16 @@ pub enum EventKind { duration: i32, }, + /// Mark the given buff stack as active. + StackActive { agent_addr: u64, stack_id: u32 }, + + /// Reset the duration of the given stack. + StackReset { + agent_addr: u64, + stack_id: u32, + duration: i32, + }, + /// Position of the agent has changed. Position { agent_addr: u64, @@ -399,10 +409,17 @@ impl TryFrom<&raw::CbtEvent> for Event { // The README says "internal use, won't see anywhere", so if we find one, we treat it // as an error. CbtStateChange::ReplInfo => return Err(FromRawEventError::UnexpectedReplInfo), + CbtStateChange::StackActive => EventKind::StackActive { + agent_addr: raw_event.src_agent, + stack_id: raw_event.dst_agent as u32, + }, + CbtStateChange::StackReset => EventKind::StackReset { + agent_addr: raw_event.src_agent, + stack_id: raw_event.padding_end, + duration: raw_event.value, + }, // XXX: implement proper handling of those events! - CbtStateChange::StackActive - | CbtStateChange::StackReset - | CbtStateChange::BuffInfo + CbtStateChange::BuffInfo | CbtStateChange::BuffFormula | CbtStateChange::SkillInfo | CbtStateChange::SkillTiming diff --git a/src/raw/parser.rs b/src/raw/parser.rs index cac803e..4622473 100644 --- a/src/raw/parser.rs +++ b/src/raw/parser.rs @@ -388,6 +388,7 @@ pub fn parse_event_rev0(mut input: R) -> ParseResult { is_flanking, is_shields, is_offcycle: false, + padding_end: 0, }) } @@ -424,8 +425,9 @@ pub fn parse_event_rev1(mut input: R) -> ParseResult { let is_shields = input.read_u8()? != 0; let is_offcycle = input.read_u8()? != 0; - // Four more bytes of internal tracking garbage. - input.read_u32::()?; + // Should only be padding in most cases, but could also be useful for some events (like + // STACKRESET). + let padding_end = input.read_u32::()?; Ok(CbtEvent { time, @@ -451,6 +453,7 @@ pub fn parse_event_rev1(mut input: R) -> ParseResult { is_flanking, is_shields, is_offcycle, + padding_end, }) } diff --git a/src/raw/types.rs b/src/raw/types.rs index 514a8d2..0dea08f 100644 --- a/src/raw/types.rs +++ b/src/raw/types.rs @@ -370,6 +370,8 @@ pub struct CbtEvent { pub is_shields: bool, /// False if buff dmg happened during tick, true otherwise. pub is_offcycle: bool, + /// Padding for some events. + pub padding_end: u32, } /// An agent. -- cgit v1.2.3