Skip to content

Commit

Permalink
feat: wanted prop states check skeleton
Browse files Browse the repository at this point in the history
bar the translation of user input into PropInfo vector
  • Loading branch information
dankotov committed Aug 21, 2024
1 parent f0ea617 commit 2e66e22
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/parser/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/parser/src/e2e_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -1052,6 +1054,7 @@ fn create_data() -> (DemoOutput, PropController, BTreeMap<String, Vec<GameEvent>
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,
Expand All @@ -1076,6 +1079,7 @@ fn create_data() -> (DemoOutput, PropController, BTreeMap<String, Vec<GameEvent>
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,
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions src/parser/src/first_pass/parser_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,6 +28,7 @@ pub struct ParserInputs<'a> {
pub wanted_players: Vec<u64>,
pub wanted_player_props: Vec<String>,
pub wanted_other_props: Vec<String>,
pub wanted_prop_states: AHashMap<String, Variant>,
pub wanted_ticks: Vec<i32>,
pub wanted_events: Vec<String>,
pub parse_ents: bool,
Expand Down Expand Up @@ -63,6 +65,7 @@ pub struct FirstPassParser<'a> {
pub wanted_players: AHashSet<u64, RandomState>,
pub wanted_ticks: AHashSet<i32, RandomState>,
pub wanted_other_props: Vec<String>,
pub wanted_prop_states: AHashMap<String, Variant>,
pub wanted_events: Vec<String>,
pub parse_entities: bool,
pub parse_projectiles: bool,
Expand Down Expand Up @@ -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()],
Expand Down Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions src/parser/src/first_pass/prop_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String, Variant>,
pub wanted_prop_state_infos: Vec<WantedPropStateInfo>,
}

#[derive(Debug, Clone, PartialEq)]
Expand All @@ -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,
Expand All @@ -84,6 +93,7 @@ impl PropController {
pub fn new(
wanted_player_props: Vec<String>,
wanted_other_props: Vec<String>,
wanted_prop_states: AHashMap<String, Variant>,
real_name_to_og_name: AHashMap<String, String>,
needs_velocty: bool,
wanted_events: &[String],
Expand All @@ -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![],
}
}

Expand Down
1 change: 1 addition & 0 deletions src/parser/src/first_pass/sendtables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 13 additions & 0 deletions src/parser/src/second_pass/collect_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 8 additions & 1 deletion src/parser/src/second_pass/parser_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 2e66e22

Please sign in to comment.