mirror of
https://codeberg.org/icewind/tf-log-parser.git
synced 2026-06-03 18:24:09 +02:00
fix damage
This commit is contained in:
parent
fbe3eee614
commit
838c3a0dd9
4 changed files with 17 additions and 3 deletions
|
|
@ -140,9 +140,16 @@ fn param_pair_parse(input: &str) -> IResult<'_, (&str, &str)> {
|
|||
|
||||
let (key, input) = split_once(input, b' ', 1)?;
|
||||
let input = skip(input, 1)?;
|
||||
let (value, input) = split_once(input, b'"', 1)?;
|
||||
|
||||
// hack to handle quotes in names
|
||||
let (value, input) = if key == "against" || key == "objectowner" {
|
||||
split_subject_end(input, 1)?
|
||||
} else {
|
||||
split_once(input, b'"', 1)?
|
||||
};
|
||||
|
||||
let input = if open_tag { skip(input, 1)? } else { input };
|
||||
let (input, _) = skip_matches(input, b' ');
|
||||
Ok((input, (key, value)))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@ pub struct ShotHitEvent<'a> {
|
|||
#[derive(Debug, Event)]
|
||||
pub struct DamageEvent<'a> {
|
||||
#[event(name = "against")]
|
||||
pub target: Option<RawSubject<'a>>,
|
||||
#[event(default)]
|
||||
pub target: RawSubject<'a>,
|
||||
pub damage: Option<NonZeroU32>,
|
||||
#[event(name = "realdamage")]
|
||||
pub real_damage: Option<NonZeroU32>,
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ impl EventHandler for ClassStatsHandler {
|
|||
}
|
||||
GameEvent::Damage(DamageEvent {
|
||||
damage: Some(damage),
|
||||
target: Some(target),
|
||||
target,
|
||||
..
|
||||
}) if self.active => {
|
||||
if let Some(target_class) = self.get_class(target) {
|
||||
|
|
|
|||
|
|
@ -76,6 +76,12 @@ pub enum RawSubject<'a> {
|
|||
World,
|
||||
}
|
||||
|
||||
impl Default for RawSubject<'static> {
|
||||
fn default() -> Self {
|
||||
RawSubject::System("unknown")
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> RawSubject<'a> {
|
||||
pub fn id(&self) -> Result<SubjectId, SubjectError> {
|
||||
self.try_into()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue