Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing user steamid/name in bomb_pickup events #192

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 28 additions & 9 deletions src/parser/src/e2e_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use memmap2::MmapOptions;
use std::collections::BTreeMap;
use std::fs::File;


pub fn _create_ge_tests() {
let wanted_props = vec![
"CCSPlayerPawn.CBodyComponentBaseAnimGraph.m_flLastTeleportTime".to_string(),
Expand Down Expand Up @@ -16693,18 +16692,38 @@ mod tests {
vec![
GameEvent {
name: "bomb_pickup".to_string(),
fields: vec![EventField {
name: "tick".to_string(),
data: Some(I32(65)),
}],
fields: vec![
EventField {
name: "tick".to_string(),
data: Some(I32(65)),
},
EventField {
name: "user_name".to_string(),
data: Some(String("Подсосник blick'a".to_string())),
},
EventField {
name: "user_steamid".to_string(),
data: Some(String("76561197964020430".to_string())),
},
],
tick: 65,
},
GameEvent {
name: "bomb_pickup".to_string(),
fields: vec![EventField {
name: "tick".to_string(),
data: Some(I32(5839)),
}],
fields: vec![
EventField {
name: "tick".to_string(),
data: Some(I32(5839)),
},
EventField {
name: "user_name".to_string(),
data: Some(String("IMI Negev".to_string())),
},
EventField {
name: "user_steamid".to_string(),
data: Some(String("76561198202353993".to_string())),
},
],
tick: 5839,
},
],
Expand Down
14 changes: 14 additions & 0 deletions src/parser/src/second_pass/game_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,22 @@ impl<'a> SecondPassParser<'a> {
"user"
}
}
// Another edge case
// Only add iff "userid" is missing in the event...
"userid_pawn" => {
let field_names: Vec<&String> = fields.iter().map(|x| &x.name).collect();
if !field_names.contains(&&"userid".to_string()) {
"user"
} else {
continue;
}
}
_ => continue,
};
if let Some(Variant::I32(u)) = field.data {
let entity_id = match field.name.as_str() {
"entityid" => self.grenade_owner_entid_from_grenade(&field.data),
"userid_pawn" => self.entity_id_from_user_pawn(u),
_ => self.entity_id_from_userid(u),
};
let entity_id = match entity_id {
Expand All @@ -195,6 +206,9 @@ impl<'a> SecondPassParser<'a> {
extra_fields.extend(self.find_non_player_props());
Ok(extra_fields)
}
pub fn entity_id_from_user_pawn(&self, pawn_handle: i32) -> Option<i32> {
Some(pawn_handle & 0x7FF)
}
pub fn grenade_owner_entid_from_grenade(&self, id_field: &Option<Variant>) -> Option<i32> {
let prop_id = match self.prop_controller.special_ids.grenade_owner_id {
Some(id) => id,
Expand Down
Loading