diff options
author | Daniel <kingdread@gmx.de> | 2020-07-24 16:22:31 +0200 |
---|---|---|
committer | Daniel <kingdread@gmx.de> | 2020-07-24 16:31:25 +0200 |
commit | e4bcc51d10919a6b68d1f6d115a231ce059b4b46 (patch) | |
tree | 9144f33a54c26c30bda6c4b8b29ffb26c3a0377b | |
parent | be650c960106e5231a83398ada7da9f7fca03c53 (diff) | |
download | raidgrep-e4bcc51d10919a6b68d1f6d115a231ce059b4b46.tar.gz raidgrep-e4bcc51d10919a6b68d1f6d115a231ce059b4b46.tar.bz2 raidgrep-e4bcc51d10919a6b68d1f6d115a231ce059b4b46.zip |
use Analyzer/span from evtclib
This is better than re-implementing these functions, especially for the
fight outcome as it is more accurate.
-rw-r--r-- | CHANGELOG.md | 3 | ||||
-rw-r--r-- | src/main.rs | 42 |
2 files changed, 27 insertions, 18 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 9822318..7c09a27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ All notable changes to this project will be documented in this file. - The exit code will now be dependent on whether logs matching the filter were found or not. +### Fixed +- Fight outcomes for some logs (2nd/3rd/... kill in a week) have been fixed. + ## 1.2.0 - 2020-05-16 ### Added - An indicator for whether a fight was done with Challenge Mote activated. diff --git a/src/main.rs b/src/main.rs index 674d128..0915f42 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,7 +17,7 @@ use structopt::StructOpt; use walkdir::{DirEntry, WalkDir}; use evtclib::raw::parser::PartialEvtc; -use evtclib::{Boss, Event, EventKind, Log}; +use evtclib::{Boss, EventKind, Log, Outcome}; mod fexpr; mod filters; @@ -212,15 +212,13 @@ pub enum FightOutcome { Wipe, } -/// A stripped version of [`LogResult`][LogResult] that is available early in the parsing process. -/// -/// This can be used by filters to filter out logs early, before they will be fully parsed. -#[derive(Debug, Clone)] -pub struct EarlyLogResult { - /// The path to the log file. - log_file: PathBuf, - /// The partially parsed evtc. - evtc: PartialEvtc, +impl From<Outcome> for FightOutcome { + fn from(outcome: Outcome) -> Self { + match outcome { + Outcome::Success => FightOutcome::Success, + Outcome::Failure => FightOutcome::Wipe, + } + } } impl FromStr for FightOutcome { @@ -235,6 +233,17 @@ impl FromStr for FightOutcome { } } +/// A stripped version of [`LogResult`][LogResult] that is available early in the parsing process. +/// +/// This can be used by filters to filter out logs early, before they will be fully parsed. +#[derive(Debug, Clone)] +pub struct EarlyLogResult { + /// The path to the log file. + log_file: PathBuf, + /// The partially parsed evtc. + evtc: PartialEvtc, +} + enum ZipWrapper<R: Read + Seek> { Raw(Option<R>), Zipped(zip::ZipArchive<R>), @@ -592,16 +601,13 @@ fn get_guild_mapping(log: &Log) -> HashMap<u64, String> { /// Get the outcome of the fight. fn get_fight_outcome(log: &Log) -> FightOutcome { - if log.was_rewarded() { - FightOutcome::Success - } else { - FightOutcome::Wipe - } + log.analyzer() + .and_then(|a| a.outcome()) + .map(Into::into) + .unwrap_or(FightOutcome::Wipe) } /// Get the duration of the fight. fn get_fight_duration(log: &Log) -> Duration { - let start = log.events().first().map(Event::time).unwrap_or(0) as i64; - let end = log.events().last().map(Event::time).unwrap_or(0) as i64; - Duration::milliseconds(end - start) + Duration::milliseconds(log.span() as i64) } |