diff --git a/crates/openlogs-analysis/src/fight.rs b/crates/openlogs-analysis/src/fight.rs index d581bb3..fedf9bc 100644 --- a/crates/openlogs-analysis/src/fight.rs +++ b/crates/openlogs-analysis/src/fight.rs @@ -320,8 +320,9 @@ pub struct Damage { /// For a `SWING_DAMAGE_LANDED`: the index in [`Fight::events`] of the hit's attacker-side /// line, set by [`crate::pair_melee_lines`]. pub attacker_line: Option, - /// A swing whose `SWING_DAMAGE_LANDED` copy is logged after the pull's end. - pub lands_after_end: bool, + /// A swing the pull shows no `SWING_DAMAGE_LANDED` copy of, in a pull whose log writes + /// them; set by [`crate::pair_melee_lines`]. + pub unlanded: bool, } impl Damage { @@ -349,6 +350,8 @@ pub struct Missed { /// Prevented amount for partial misses, else 0. pub amount_missed: u64, pub critical: bool, + /// Like [`Damage::unlanded`], for a swing a shield took whole. + pub unlanded: bool, } #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] diff --git a/crates/openlogs-analysis/src/lib.rs b/crates/openlogs-analysis/src/lib.rs index 6170da6..5a088ef 100644 --- a/crates/openlogs-analysis/src/lib.rs +++ b/crates/openlogs-analysis/src/lib.rs @@ -66,8 +66,7 @@ pub use interrupts::{ }; pub use links::AbilityLink; pub use load::{ - LANDED_TAIL_BYTES, load_fight, load_fight_file, load_fight_slice, load_fight_slice_with, - pair_melee_lines, + load_fight, load_fight_file, load_fight_slice, load_fight_slice_with, pair_melee_lines, }; pub use meter::{Meter, MeterCategory, MeterEntry, MeterKey, MeterRow, meter}; pub use options::{FilterOption, OptionValue, SpellVariant, filter_options}; diff --git a/crates/openlogs-analysis/src/load.rs b/crates/openlogs-analysis/src/load.rs index 315ce04..e7de0df 100644 --- a/crates/openlogs-analysis/src/load.rs +++ b/crates/openlogs-analysis/src/load.rs @@ -24,12 +24,8 @@ pub fn load_fight(data: &[u8], summary: &FightSummary) -> Fight { load_fight_slice(data, 0, summary) } -/// How far past a fight's end a part of the log should reach, so that the landed copies of -/// its last swings are in it. -pub const LANDED_TAIL_BYTES: u64 = 2 * 1024 * 1024; - /// Loads one fight from a part of the log that starts at byte `base_offset` and covers the -/// fight from its prelude to its end, plus up to [`LANDED_TAIL_BYTES`] after it. +/// fight from its prelude to its end. pub fn load_fight_slice(data: &[u8], base_offset: u64, summary: &FightSummary) -> Fight { load_slice(data, base_offset, summary, Actors::new(), true) } @@ -69,13 +65,11 @@ fn load_slice( Err(_) => builder.fight.broken_lines += 1, } } - let late = builder.landed_after_end(&data[end..], &mut fields); let mut fight = builder.finish(); // A combat pull's specs come from `COMBATANT_INFO` before its range, which only the index // read; a spec logged inside the range wins. apply_roster(&mut fight, &summary.roster); - let unpaired = pair_landed_copies(&mut fight); - mark_swings_landing_after_end(&mut fight, unpaired, &late); + pair_melee_lines(&mut fight); note_delayed_hits(&mut fight); fight } @@ -92,14 +86,6 @@ fn apply_roster(fight: &mut Fight, roster: &[RosterEntry]) { } } -/// A `SWING_DAMAGE_LANDED` logged after the fight's end, of units the fight knows. -struct LateLanded { - t: i32, - source: ActorId, - target: ActorId, - melee_total: u64, -} - enum MeleeLine { /// `SWING_DAMAGE`, or `SWING_MISSED` ABSORB for a hit a shield took whole. Attacker, @@ -120,24 +106,35 @@ fn melee_line(event: &Event) -> Option<(MeleeLine, u64)> { } } -/// Pairs each melee hit's landed copy with its attacker-side line, as loading does, for a -/// fight built without loading it. A landed copy left without one is the hit itself. +/// Pairs each melee hit's landed copy with its attacker-side line and marks the swings left +/// without one, as loading does, for a fight built without loading it. A landed copy left +/// without an attacker-side line is the hit itself. pub fn pair_melee_lines(fight: &mut Fight) { - pair_landed_copies(fight); + let unlanded = pair_landed_copies(fight); + for line in unlanded { + match &mut fight.events[line].kind { + EventKind::Damage(damage) => damage.unlanded = true, + EventKind::Missed(missed) => missed.unlanded = true, + _ => {} + } + } } /// Pairs each landed copy with its attacker-side line, which the log writes up to /// [`LANDED_MATCH_MS`] before or after it, and records that line in the copy. Returns the -/// attacker-side lines of the last [`LANDED_MATCH_MS`] that are still unpaired. -fn pair_landed_copies(fight: &mut Fight) -> VecDeque<(usize, u64)> { +/// attacker-side lines left without a copy; none when the pull has no landed copy at all, as +/// in logs that do not write them. +fn pair_landed_copies(fight: &mut Fight) -> Vec { let mut attackers: VecDeque<(usize, u64)> = VecDeque::new(); let mut landed: VecDeque<(usize, u64)> = VecDeque::new(); + let mut unlanded = Vec::new(); let mut pairs = Vec::new(); + let mut any_landed = false; for index in 0..fight.events.len() { let event = &fight.events[index]; let expired = |&(line, _): &(usize, u64)| event.t - fight.events[line].t > LANDED_MATCH_MS; - while attackers.front().is_some_and(expired) { - attackers.pop_front(); + while let Some(attacker) = attackers.pop_front_if(|a| expired(a)) { + unlanded.push(attacker.0); } while landed.front().is_some_and(expired) { landed.pop_front(); @@ -147,7 +144,10 @@ fn pair_landed_copies(fight: &mut Fight) -> VecDeque<(usize, u64)> { }; let (unpaired, other_side) = match side { MeleeLine::Attacker => (&mut attackers, &mut landed), - MeleeLine::Landed => (&mut landed, &mut attackers), + MeleeLine::Landed => { + any_landed = true; + (&mut landed, &mut attackers) + } }; let pair = |&(line, other_total): &(usize, u64)| { let other = &fight.events[line]; @@ -169,30 +169,11 @@ fn pair_landed_copies(fight: &mut Fight) -> VecDeque<(usize, u64)> { damage.attacker_line = u32::try_from(attacker).ok(); } } - attackers -} - -/// Flags the swings among `unpaired` whose landed copy is one of `late`. -fn mark_swings_landing_after_end( - fight: &mut Fight, - mut unpaired: VecDeque<(usize, u64)>, - late: &[LateLanded], -) { - for copy in late { - let landed_after = |&(line, total): &(usize, u64)| { - let swing = &fight.events[line]; - total == copy.melee_total - && swing.source == copy.source - && swing.target == copy.target - && copy.t - swing.t <= LANDED_MATCH_MS - }; - if let Some(position) = unpaired.iter().position(landed_after) - && let Some((swing, _)) = unpaired.remove(position) - && let EventKind::Damage(damage) = &mut fight.events[swing].kind - { - damage.lands_after_end = true; - } + if !any_landed { + return Vec::new(); } + unlanded.extend(attackers.into_iter().map(|(line, _)| line)); + unlanded } /// Memory-maps `path` and loads one fight from it. @@ -505,43 +486,6 @@ impl FightBuilder { FailReason::Other(u16::try_from(index).unwrap_or(u16::MAX)) } - /// The landed copies in `tail`, the lines after the fight, until they could no longer - /// belong to one of its swings. - fn landed_after_end<'a>(&self, tail: &'a [u8], fields: &mut Vec<&'a str>) -> Vec { - let end = i32::try_from(self.fight.duration_ms).unwrap_or(i32::MAX); - let actors = &self.fight.actors; - let mut late = Vec::new(); - for raw in Lines::new(tail) { - let Ok(line) = raw.text().and_then(|text| parse_line(text, fields)) else { - continue; - }; - let t = self.relative_ms(line.timestamp); - if t > end.saturating_add(LANDED_MATCH_MS) { - break; - } - let LogEvent::Combat(event) = &line.event else { - continue; - }; - let CombatKind::Damage(damage) = event.kind else { - continue; - }; - if damage.via != DamageVia::SwingLanded || damage.supporter.is_some() { - continue; - } - if let (Some(source), Some(target)) = - (actors.id(event.source.guid), actors.id(event.target.guid)) - { - late.push(LateLanded { - t, - source, - target, - melee_total: damage.amount + damage.absorbed, - }); - } - } - late - } - fn relative_ms(&self, timestamp: Timestamp) -> i32 { ((timestamp.0 - self.start.0) / 1_000).clamp(i64::from(i32::MIN), i64::from(i32::MAX)) as i32 @@ -673,13 +617,14 @@ impl FightBuilder { critical: d.critical, supporter: self.actor(d.supporter), attacker_line: None, - lands_after_end: false, + unlanded: false, }), CombatKind::Missed(m) => EventKind::Missed(Missed { via: m.via, miss_type: MissType::from_log(m.miss_type), amount_missed: m.amount_missed.unwrap_or(0), critical: m.critical, + unlanded: false, }), CombatKind::Heal(h) => EventKind::Heal(Heal { periodic: h.via == HealVia::Periodic, diff --git a/crates/openlogs-analysis/src/reports/mod.rs b/crates/openlogs-analysis/src/reports/mod.rs index 2e9b2d3..facbb9d 100644 --- a/crates/openlogs-analysis/src/reports/mod.rs +++ b/crates/openlogs-analysis/src/reports/mod.rs @@ -663,18 +663,19 @@ pub(crate) fn keeps_support( ) -> SupportParts { if scope.selects_all() { return SupportParts { - buffed: true, + buffed: support.hit_counts, credit: true, }; } let target = unit_of(fight, support.target); SupportParts { - buffed: scope.accepts( - fight, - Some(&unit_of(fight, support.doer)), - ability, - Some(&target), - ), + buffed: support.hit_counts + && scope.accepts( + fight, + Some(&unit_of(fight, support.doer)), + ability, + Some(&target), + ), credit: scope.accepts( fight, Some(&UnitRef::Player(support.evoker)), @@ -860,6 +861,8 @@ pub(crate) struct Support { pub buff: SpellId, pub target: ActorId, pub amount: u64, + /// Whether the buffed hit is in the numbers itself; the Evoker's share counts either way. + pub hit_counts: bool, } /// The parts of an amount that went into or came from shields, and that heal absorbs took. @@ -914,16 +917,15 @@ impl Absorbs { } } -/// Damage done: hits on enemies (see [`hits_enemy`]), credited through pets. -/// Support from an unknown Evoker is not a share. +/// Damage done: hits on enemies (see [`hits_enemy`]), credited through pets. The Evoker's share +/// of a hit a player dealt themselves counts for the Evoker alone. Support from an unknown Evoker +/// is not a share. pub(crate) fn damage_share(fight: &Fight, event: &Event, overkill: Overkill) -> Option { let damage = dealt_damage(event)?; - if !hits_enemy(fight, event) { - return None; - } let player = fight.actors.credited_player(event.source)?; + let on_enemy = hits_enemy(fight, event); if damage.supporter == NOBODY { - return credited_as_damage_done(&damage).then_some(Share::Own { + return (on_enemy && credited_as_damage_done(&damage)).then_some(Share::Own { player, actor: event.source, spell: event.spell, @@ -935,6 +937,11 @@ pub(crate) fn damage_share(fight: &Fight, event: &Event, overkill: Overkill) -> }); } let evoker = fight.actors.credited_player(damage.supporter)?; + let self_hit_buffed_by_another = + evoker != player && fight.actors.credited_player(event.target) == Some(player); + if !(on_enemy || self_hit_buffed_by_another) { + return None; + } Some(Share::Support(Support { player, evoker, @@ -942,6 +949,7 @@ pub(crate) fn damage_share(fight: &Fight, event: &Event, overkill: Overkill) -> buff: event.spell, target: event.target, amount: damage_done_amount(&damage, overkill), + hit_counts: on_enemy, })) } @@ -1057,6 +1065,7 @@ pub(crate) fn healing_share(fight: &Fight, event: &Event) -> Option { buff: spell, target: event.target, amount, + hit_counts: true, })) } diff --git a/crates/openlogs-analysis/src/timeline.rs b/crates/openlogs-analysis/src/timeline.rs index be6535e..4806521 100644 --- a/crates/openlogs-analysis/src/timeline.rs +++ b/crates/openlogs-analysis/src/timeline.rs @@ -21,10 +21,10 @@ pub fn is_distinct_hit(damage: &Damage) -> bool { } } -/// Whether a hit is in the Damage Done numbers. They leave out a swing whose landed copy is -/// logged after the pull's end, mostly the boss's killing blow. +/// Whether a hit is in the Damage Done numbers. They leave out a swing the log never shows +/// landing in the pull, like the boss's killing blow or a hit on a unit logged neutral. pub(crate) fn credited_as_damage_done(damage: &Damage) -> bool { - is_distinct_hit(damage) && !damage.lands_after_end + is_distinct_hit(damage) && !damage.unlanded } /// The damage an event deals its target. A hit a shield swallowed completely is logged as an @@ -43,7 +43,7 @@ pub(crate) fn dealt_damage(event: &Event) -> Option { critical: missed.critical, supporter: NOBODY, attacker_line: None, - lands_after_end: false, + unlanded: missed.unlanded, }), _ => None, } diff --git a/crates/openlogs-analysis/src/views/parts.rs b/crates/openlogs-analysis/src/views/parts.rs index 2c8f8f9..7c8e945 100644 --- a/crates/openlogs-analysis/src/views/parts.rs +++ b/crates/openlogs-analysis/src/views/parts.rs @@ -184,27 +184,29 @@ fn own_side( miss: None, row, }); - let (spell, kind) = match hit { - Some((_, spell)) => (spell, CellKind::Own), - None => (NO_SPELL, CellKind::Unmatched), - }; - book(Part { - source: support.doer, - spell, - kind, - target: support.target, - amount: -amount, - absorbed: -(deducted.absorbed as i64), - heal_absorbed: -(deducted.heal_absorbed as i64), - overheal: 0, - healed: 0, - hit: false, - cost: false, - crit: false, - periodic, - miss: None, - row, - }); + if support.hit_counts { + let (spell, kind) = match hit { + Some((_, spell)) => (spell, CellKind::Own), + None => (NO_SPELL, CellKind::Unmatched), + }; + book(Part { + source: support.doer, + spell, + kind, + target: support.target, + amount: -amount, + absorbed: -(deducted.absorbed as i64), + heal_absorbed: -(deducted.heal_absorbed as i64), + overheal: 0, + healed: 0, + hit: false, + cost: false, + crit: false, + periodic, + miss: None, + row, + }); + } } _ => {} } diff --git a/crates/openlogs-analysis/tests/breakdown.rs b/crates/openlogs-analysis/tests/breakdown.rs index 2df6be1..ad38ae0 100644 --- a/crates/openlogs-analysis/tests/breakdown.rs +++ b/crates/openlogs-analysis/tests/breakdown.rs @@ -298,6 +298,7 @@ fn damage_taken_rows_carry_hits_and_absorbed_damage_on_both_sides() { miss_type: MissType::Absorb, amount_missed: 400, critical: true, + unlanded: false, }), ); b.push( @@ -508,6 +509,7 @@ fn missed(via: DamageVia, miss_type: MissType) -> EventKind { miss_type, amount_missed: 0, critical: false, + unlanded: false, }) } diff --git a/crates/openlogs-analysis/tests/damage_report.rs b/crates/openlogs-analysis/tests/damage_report.rs index 2ba42e2..db6d732 100644 --- a/crates/openlogs-analysis/tests/damage_report.rs +++ b/crates/openlogs-analysis/tests/damage_report.rs @@ -146,6 +146,7 @@ fn hits_a_shield_swallowed_count_as_damage_done_net_of_their_support() { miss_type: MissType::Absorb, amount_missed: 400, critical: true, + unlanded: false, }), ); r.b.push(2_000, r.warrior, r.boss, 395152, supported(40, r.evoker)); @@ -184,6 +185,30 @@ fn self_support_cancels_out() { } } +#[test] +fn the_share_of_a_hit_a_player_dealt_themselves_counts_for_the_evoker_alone() { + let mut r = raid(); + r.b.spell(1292299, "Seriously Sharp Seashell"); + r.b.spell(413984, "Shifting Sands"); + r.b.push(1_000, r.warrior, r.boss, 1, hit(1_000)); + r.b.push(2_000, r.warrior, r.warrior, 1292299, hit(200)); + r.b.push(2_000, r.warrior, r.warrior, 413984, supported(20, r.evoker)); + let fight = r.b.build(); + let augmented = damage_done(&fight, &ReportFilter::whole(AUG)); + assert_eq!( + (total(&augmented, r.warrior), total(&augmented, r.evoker)), + (1_000, 0) + ); + let reattributed = damage_done(&fight, &ReportFilter::whole(RE)); + assert_eq!( + ( + total(&reattributed, r.warrior), + total(&reattributed, r.evoker) + ), + (1_000, 20) + ); +} + #[test] fn support_from_unknown_supporter_stays_with_the_player() { let mut r = raid(); diff --git a/crates/openlogs-analysis/tests/deaths.rs b/crates/openlogs-analysis/tests/deaths.rs index 692b237..f64993d 100644 --- a/crates/openlogs-analysis/tests/deaths.rs +++ b/crates/openlogs-analysis/tests/deaths.rs @@ -176,6 +176,7 @@ fn damage_before_death_counts_what_shields_absorbed() { miss_type: MissType::Absorb, amount_missed: 250, critical: false, + unlanded: false, }), ); b.push( diff --git a/crates/openlogs-analysis/tests/events.rs b/crates/openlogs-analysis/tests/events.rs index 37423fc..164b93a 100644 --- a/crates/openlogs-analysis/tests/events.rs +++ b/crates/openlogs-analysis/tests/events.rs @@ -96,6 +96,7 @@ fn raid() -> Raid { miss_type: MissType::Absorb, amount_missed: 250, critical: false, + unlanded: false, }), ); Raid { @@ -181,6 +182,7 @@ fn misses_are_rows_without_an_amount_on_both_sides() { miss_type, amount_missed: 0, critical: false, + unlanded: false, }) }; b.push( diff --git a/crates/openlogs-analysis/tests/load_fight.rs b/crates/openlogs-analysis/tests/load_fight.rs index 6d00d8c..9f7782f 100644 --- a/crates/openlogs-analysis/tests/load_fight.rs +++ b/crates/openlogs-analysis/tests/load_fight.rs @@ -1,7 +1,7 @@ use openlogs_analysis::{ - ActorKind, Actors, Attribution, Damage, DamageVia, EventKind, FailReason, LANDED_TAIL_BYTES, - NO_SPELL, ReportFilter, ScopeMetric, Side, UnitHp, cells, damage_done, damage_taken, - load_fight, load_fight_slice, load_fight_slice_with, + ActorKind, Actors, Attribution, Damage, DamageVia, EventKind, FailReason, NO_SPELL, + ReportFilter, ScopeMetric, Side, UnitHp, cells, damage_done, damage_taken, load_fight, + load_fight_slice, load_fight_slice_with, }; use openlogs_gamedata::Curated; use openlogs_index::{Outcome, index_bytes}; @@ -186,7 +186,7 @@ fn a_fight_loads_the_same_from_its_part_of_the_log() { let index = index_bytes(log); for summary in &index.fights { let start = summary.prelude_offset as usize; - let end = ((summary.end_offset + LANDED_TAIL_BYTES) as usize).min(log.len()); + let end = summary.end_offset as usize; assert_eq!( load_fight_slice(&log[start..end], summary.prelude_offset, summary), load_fight(log, summary) @@ -198,6 +198,7 @@ fn a_fight_loads_the_same_from_its_part_of_the_log() { const KILLING_SWING_LOG: &str = concat!( "10/7/2026 19:03:02.0762 ENCOUNTER_START,3492,\"Ula'tek\",15,23,3004\n", "10/7/2026 19:03:05.0000 SWING_DAMAGE,Pet-0-4246-0-846-17252-01044B0E32,\"ShaaNash\",0x1114,0x80000000,Vehicle-0-3892-3004-1387-257758-00004679D4,\"Ula'tek\",0x10a48,0x80000000,Pet-0-4246-0-846-17252-01044B0E32,Player-4101-0A1AA093,821186,821186,7070,10791,5420,0,0,164192,3,75,200,0,1576.64,5.07,2610,6.0174,333,6234,6234,-1,1,0,0,0,nil,nil,nil\n", + "10/7/2026 19:03:05.0100 SWING_DAMAGE_LANDED,Pet-0-4246-0-846-17252-01044B0E32,\"ShaaNash\",0x1114,0x80000000,Vehicle-0-3892-3004-1387-257758-00004679D4,\"Ula'tek\",0x10a48,0x80000000,Pet-0-4246-0-846-17252-01044B0E32,Player-4101-0A1AA093,821186,821186,7070,10791,5420,0,0,164192,3,75,200,0,1576.64,5.07,2610,6.0174,333,6234,6234,-1,1,0,0,0,nil,nil,nil\n", "10/7/2026 19:04:02.0500 SWING_DAMAGE,Pet-0-4246-0-846-17252-01044B0E32,\"ShaaNash\",0x1114,0x80000000,Vehicle-0-3892-3004-1387-257758-00004679D4,\"Ula'tek\",0x10a48,0x80000000,Pet-0-4246-0-846-17252-01044B0E32,Player-4101-0A1AA093,821186,821186,7070,10791,5420,0,0,164192,3,75,200,0,1576.64,5.07,2610,6.0174,333,5000,5000,1200,1,0,0,0,nil,nil,nil\n", "10/7/2026 19:04:02.0762 ENCOUNTER_END,3492,\"Ula'tek\",15,23,1,60000\n", "10/7/2026 19:04:02.0800 SWING_DAMAGE_LANDED,Pet-0-4246-0-846-17252-01044B0E32,\"ShaaNash\",0x1114,0x80000000,Vehicle-0-3892-3004-1387-257758-00004679D4,\"Ula'tek\",0x10a48,0x80000000,Pet-0-4246-0-846-17252-01044B0E32,Player-4101-0A1AA093,821186,821186,7070,10791,5420,0,0,164192,3,75,200,0,1576.64,5.07,2610,6.0174,333,3800,5000,1200,1,0,0,1200,nil,nil,nil\n", @@ -208,15 +209,12 @@ fn a_swing_whose_landed_copy_follows_the_end_stays_out_of_damage_done() { let index = index_bytes(KILLING_SWING_LOG.as_bytes()); let fight = load_fight(KILLING_SWING_LOG.as_bytes(), &index.fights[0]); let report = damage_done(&fight, &ReportFilter::whole(Attribution::Augmented)); - assert_eq!( - report.total, 6_234, - "a swing without any landed copy still counts" - ); + assert_eq!(report.total, 6_234); let swings: Vec = fight .events .iter() .filter_map(|e| match e.kind { - EventKind::Damage(d) if d.via == DamageVia::Swing => Some(d.lands_after_end), + EventKind::Damage(d) if d.via == DamageVia::Swing => Some(d.unlanded), _ => None, }) .collect(); @@ -294,6 +292,32 @@ fn a_melee_hit_counts_once_whichever_of_its_lines_the_log_has() { ); } +#[test] +fn a_swing_the_pull_never_shows_landing_stays_out_of_damage_done() { + let log = pull_log(&[ + melee("04.0000", "SWING_DAMAGE", KNIGHT, BOSS, 300, 0), + melee("04.0100", "SWING_DAMAGE_LANDED", KNIGHT, BOSS, 300, 0), + melee("05.0000", "SWING_DAMAGE", KNIGHT, GHOUL, 500, 0), + format!("06.0000 SWING_MISSED,{KNIGHT},{BOSS},ABSORB,nil,900,900,nil"), + ]); + let index = index_bytes(log.as_bytes()); + let fight = load_fight(log.as_bytes(), &index.fights[0]); + let report = damage_done(&fight, &ReportFilter::whole(Attribution::Augmented)); + assert_eq!(report.total, 300); +} + +#[test] +fn every_swing_counts_in_a_log_without_landed_copies() { + let log = pull_log(&[ + melee("04.0000", "SWING_DAMAGE", KNIGHT, BOSS, 300, 0), + melee("05.0000", "SWING_DAMAGE", KNIGHT, GHOUL, 500, 0), + ]); + let index = index_bytes(log.as_bytes()); + let fight = load_fight(log.as_bytes(), &index.fights[0]); + let report = damage_done(&fight, &ReportFilter::whole(Attribution::Augmented)); + assert_eq!(report.total, 800); +} + #[test] fn a_melee_hit_a_shield_took_whole_counts_once_in_damage_taken() { let log = pull_log(&[ diff --git a/crates/openlogs-analysis/tests/overview.rs b/crates/openlogs-analysis/tests/overview.rs index ecafbcd..781df85 100644 --- a/crates/openlogs-analysis/tests/overview.rs +++ b/crates/openlogs-analysis/tests/overview.rs @@ -81,6 +81,7 @@ fn raid_damage_counts_hits_a_shield_swallowed_like_the_damage_report() { miss_type: MissType::Absorb, amount_missed: 10_000, critical: false, + unlanded: false, }), ); let fight = b.build(); diff --git a/crates/openlogs-analysis/tests/recap.rs b/crates/openlogs-analysis/tests/recap.rs index 886968b..e22d811 100644 --- a/crates/openlogs-analysis/tests/recap.rs +++ b/crates/openlogs-analysis/tests/recap.rs @@ -78,6 +78,7 @@ fn recap_lists_damage_heals_and_absorbs() { miss_type: MissType::Absorb, amount_missed: 80_000, critical: false, + unlanded: false, }), ); s.b.push( diff --git a/crates/openlogs-analysis/tests/replay.rs b/crates/openlogs-analysis/tests/replay.rs index c6b099d..bf22c82 100644 --- a/crates/openlogs-analysis/tests/replay.rs +++ b/crates/openlogs-analysis/tests/replay.rs @@ -736,6 +736,7 @@ fn a_bosses_target_follows_its_melee_swings() { miss_type: openlogs_analysis::MissType::Dodge, amount_missed: 0, critical: false, + unlanded: false, }), ); diff --git a/crates/openlogs-analysis/tests/support/mod.rs b/crates/openlogs-analysis/tests/support/mod.rs index ab2ac6f..34059eb 100644 --- a/crates/openlogs-analysis/tests/support/mod.rs +++ b/crates/openlogs-analysis/tests/support/mod.rs @@ -233,7 +233,7 @@ pub fn damage(via: DamageVia, amount: u64, overkill: u64) -> Damage { critical: false, supporter: NOBODY, attacker_line: None, - lands_after_end: false, + unlanded: false, } } diff --git a/crates/openlogs-analysis/tests/taken_report.rs b/crates/openlogs-analysis/tests/taken_report.rs index 519121f..1ab2790 100644 --- a/crates/openlogs-analysis/tests/taken_report.rs +++ b/crates/openlogs-analysis/tests/taken_report.rs @@ -116,6 +116,7 @@ fn fully_absorbed_hits_count_as_damage_taken() { miss_type: MissType::Absorb, amount_missed: 400, critical: false, + unlanded: false, }), ); b.push( @@ -128,6 +129,7 @@ fn fully_absorbed_hits_count_as_damage_taken() { miss_type: MissType::Dodge, amount_missed: 0, critical: false, + unlanded: false, }), ); let report = damage_taken(&b.build(), &ReportFilter::whole(Attribution::Augmented)); @@ -339,6 +341,7 @@ fn refractive_images_on_a_fully_absorbed_swing_comes_off_that_swing() { miss_type: MissType::Absorb, amount_missed: 400, critical: false, + unlanded: false, }), ); b.push( diff --git a/crates/openlogs-analysis/tests/views_timeline.rs b/crates/openlogs-analysis/tests/views_timeline.rs index 3ce1c46..473324d 100644 --- a/crates/openlogs-analysis/tests/views_timeline.rs +++ b/crates/openlogs-analysis/tests/views_timeline.rs @@ -1291,6 +1291,7 @@ fn the_dot_a_game_data_channel_left_does_not_extend_it() { miss_type: MissType::Absorb, amount_missed: 200, critical: false, + unlanded: false, }); b.push(1_000, hunter, boss, fire, EventKind::CastSuccess); b.push(1_300, hunter, boss, fire, spell_hit(200)); diff --git a/crates/openlogs-service/src/set_merge.rs b/crates/openlogs-service/src/set_merge.rs index e0b6a37..7fd56ff 100644 --- a/crates/openlogs-service/src/set_merge.rs +++ b/crates/openlogs-service/src/set_merge.rs @@ -928,6 +928,7 @@ mod tests { miss_type, amount_missed: 0, critical: false, + unlanded: false, }), ..damage_event(t, mage, boss, 1, 0, NOBODY) }; diff --git a/crates/openlogs-service/src/test_fight.rs b/crates/openlogs-service/src/test_fight.rs index 4424672..8deea61 100644 --- a/crates/openlogs-service/src/test_fight.rs +++ b/crates/openlogs-service/src/test_fight.rs @@ -76,7 +76,7 @@ pub fn damage_event( critical: false, supporter, attacker_line: None, - lands_after_end: false, + unlanded: false, }), source_logged_hostile: false, target_logged_hostile: true, diff --git a/crates/openlogs-wasm/src/engine.rs b/crates/openlogs-wasm/src/engine.rs index 95706b7..2e3db09 100644 --- a/crates/openlogs-wasm/src/engine.rs +++ b/crates/openlogs-wasm/src/engine.rs @@ -1,8 +1,7 @@ use std::collections::BTreeSet; use openlogs_analysis::{ - Actors, Fight, LANDED_MATCH_MS, LANDED_TAIL_BYTES, infer_classes, load_fight_slice, - load_fight_slice_with, + Actors, Fight, LANDED_MATCH_MS, infer_classes, load_fight_slice, load_fight_slice_with, }; use openlogs_gamedata::{ChannelSpells, Curated, DungeonTable, SpellClasses}; use openlogs_index::{FightSummary, Indexer, LogIndex}; @@ -101,8 +100,7 @@ impl Engine { self.index = self.indexer.settled_index(settle_ms); let index = &self.index; self.fights.retain(|pulled| { - !pulled.cut_tail - && summary_of(index, pulled.index).is_ok_and(|summary| *summary == pulled.summary) + summary_of(index, pulled.index).is_ok_and(|summary| *summary == pulled.summary) }); self.view_json(log_id, file_name, size_bytes, false) } @@ -131,13 +129,10 @@ impl Engine { Ok(self.view_json(log_id, file_name, size_bytes, true)) } - /// The byte range `[prelude, end)` the pull needs from the log; `end` may lie past the file. + /// The byte range `[prelude, end)` the pull needs from the log. pub fn fight_range(&self, fight_index: u32) -> Result<(u64, u64), String> { let summary = self.summary(fight_index)?; - Ok(( - summary.prelude_offset, - summary.end_offset + LANDED_TAIL_BYTES, - )) + Ok((summary.prelude_offset, summary.end_offset)) } /// Marks a loaded pull as the most recently used one; `false` when it is not loaded. @@ -164,7 +159,6 @@ impl Engine { let summary = self.summary(fight_index)?.clone(); let mut fight = load_fight_slice(part, base_offset, &summary); infer_classes(&mut fight, &self.spell_classes); - let cut_tail = base_offset + (part.len() as u64) < summary.end_offset + LANDED_TAIL_BYTES; self.fights.retain(|pulled| pulled.index != fight_index); self.fights.insert( 0, @@ -172,7 +166,6 @@ impl Engine { index: fight_index, fight, summary, - cut_tail, }, ); self.fights.truncate(LOADED_PULLS); @@ -478,8 +471,6 @@ struct LoadedPull { index: u32, fight: Fight, summary: FightSummary, - /// The file ended before the pull's landed tail did, so later lines may change it. - cut_tail: bool, } fn summary_of(index: &LogIndex, fight_index: u32) -> Result<&FightSummary, String> { diff --git a/crates/openlogs-wasm/tests/engine.rs b/crates/openlogs-wasm/tests/engine.rs index 76a4289..e7f2574 100644 --- a/crates/openlogs-wasm/tests/engine.rs +++ b/crates/openlogs-wasm/tests/engine.rs @@ -140,7 +140,7 @@ fn opening_a_log_lists_its_pulls_and_a_stored_index_reopens_it() { } #[test] -fn a_grown_log_lists_settled_pulls_and_reloads_pulls_read_before_their_tail() { +fn a_grown_log_lists_settled_pulls_and_keeps_the_complete_ones_loaded() { let pull_2_start = FIXTURE.find("19:10:00.0000").unwrap(); let cut = pull_2_start + FIXTURE[pull_2_start..].find('\n').unwrap() + 1; let (head, rest) = FIXTURE.split_at(cut); @@ -163,7 +163,7 @@ fn a_grown_log_lists_settled_pulls_and_reloads_pulls_read_before_their_tail() { for (grown, complete) in listed.iter().zip(whole["fights"].as_array().unwrap()) { assert_eq!(grown, complete); } - assert!(!engine.touch_fight(1)); + assert!(engine.touch_fight(1)); assert_eq!( serde_json::from_str::(&engine.snapshot_json()).unwrap(), serde_json::from_str::(&reference.index_json()).unwrap()