diff options
author | Daniel Schadt <kingdread@gmx.de> | 2018-04-23 15:27:07 +0200 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2018-04-23 15:27:07 +0200 |
commit | 258bb123b36453587b48742f3436fe67f832f6a9 (patch) | |
tree | f63570774009f51ce8dfd80afdfda8b8a605d338 | |
parent | 4d4c6b6690d8ee1abff68d87fc6d0d0469412101 (diff) | |
download | evtclib-258bb123b36453587b48742f3436fe67f832f6a9.tar.gz evtclib-258bb123b36453587b48742f3436fe67f832f6a9.tar.bz2 evtclib-258bb123b36453587b48742f3436fe67f832f6a9.zip |
run rustfmt
-rw-r--r-- | src/event.rs | 66 | ||||
-rw-r--r-- | src/lib.rs | 34 |
2 files changed, 44 insertions, 56 deletions
diff --git a/src/event.rs b/src/event.rs index 83c569e..f9489e6 100644 --- a/src/event.rs +++ b/src/event.rs @@ -9,34 +9,19 @@ use num_traits::FromPrimitive; pub enum EventKind { // State change events /// The agent has entered combat. - EnterCombat { - agent_addr: u64, - subgroup: u64, - }, + EnterCombat { agent_addr: u64, subgroup: u64 }, /// The agent has left combat. - ExitCombat { - agent_addr: u64, - }, + ExitCombat { agent_addr: u64 }, /// The agent is now alive. - ChangeUp { - agent_addr: u64, - }, + ChangeUp { agent_addr: u64 }, /// The agent is now downed. - ChangeDown { - agent_addr: u64, - }, + ChangeDown { agent_addr: u64 }, /// The agent is now dead. - ChangeDead { - agent_addr: u64, - }, + ChangeDead { agent_addr: u64 }, /// The agent is now in tracking range. - Spawn { - agent_addr: u64, - }, + Spawn { agent_addr: u64 }, /// The agent has left the tracking range. - Despawn { - agent_addr: u64, - }, + Despawn { agent_addr: u64 }, /// The agent has reached a health treshold. HealthUpdate { agent_addr: u64, @@ -54,36 +39,19 @@ pub enum EventKind { local_timestamp: u32, }, /// The agent has swapped the weapon set. - WeaponSwap { - agent_addr: u64, - set: WeaponSet, - }, + WeaponSwap { agent_addr: u64, set: WeaponSet }, /// The given agent has its max health changed. - MaxHealthUpdate { - agent_addr: u64, - max_health: u64, - }, + MaxHealthUpdate { agent_addr: u64, max_health: u64 }, /// The given agent is the point-of-view. - PointOfView { - agent_addr: u64, - }, + PointOfView { agent_addr: u64 }, /// The given language is the text language. - Language { - language: raw::Language, - }, + Language { language: raw::Language }, /// The log was made with the given game build. - Build { - build: u64, - }, + Build { build: u64 }, /// The shard id of the server. - ShardId { - shard_id: u64, - }, + ShardId { shard_id: u64 }, /// A reward has been awarded. - Reward { - reward_id: u64, - reward_type: i32, - }, + Reward { reward_id: u64, reward_type: i32 }, /// A skill has been used. SkillUse { @@ -214,7 +182,7 @@ impl Event { CbtStateChange::None => if let Some(kind) = check_activation(raw_event) { kind } else { - return None + return None; }, }; Some(Event { @@ -274,7 +242,9 @@ fn check_damage(raw_event: &raw::CbtEvent) -> Option<EventKind> { damage: raw_event.value, result: raw_event.result, }) - } else if raw_event.buff == 1 && raw_event.buff_dmg != 0 && raw_event.dst_agent != 0 && raw_event.value == 0 { + } else if raw_event.buff == 1 && raw_event.buff_dmg != 0 && raw_event.dst_agent != 0 + && raw_event.value == 0 + { Some(EventKind::ConditionTick { source_agent_addr: raw_event.src_agent, destination_agent_addr: raw_event.dst_agent, @@ -38,7 +38,11 @@ pub enum AgentKind { #[derive(Debug, Clone, PartialEq, Eq)] pub enum AgentName { Single(String), - Player { character_name: String, account_name: String, subgroup: u8 } + Player { + character_name: String, + account_name: String, + subgroup: u8, + }, } /// An agent. @@ -91,16 +95,25 @@ fn setup_agents(data: &raw::Evtc) -> Result<Vec<Agent>, EvtcError> { } else if raw_agent.is_gadget() { AgentKind::Gadget(raw_agent.prof as u16) } else if raw_agent.is_player() { - AgentKind::Player { profession: raw_agent.prof, elite: raw_agent.is_elite } + AgentKind::Player { + profession: raw_agent.prof, + elite: raw_agent.is_elite, + } } else { return Err(EvtcError::InvalidData); }; let name = if raw_agent.is_player() { - let first = raw_agent.name.iter().cloned() + let first = raw_agent + .name + .iter() + .cloned() .take_while(|c| *c != 0) .collect::<Vec<_>>(); - let second = raw_agent.name.iter().cloned() + let second = raw_agent + .name + .iter() + .cloned() .skip(first.len() + 1) .take_while(|c| *c != 0) .collect::<Vec<_>>(); @@ -111,7 +124,10 @@ fn setup_agents(data: &raw::Evtc) -> Result<Vec<Agent>, EvtcError> { subgroup: third, } } else { - let name = raw_agent.name.iter().cloned() + let name = raw_agent + .name + .iter() + .cloned() .take_while(|c| *c != 0) .collect::<Vec<_>>(); AgentName::Single(String::from_utf8(name)?) @@ -139,7 +155,7 @@ fn setup_agents(data: &raw::Evtc) -> Result<Vec<Agent>, EvtcError> { fn get_agent_by_addr(agents: &mut [Agent], addr: u64) -> Option<&mut Agent> { for agent in agents { if agent.addr == addr { - return Some(agent) + return Some(agent); } } None @@ -150,7 +166,7 @@ fn set_agent_awares(data: &raw::Evtc, agents: &mut [Agent]) -> Result<(), EvtcEr if event.is_statechange == raw::CbtStateChange::None { if let Some(current_agent) = get_agent_by_addr(agents, event.src_agent) { current_agent.instance_id = event.src_instid; - if current_agent.first_aware == 0 { + if current_agent.first_aware == 0 { current_agent.first_aware = event.time; } current_agent.last_aware = event.time; @@ -165,7 +181,9 @@ fn set_agent_masters(data: &raw::Evtc, agents: &mut [Agent]) -> Result<(), EvtcE if event.src_master_instid != 0 { let mut master_addr = None; for agent in &*agents { - if agent.instance_id == event.src_master_instid && agent.first_aware < event.time && event.time < agent.last_aware { + if agent.instance_id == event.src_master_instid && agent.first_aware < event.time + && event.time < agent.last_aware + { master_addr = Some(agent.addr); break; } |