fix classes in older log without spawn events

This commit is contained in:
Robin Appelman 2026-11-16 22:08:43 +01:00
commit f5121a75c3
Signed by: robin
SSH key fingerprint: SHA256:kifqgrqnut7q1YUIrI0AdMNC23qiKAS/T9uGFmIYvbE
3 changed files with 11 additions and 2 deletions

2
Cargo.lock generated
View file

@ -1178,7 +1178,7 @@ dependencies = [
[[package]]
name = "tf-log-parser"
version = "0.1.1"
version = "0.1.2"
dependencies = [
"ahash",
"chrono",

View file

@ -1,6 +1,6 @@
[package]
name = "tf-log-parser"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
rust-version = "1.90.0"
description = "TF2 log parser with a focus on speed and flexibility"

View file

@ -174,6 +174,7 @@ impl GlobalData for Kills {
RawEventType::Killed
| RawEventType::KillAssist
| RawEventType::Spawned
| RawEventType::RoleChange
| RawEventType::ShotFired
| RawEventType::ChargeDeployed
| RawEventType::ChargeReady
@ -213,6 +214,14 @@ impl GlobalData for Kills {
}
self.alive.insert(subject, true);
}
GameEvent::RoleChange(event) => {
self.active = self.game_started;
if let Some(class) = event.class {
self.classes.insert(subject, class);
}
self.alive.insert(subject, true);
}
GameEvent::ShotFired(event) => {
if let Some(Ok(weapon)) = event.weapon.map(Weapon::from_str) {
let class = self.classes.get(&subject).copied().unwrap_or_default();