Skip to content

Commit e435743

Browse files
committed
0.2.1 - fix deaths by world not being properly classified as suicides
1 parent 6600d5a commit e435743

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

src/filters.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::heatmap_analyser::{Death, PlayerEntity, Team, PlayerState};
1+
use crate::heatmap_analyser::{Death, PlayerEntity, PlayerState, Team};
22
use enum_dispatch::enum_dispatch;
33
use std::fmt::Display;
44
use tf_demo_parser::demo::vector::Vector;
@@ -75,10 +75,7 @@ pub enum Property {
7575
}
7676

7777
impl Property {
78-
pub const ALL: [Property; 2] = [
79-
Property::Suicide,
80-
Property::Posthumous,
81-
];
78+
pub const ALL: [Property; 2] = [Property::Suicide, Property::Posthumous];
8279
}
8380

8481
impl Default for Property {
@@ -295,9 +292,9 @@ impl FilterTrait for PropertyFilter {
295292
let ret = match self.property {
296293
Property::Suicide => death.killer == death.victim,
297294
Property::Posthumous => match death.killer_entity_state {
298-
Some(PlayerEntity { state: PlayerState::Alive, .. } ) => false,
299-
_ => true
300-
}
295+
Some(PlayerEntity { state: PlayerState::Alive, .. }) => false,
296+
_ => true,
297+
},
301298
};
302299
match self.op {
303300
PropertyOperator::IsPresent => ret,

src/heatmap_analyser.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,11 @@ impl Death {
226226
} else {
227227
(None, None)
228228
};
229-
let killer = UserId::from(event.attacker);
229+
let killer = UserId::from(if event.attacker == 0 {
230+
event.user_id // if world killed the player, count it as a suicide
231+
} else {
232+
event.attacker
233+
});
230234
let victim = UserId::from(event.user_id);
231235
Death {
232236
assister,

0 commit comments

Comments
 (0)