Skip to content

Commit

Permalink
fix missing pickup event id (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
LaihoE authored Jul 10, 2024
1 parent 6c84f49 commit 63fcd63
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 9 deletions.
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

0 comments on commit 63fcd63

Please sign in to comment.