From 2e66e2242690475d8e409ebc37bde404b25425b6 Mon Sep 17 00:00:00 2001 From: Dan Kotov Date: Wed, 21 Aug 2024 14:31:03 -0400 Subject: [PATCH] feat: wanted prop states check skeleton bar the translation of user input into PropInfo vector --- src/parser/Cargo.lock | 8 ++++---- src/parser/src/e2e_test.rs | 5 +++++ src/parser/src/first_pass/parser_settings.rs | 5 +++++ src/parser/src/first_pass/prop_controller.rs | 12 ++++++++++++ src/parser/src/first_pass/sendtables.rs | 1 + src/parser/src/second_pass/collect_data.rs | 13 +++++++++++++ src/parser/src/second_pass/parser_settings.rs | 9 ++++++++- 7 files changed, 48 insertions(+), 5 deletions(-) diff --git a/src/parser/Cargo.lock b/src/parser/Cargo.lock index 665fe753..6f9e77a3 100644 --- a/src/parser/Cargo.lock +++ b/src/parser/Cargo.lock @@ -301,9 +301,9 @@ dependencies = [ [[package]] name = "protobuf" -version = "3.3.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b65f4a8ec18723a734e5dc09c173e0abf9690432da5340285d536edcb4dac190" +checksum = "df67496db1a89596beaced1579212e9b7c53c22dca1d9745de00ead76573d514" dependencies = [ "bytes", "once_cell", @@ -313,9 +313,9 @@ dependencies = [ [[package]] name = "protobuf-support" -version = "3.3.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6872f4d4f4b98303239a2b5838f5bbbb77b01ffc892d627957f37a22d7cfe69c" +checksum = "70e2d30ab1878b2e72d1e2fc23ff5517799c9929e2cf81a8516f9f4dcf2b9cf3" dependencies = [ "thiserror", ] diff --git a/src/parser/src/e2e_test.rs b/src/parser/src/e2e_test.rs index f69d5075..7f9be842 100644 --- a/src/parser/src/e2e_test.rs +++ b/src/parser/src/e2e_test.rs @@ -307,6 +307,7 @@ pub fn _create_ge_tests() { parse_ents: true, wanted_players: vec![], wanted_ticks: (0..5).into_iter().map(|x| x * 10000).collect_vec(), + wanted_prop_states: AHashMap::default(), parse_projectiles: true, only_header: false, count_props: false, @@ -680,6 +681,7 @@ pub fn _create_tests() { parse_ents: true, wanted_players: vec![], wanted_ticks: (0..5).into_iter().map(|x| x * 10000).collect_vec(), + wanted_prop_states: AHashMap::default(), parse_projectiles: true, only_header: false, count_props: false, @@ -1052,6 +1054,7 @@ fn create_data() -> (DemoOutput, PropController, BTreeMap parse_ents: true, wanted_players: vec![], wanted_ticks: (0..5).into_iter().map(|x| x * 10000).collect_vec(), + wanted_prop_states: AHashMap::default(), parse_projectiles: true, only_header: false, count_props: false, @@ -1076,6 +1079,7 @@ fn create_data() -> (DemoOutput, PropController, BTreeMap parse_ents: true, wanted_players: vec![], wanted_ticks: (0..5).into_iter().map(|x| x * 10000).collect_vec(), + wanted_prop_states: AHashMap::default(), parse_projectiles: true, only_header: false, count_props: false, @@ -1191,6 +1195,7 @@ mod tests { wanted_other_props: vec!["CCSTeam.m_iScore".to_string()], parse_ents: true, wanted_ticks: vec![10000, 10001], + wanted_prop_states: AHashMap::default(), parse_projectiles: true, only_header: false, count_props: false, diff --git a/src/parser/src/first_pass/parser_settings.rs b/src/parser/src/first_pass/parser_settings.rs index 3a6cdeb1..0a4bc844 100644 --- a/src/parser/src/first_pass/parser_settings.rs +++ b/src/parser/src/first_pass/parser_settings.rs @@ -10,6 +10,7 @@ use crate::second_pass::decoder::QfMapper; use crate::second_pass::other_netmessages::Class; use crate::second_pass::parser_settings::PlayerEndMetaData; use crate::second_pass::parser_settings::SpecialIDs; +use crate::second_pass::variants::Variant; use ahash::AHashMap; use ahash::AHashSet; use ahash::RandomState; @@ -27,6 +28,7 @@ pub struct ParserInputs<'a> { pub wanted_players: Vec, pub wanted_player_props: Vec, pub wanted_other_props: Vec, + pub wanted_prop_states: AHashMap, pub wanted_ticks: Vec, pub wanted_events: Vec, pub parse_ents: bool, @@ -63,6 +65,7 @@ pub struct FirstPassParser<'a> { pub wanted_players: AHashSet, pub wanted_ticks: AHashSet, pub wanted_other_props: Vec, + pub wanted_prop_states: AHashMap, pub wanted_events: Vec, pub parse_entities: bool, pub parse_projectiles: bool, @@ -104,6 +107,7 @@ impl<'a> FirstPassParser<'a> { prop_controller: PropController::new( inputs.wanted_player_props.clone(), inputs.wanted_other_props.clone(), + inputs.wanted_prop_states.clone(), inputs.real_name_to_og_name.clone(), false, &vec!["None".to_string()], @@ -131,6 +135,7 @@ impl<'a> FirstPassParser<'a> { wanted_players: AHashSet::from_iter(inputs.wanted_players.iter().cloned()), wanted_ticks: AHashSet::from_iter(inputs.wanted_ticks.iter().cloned()), wanted_other_props: inputs.wanted_other_props.clone(), + wanted_prop_states: inputs.wanted_prop_states.clone(), settings: &inputs, controller_ids: SpecialIDs::new(), id: 0, diff --git a/src/parser/src/first_pass/prop_controller.rs b/src/parser/src/first_pass/prop_controller.rs index c75d5046..66e7c8a7 100644 --- a/src/parser/src/first_pass/prop_controller.rs +++ b/src/parser/src/first_pass/prop_controller.rs @@ -5,6 +5,7 @@ use crate::maps::BUTTONMAP; use crate::maps::TYPEHM; use crate::second_pass::collect_data::PropType; use crate::second_pass::parser_settings::SpecialIDs; +use crate::second_pass::variants::Variant; use ahash::AHashMap; pub const PLAYER_ENTITY_HANDLE_MISSING: i32 = 2047; @@ -63,6 +64,8 @@ pub struct PropController { pub event_with_velocity: bool, pub needs_velocity: bool, pub path_to_name: AHashMap<[i32; 7], String>, + pub wanted_prop_states: AHashMap, + pub wanted_prop_state_infos: Vec, } #[derive(Debug, Clone, PartialEq)] @@ -74,6 +77,12 @@ pub struct PropInfo { pub is_player_prop: bool, } +#[derive(Debug, Clone, PartialEq)] +pub struct WantedPropStateInfo { + pub base: PropInfo, + pub wanted_prop_state: Variant, +} + pub enum PropCollectionType { Player, Rules, @@ -84,6 +93,7 @@ impl PropController { pub fn new( wanted_player_props: Vec, wanted_other_props: Vec, + wanted_prop_states: AHashMap, real_name_to_og_name: AHashMap, needs_velocty: bool, wanted_events: &[String], @@ -102,6 +112,8 @@ impl PropController { event_with_velocity: !wanted_events.is_empty() && needs_velocty, path_to_name: AHashMap::default(), needs_velocity: needs_velocty, + wanted_prop_states: wanted_prop_states, + wanted_prop_state_infos: vec![], } } diff --git a/src/parser/src/first_pass/sendtables.rs b/src/parser/src/first_pass/sendtables.rs index c7fd557b..b08fad34 100644 --- a/src/parser/src/first_pass/sendtables.rs +++ b/src/parser/src/first_pass/sendtables.rs @@ -97,6 +97,7 @@ impl<'a> FirstPassParser<'a> { let mut prop_controller = PropController::new( self.wanted_player_props.clone(), self.wanted_other_props.clone(), + self.wanted_prop_states.clone(), self.real_name_to_og_name.clone(), needs_velocity(&self.wanted_player_props), &self.wanted_events, diff --git a/src/parser/src/second_pass/collect_data.rs b/src/parser/src/second_pass/collect_data.rs index d9e33e5b..539d9b97 100644 --- a/src/parser/src/second_pass/collect_data.rs +++ b/src/parser/src/second_pass/collect_data.rs @@ -70,6 +70,19 @@ impl<'a> SecondPassParser<'a> { // iterate every player and every wanted prop name // if either one is missing then push None to output for (entity_id, player) in &self.players { + // iterate every wanted prop state + // if any prop's state for this tick is not the wanted state, dont extract info from tick + for wanted_prop_state_info in &self.prop_controller.wanted_prop_state_infos { + match self.find_prop(&wanted_prop_state_info.base, entity_id, player) { + Ok(prop) => { + if prop != wanted_prop_state_info.wanted_prop_state { + return; + } + } + Err(_e) => return, + } + } + for prop_info in &self.prop_controller.prop_infos { let player_steamid = match player.steamid { Some(steamid) => steamid, diff --git a/src/parser/src/second_pass/parser_settings.rs b/src/parser/src/second_pass/parser_settings.rs index 8554853c..c7f390d0 100644 --- a/src/parser/src/second_pass/parser_settings.rs +++ b/src/parser/src/second_pass/parser_settings.rs @@ -137,7 +137,14 @@ impl<'a> SecondPassParser<'a> { header: None, player_md: self.player_end_data, game_events_counter: self.game_events_counter, - prop_info: PropController::new(vec![], vec![], AHashMap::default(), false, &["none".to_string()]), + prop_info: PropController::new( + vec![], + vec![], + AHashMap::default(), + AHashMap::default(), + false, + &["none".to_string()], + ), projectiles: self.projectile_records, ptr: self.ptr, df_per_player: self.df_per_player,