From 6d89de0663a4f0d87bc28b9478fde1c57b79efec Mon Sep 17 00:00:00 2001 From: Lol3rrr Date: Sat, 21 Sep 2024 21:53:41 +0200 Subject: [PATCH] Update tests and some more --- src/parser.rs | 124 ++++----- src/parser/entities.rs | 51 +++- src/parser/fieldpath.rs | 88 +++---- src/parser/sendtables.rs | 527 +++++++++++++++++++-------------------- tests/parse.rs | 12 +- 5 files changed, 428 insertions(+), 374 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index c11afb0..4be5abb 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -9,6 +9,8 @@ mod propcontroller; mod sendtables; mod variant; +pub use entities::EntityFilter; + #[derive(Debug)] pub enum FirstPassError { DecompressFrame, @@ -76,7 +78,7 @@ pub struct Class { serializer: sendtables::Serializer, } -pub fn parse<'b, FI>(frames: FI) -> Result +pub fn parse<'b, FI>(frames: FI, filter: EntityFilter) -> Result where FI: IntoIterator>, { @@ -91,6 +93,7 @@ where let mut entity_ctx = entities::EntityContext { entities: std::collections::HashMap::new(), cls_to_class: std::collections::HashMap::new(), + filter, }; let mut paths = Paths::new(); let mut qf_mapper = decoder::QfMapper { @@ -130,7 +133,7 @@ where &mut qf_mapper, &mut baselines, &prop_controller, - &mut entity_states + &mut entity_states, )?; } DemoCommand::FullPacket => { @@ -144,7 +147,7 @@ where &mut qf_mapper, &mut baselines, &prop_controller, - &mut entity_states + &mut entity_states, )?; } // TODO @@ -231,7 +234,7 @@ fn parse_fullpacket( qf_mapper: &mut decoder::QfMapper, baselines: &mut std::collections::HashMap>, prop_controller: &propcontroller::PropController, - entity_states: &mut Vec + entity_states: &mut Vec, ) -> Result<(), FirstPassError> { let raw: crate::csgo_proto::CDemoFullPacket = prost::Message::decode(data)?; @@ -253,7 +256,7 @@ fn parse_fullpacket( qf_mapper, baselines, prop_controller, - entity_states + entity_states, )?; Ok(()) @@ -272,7 +275,7 @@ fn parse_packet( qf_mapper: &mut decoder::QfMapper, baselines: &mut std::collections::HashMap>, prop_controller: &propcontroller::PropController, - entity_states: &mut Vec + entity_states: &mut Vec, ) -> Result<(), FirstPassError> { let raw: crate::csgo_proto::CDemoPacket = prost::Message::decode(data)?; @@ -286,7 +289,7 @@ fn parse_packet( qf_mapper, baselines, prop_controller, - entity_states + entity_states, )?; Ok(()) @@ -302,7 +305,7 @@ fn inner_parse_packet( qf_mapper: &mut decoder::QfMapper, baselines: &mut std::collections::HashMap>, prop_controller: &propcontroller::PropController, - entity_states: &mut Vec + entity_states: &mut Vec, ) -> Result<(), FirstPassError> { let mut bitreader = crate::bitreader::Bitreader::new(raw.data()); @@ -360,61 +363,67 @@ fn inner_parse_packet( let raw: crate::csgo_proto::CsvcMsgPacketEntities = prost::Message::decode(msg_bytes.as_slice())?; - let mut bitreader = crate::bitreader::Bitreader::new(raw.entity_data()); - let mut entity_id: i32 = -1; - for _ in 0..raw.updated_entries() { - entity_id += 1 + (bitreader.read_u_bit_var()? as i32); + if entity_ctx.filter.enabled { + let mut bitreader = crate::bitreader::Bitreader::new(raw.entity_data()); + let mut entity_id: i32 = -1; + for _ in 0..raw.updated_entries() { + entity_id += 1 + (bitreader.read_u_bit_var()? as i32); + + match bitreader.read_nbits(2)? { + 0b01 | 0b11 => { + entity_ctx.entities.remove(&entity_id); + } + 0b10 => { + let cls = entity_ctx.create_entity(entity_id, &mut bitreader)?; + + if let Some(baseline_bytes) = baselines.get(&cls) { + let mut br = crate::bitreader::Bitreader::new(&baseline_bytes); + let state = update_entity( + entity_id, + &mut br, + entity_ctx, + paths, + qf_mapper, + prop_controller, + )?; + } - match bitreader.read_nbits(2)? { - 0b01 | 0b11 => { - entity_ctx.entities.remove(&entity_id); - } - 0b10 => { - let cls = entity_ctx.create_entity(entity_id, &mut bitreader)?; - - if let Some(baseline_bytes) = baselines.get(&cls) { - let mut br = crate::bitreader::Bitreader::new(&baseline_bytes); let state = update_entity( entity_id, - &mut br, + &mut bitreader, entity_ctx, paths, qf_mapper, prop_controller, )?; - } - - let state = update_entity( - entity_id, - &mut bitreader, - entity_ctx, - paths, - qf_mapper, - prop_controller, - )?; - entity_states.push(state); - } - 0b00 => { - if raw.has_pvs_vis_bits() > 0 { - if bitreader.read_nbits(2)? & 0x01 == 1 { - continue; + if let Some(state) = state { + entity_states.push(state); } } + 0b00 => { + if raw.has_pvs_vis_bits() > 0 { + if bitreader.read_nbits(2)? & 0x01 == 1 { + continue; + } + } - let state = update_entity( - entity_id, - &mut bitreader, - entity_ctx, - paths, - qf_mapper, - prop_controller, - )?; - entity_states.push(state); - } - unknown => { - panic!("{:?}", unknown); - } - }; + let state = update_entity( + entity_id, + &mut bitreader, + entity_ctx, + paths, + qf_mapper, + prop_controller, + )?; + if let Some(state) = state { + entity_states.push(state); + } + } + unknown => { + panic!("{:?}", unknown); + } + }; + } } } crate::netmessagetypes::NetmessageType::svc_UserCmds => {} @@ -506,23 +515,26 @@ fn update_entity( paths: &mut Paths, qf_mapper: &mut decoder::QfMapper, prop_controller: &propcontroller::PropController, -) -> Result { +) -> Result, FirstPassError> { let n_updates = fieldpath::parse_paths(bitreader, paths)?; - let (n_updated_values, entity_state) = entity_ctx.decode_entity_update( + let (n_updated_values, entity_state) = match entity_ctx.decode_entity_update( entity_id, bitreader, n_updates, paths, qf_mapper, prop_controller, - )?; + )? { + Some(s) => s, + None => return Ok(None), + }; if n_updated_values > 0 { // TODO // Gather extra information // gather_extra_info(entity_id, prop_controller)?; } - Ok(entity_state) + Ok(Some(entity_state)) } static HUFFMAN_LOOKUP_TABLE: std::sync::LazyLock> = std::sync::LazyLock::new(|| { diff --git a/src/parser/entities.rs b/src/parser/entities.rs index fbb3c23..ed54381 100644 --- a/src/parser/entities.rs +++ b/src/parser/entities.rs @@ -3,6 +3,7 @@ use super::{decoder, propcontroller, Class, Entity, FirstPassError, Paths}; pub struct EntityContext { pub entities: std::collections::HashMap, pub cls_to_class: std::collections::HashMap, + pub filter: EntityFilter, } #[derive(Debug, Clone)] @@ -19,16 +20,39 @@ pub struct EntityProp { pub value: super::variant::Variant, } +pub struct EntityFilter { + pub enabled: bool, + entity: Box bool>, +} + +impl EntityFilter { + pub fn all() -> Self { + Self { + enabled: true, + entity: Box::new(|_| true), + } + } + + pub fn disabled() -> Self { + Self { + enabled: false, + entity: Box::new(|_| false), + } + } +} + impl EntityContext { /// Returns the `cls_id` - pub fn create_entity(&mut self, entity_id: i32, bitreader: &mut crate::bitreader::Bitreader) -> Result { + pub fn create_entity( + &mut self, + entity_id: i32, + bitreader: &mut crate::bitreader::Bitreader, + ) -> Result { let cls_id: u32 = bitreader.read_nbits(8)?; let _serial = bitreader.read_nbits(17)?; let _unknown = bitreader.read_varint()?; - self.entities.insert(entity_id, Entity { - cls: cls_id, - }); + self.entities.insert(entity_id, Entity { cls: cls_id }); Ok(cls_id) } @@ -41,7 +65,7 @@ impl EntityContext { paths: &mut Paths, qf_mapper: &mut decoder::QfMapper, prop_controller: &propcontroller::PropController, - ) -> Result<(usize, EntityState), FirstPassError> { + ) -> Result, FirstPassError> { let entity = match self.entities.get_mut(&entity_id) { Some(e) => e, None => panic!("ID: {:?} - Entities: {:?}", entity_id, self.entities), @@ -73,10 +97,17 @@ impl EntityContext { } } - Ok((n_updates, EntityState { - class: class.name.clone(), - cls: entity.cls, - props: fields, - })) + if !(self.filter.entity)(class.name.as_str()) { + return Ok(None); + } + + Ok(Some(( + n_updates, + EntityState { + class: class.name.clone(), + cls: entity.cls, + props: fields, + }, + ))) } } diff --git a/src/parser/fieldpath.rs b/src/parser/fieldpath.rs index 57b91ee..9a79f56 100644 --- a/src/parser/fieldpath.rs +++ b/src/parser/fieldpath.rs @@ -103,51 +103,55 @@ impl FieldPath { } } - pub fn do_op(&mut self, bitreader: &mut crate::bitreader::Bitreader, symbol: u8) -> Result<(), super::FirstPassError> { + pub fn do_op( + &mut self, + bitreader: &mut crate::bitreader::Bitreader, + symbol: u8, + ) -> Result<(), super::FirstPassError> { use ops::*; match symbol { - 0 => plus_one(bitreader, self), - 1 => plus_two(bitreader, self), - 2 => plus_three(bitreader, self), - 3 => plus_four(bitreader, self), - 4 => plus_n(bitreader, self), - 5 => push_one_left_delta_zero_right_zero(bitreader, self), - 6 => push_one_left_delta_zero_right_non_zero(bitreader, self), - 7 => push_one_left_delta_one_right_zero(bitreader, self), - 8 => push_one_left_delta_one_right_non_zero(bitreader, self), - 9 => push_one_left_delta_n_right_zero(bitreader, self), - 10 => push_one_left_delta_n_right_non_zero(bitreader, self), - 11 => push_one_left_delta_n_right_non_zero_pack6_bits(bitreader, self), - 12 => push_one_left_delta_n_right_non_zero_pack8_bits(bitreader, self), - 13 => push_two_left_delta_zero(bitreader, self), - 14 => push_two_pack5_left_delta_zero(bitreader, self), - 15 => push_three_left_delta_zero(bitreader, self), - 16 => push_three_pack5_left_delta_zero(bitreader, self), - 17 => push_two_left_delta_one(bitreader, self), - 18 => push_two_pack5_left_delta_one(bitreader, self), - 19 => push_three_left_delta_one(bitreader, self), - 20 => push_three_pack5_left_delta_one(bitreader, self), - 21 => push_two_left_delta_n(bitreader, self), - 22 => push_two_pack5_left_delta_n(bitreader, self), - 23 => push_three_left_delta_n(bitreader, self), - 24 => push_three_pack5_left_delta_n(bitreader, self), - 25 => push_n(bitreader, self), - 26 => push_n_and_non_topological(bitreader, self), - 27 => pop_one_plus_one(bitreader, self), - 28 => pop_one_plus_n(bitreader, self), - 29 => pop_all_but_one_plus_one(bitreader, self), - 30 => pop_all_but_one_plus_n(bitreader, self), - 31 => pop_all_but_one_plus_n_pack3_bits(bitreader, self), - 32 => pop_all_but_one_plus_n_pack6_bits(bitreader, self), - 33 => pop_n_plus_one(bitreader, self), - 34 => pop_n_plus_n(bitreader, self), - 35 => pop_n_and_non_topographical(bitreader, self), - 36 => non_topo_complex(bitreader, self), - 37 => non_topo_penultimate_plus_one(bitreader, self), - 38 => non_topo_complex_pack4_bits(bitreader, self), - other => todo!("Other OP: {:?}", other), - } + 0 => plus_one(bitreader, self), + 1 => plus_two(bitreader, self), + 2 => plus_three(bitreader, self), + 3 => plus_four(bitreader, self), + 4 => plus_n(bitreader, self), + 5 => push_one_left_delta_zero_right_zero(bitreader, self), + 6 => push_one_left_delta_zero_right_non_zero(bitreader, self), + 7 => push_one_left_delta_one_right_zero(bitreader, self), + 8 => push_one_left_delta_one_right_non_zero(bitreader, self), + 9 => push_one_left_delta_n_right_zero(bitreader, self), + 10 => push_one_left_delta_n_right_non_zero(bitreader, self), + 11 => push_one_left_delta_n_right_non_zero_pack6_bits(bitreader, self), + 12 => push_one_left_delta_n_right_non_zero_pack8_bits(bitreader, self), + 13 => push_two_left_delta_zero(bitreader, self), + 14 => push_two_pack5_left_delta_zero(bitreader, self), + 15 => push_three_left_delta_zero(bitreader, self), + 16 => push_three_pack5_left_delta_zero(bitreader, self), + 17 => push_two_left_delta_one(bitreader, self), + 18 => push_two_pack5_left_delta_one(bitreader, self), + 19 => push_three_left_delta_one(bitreader, self), + 20 => push_three_pack5_left_delta_one(bitreader, self), + 21 => push_two_left_delta_n(bitreader, self), + 22 => push_two_pack5_left_delta_n(bitreader, self), + 23 => push_three_left_delta_n(bitreader, self), + 24 => push_three_pack5_left_delta_n(bitreader, self), + 25 => push_n(bitreader, self), + 26 => push_n_and_non_topological(bitreader, self), + 27 => pop_one_plus_one(bitreader, self), + 28 => pop_one_plus_n(bitreader, self), + 29 => pop_all_but_one_plus_one(bitreader, self), + 30 => pop_all_but_one_plus_n(bitreader, self), + 31 => pop_all_but_one_plus_n_pack3_bits(bitreader, self), + 32 => pop_all_but_one_plus_n_pack6_bits(bitreader, self), + 33 => pop_n_plus_one(bitreader, self), + 34 => pop_n_plus_n(bitreader, self), + 35 => pop_n_and_non_topographical(bitreader, self), + 36 => non_topo_complex(bitreader, self), + 37 => non_topo_penultimate_plus_one(bitreader, self), + 38 => non_topo_complex_pack4_bits(bitreader, self), + other => todo!("Other OP: {:?}", other), + } } } diff --git a/src/parser/sendtables.rs b/src/parser/sendtables.rs index 60cbaf6..4837f4c 100644 --- a/src/parser/sendtables.rs +++ b/src/parser/sendtables.rs @@ -90,8 +90,8 @@ impl ValueField { decoder, name: name.to_string(), prop_id: 0, - should_parse: false, - full_name: "None ".to_string() + name, + should_parse: true, + full_name: "CWorld.".to_string() + name, } } } @@ -597,7 +597,6 @@ mod tests { use pretty_assertions::assert_eq; #[test] - #[ignore = "Testing"] fn parse_ancient_example_msg() { use decoder::Decoder::*; use Field::*; @@ -625,23 +624,23 @@ mod tests { Value(ValueField { decoder: FloatSimulationTimeDecoder, name: "m_flAnimTime".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_flAnimTime".to_string(), + should_parse: true, + prop_id: 27022, + full_name: "CWorld.m_flAnimTime".to_string(), }), Value(ValueField { decoder: FloatSimulationTimeDecoder, name: "m_flSimulationTime".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_flSimulationTime".to_string(), + should_parse: true, + prop_id: 27023, + full_name: "CWorld.m_flSimulationTime".to_string(), }), Value(ValueField { decoder: UnsignedDecoder, name: "m_hOwnerEntity".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_hOwnerEntity".to_string(), + should_parse: true, + prop_id: 27024, + full_name: "CWorld.m_hOwnerEntity".to_string(), }), Pointer(PointerField { decoder: BooleanDecoder, @@ -651,142 +650,142 @@ mod tests { Value(ValueField { decoder: UnsignedDecoder, name: "m_cellX".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_cellX".to_string(), + should_parse: true, + prop_id: 27025, + full_name: "CWorld.CBodyComponentBaseModelEntity.m_cellX".to_string(), }), Value(ValueField { decoder: UnsignedDecoder, name: "m_cellY".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_cellY".to_string(), + should_parse: true, + prop_id: 27026, + full_name: "CWorld.CBodyComponentBaseModelEntity.m_cellY".to_string(), }), Value(ValueField { decoder: UnsignedDecoder, name: "m_cellZ".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_cellZ".to_string(), + should_parse: true, + prop_id: 27027, + full_name: "CWorld.CBodyComponentBaseModelEntity.m_cellZ".to_string(), }), Value(ValueField { decoder: QuantalizedFloatDecoder(0), name: "m_vecX".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_vecX".to_string(), + should_parse: true, + prop_id: 27028, + full_name: "CWorld.CBodyComponentBaseModelEntity.m_vecX".to_string(), }), Value(ValueField { decoder: QuantalizedFloatDecoder(1), name: "m_vecY".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_vecY".to_string(), + should_parse: true, + prop_id: 27029, + full_name: "CWorld.CBodyComponentBaseModelEntity.m_vecY".to_string(), }), Value(ValueField { decoder: QuantalizedFloatDecoder(2), name: "m_vecZ".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_vecZ".to_string(), + should_parse: true, + prop_id: 27030, + full_name: "CWorld.CBodyComponentBaseModelEntity.m_vecZ".to_string(), }), Value(ValueField { decoder: UnsignedDecoder, name: "m_hParent".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_hParent".to_string(), + should_parse: true, + prop_id: 27031, + full_name: "CWorld.CBodyComponentBaseModelEntity.m_hParent".to_string(), }), Value(ValueField { decoder: QanglePresDecoder, name: "m_angRotation".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_angRotation".to_string(), + should_parse: true, + prop_id: 27032, + full_name: "CWorld.CBodyComponentBaseModelEntity.m_angRotation".to_string(), }), Value(ValueField { decoder: NoscaleDecoder, name: "m_flScale".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_flScale".to_string(), + should_parse: true, + prop_id: 27033, + full_name: "CWorld.CBodyComponentBaseModelEntity.m_flScale".to_string(), }), Value(ValueField { decoder: UnsignedDecoder, name: "m_name".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_name".to_string(), + should_parse: true, + prop_id: 27034, + full_name: "CWorld.CBodyComponentBaseModelEntity.m_name".to_string(), }), Value(ValueField { decoder: UnsignedDecoder, name: "m_hierarchyAttachName".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_hierarchyAttachName".to_string(), + should_parse: true, + prop_id: 27035, + full_name: "CWorld.CBodyComponentBaseModelEntity.m_hierarchyAttachName".to_string(), }), Value(ValueField { decoder: Unsigned64Decoder, name: "m_hModel".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_hModel".to_string(), + should_parse: true, + prop_id: 27036, + full_name: "CWorld.CBodyComponentBaseModelEntity.m_hModel".to_string(), }), Value(ValueField { decoder: BooleanDecoder, name: "m_bClientClothCreationSuppressed".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_bClientClothCreationSuppressed".to_string(), + should_parse: true, + prop_id: 27037, + full_name: "CWorld.CBodyComponentBaseModelEntity.m_bClientClothCreationSuppressed".to_string(), }), Value(ValueField { decoder: Unsigned64Decoder, name: "m_MeshGroupMask".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_MeshGroupMask".to_string(), + should_parse: true, + prop_id: 27038, + full_name: "CWorld.CBodyComponentBaseModelEntity.m_MeshGroupMask".to_string(), }), Value(ValueField { decoder: SignedDecoder, name: "m_nIdealMotionType".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_nIdealMotionType".to_string(), + should_parse: true, + prop_id: 27039, + full_name: "CWorld.CBodyComponentBaseModelEntity.m_nIdealMotionType".to_string(), }), Value(ValueField { decoder: BooleanDecoder, name: "m_bIsAnimationEnabled".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_bIsAnimationEnabled".to_string(), + should_parse: true, + prop_id: 27040, + full_name: "CWorld.CBodyComponentBaseModelEntity.m_bIsAnimationEnabled".to_string(), }), Value(ValueField { decoder: BooleanDecoder, name: "m_bUseParentRenderBounds".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_bUseParentRenderBounds".to_string(), + should_parse: true, + prop_id: 27041, + full_name: "CWorld.CBodyComponentBaseModelEntity.m_bUseParentRenderBounds".to_string(), }), Value(ValueField { decoder: UnsignedDecoder, name: "m_materialGroup".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_materialGroup".to_string(), + should_parse: true, + prop_id: 27042, + full_name: "CWorld.CBodyComponentBaseModelEntity.m_materialGroup".to_string(), }), Value(ValueField { decoder: UnsignedDecoder, name: "m_nHitboxSet".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_nHitboxSet".to_string(), + should_parse: true, + prop_id: 27043, + full_name: "CWorld.CBodyComponentBaseModelEntity.m_nHitboxSet".to_string(), }), Value(ValueField { decoder: UnsignedDecoder, name: "m_nOutsideWorld".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_nOutsideWorld".to_string(), + should_parse: true, + prop_id: 27044, + full_name: "CWorld.CBodyComponentBaseModelEntity.m_nOutsideWorld".to_string(), }), ] .to_vec(), @@ -799,9 +798,9 @@ mod tests { fields: [Value(ValueField { decoder: SignedDecoder, name: "m_nameStringableIndex".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_nameStringableIndex".to_string(), + should_parse: true, + prop_id: 27045, + full_name: "CWorld.CEntityIdentity.m_nameStringableIndex".to_string(), })] .to_vec(), }, @@ -809,121 +808,121 @@ mod tests { Value(ValueField { decoder: BooleanDecoder, name: "m_bVisibleinPVS".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_bVisibleinPVS".to_string(), + should_parse: true, + prop_id: 27046, + full_name: "CWorld.m_bVisibleinPVS".to_string(), }), Value(ValueField { decoder: BooleanDecoder, name: "m_bIsPlatform".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_bIsPlatform".to_string(), + should_parse: true, + prop_id: 27047, + full_name: "CWorld.m_bIsPlatform".to_string(), }), Value(ValueField { decoder: Unsigned64Decoder, name: "m_MoveCollide".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_MoveCollide".to_string(), + should_parse: true, + prop_id: 27048, + full_name: "CWorld.m_MoveCollide".to_string(), }), Value(ValueField { decoder: Unsigned64Decoder, name: "m_MoveType".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_MoveType".to_string(), + should_parse: true, + prop_id: 27049, + full_name: "CWorld.m_MoveType".to_string(), }), Value(ValueField { decoder: UnsignedDecoder, name: "m_nSubclassID".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_nSubclassID".to_string(), + should_parse: true, + prop_id: 27050, + full_name: "CWorld.m_nSubclassID".to_string(), }), Value(ValueField { decoder: NoscaleDecoder, name: "m_flCreateTime".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_flCreateTime".to_string(), + should_parse: true, + prop_id: 27051, + full_name: "CWorld.m_flCreateTime".to_string(), }), Value(ValueField { decoder: UnsignedDecoder, name: "m_ubInterpolationFrame".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_ubInterpolationFrame".to_string(), + should_parse: true, + prop_id: 27052, + full_name: "CWorld.m_ubInterpolationFrame".to_string(), }), Value(ValueField { decoder: UnsignedDecoder, name: "m_iTeamNum".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_iTeamNum".to_string(), + should_parse: true, + prop_id: 27053, + full_name: "CWorld.m_iTeamNum".to_string(), }), Value(ValueField { decoder: UnsignedDecoder, name: "m_hEffectEntity".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_hEffectEntity".to_string(), + should_parse: true, + prop_id: 27054, + full_name: "CWorld.m_hEffectEntity".to_string(), }), Value(ValueField { decoder: UnsignedDecoder, name: "m_fEffects".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_fEffects".to_string(), + should_parse: true, + prop_id: 27055, + full_name: "CWorld.m_fEffects".to_string(), }), Value(ValueField { decoder: FloatCoordDecoder, name: "m_flElasticity".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_flElasticity".to_string(), + should_parse: true, + prop_id: 27056, + full_name: "CWorld.m_flElasticity".to_string(), }), Value(ValueField { decoder: BooleanDecoder, name: "m_bAnimatedEveryTick".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_bAnimatedEveryTick".to_string(), + should_parse: true, + prop_id: 27057, + full_name: "CWorld.m_bAnimatedEveryTick".to_string(), }), Value(ValueField { decoder: NoscaleDecoder, name: "m_flNavIgnoreUntilTime".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_flNavIgnoreUntilTime".to_string(), + should_parse: true, + prop_id: 27058, + full_name: "CWorld.m_flNavIgnoreUntilTime".to_string(), }), Value(ValueField { decoder: UnsignedDecoder, name: "m_nBloodType".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_nBloodType".to_string(), + should_parse: true, + prop_id: 27059, + full_name: "CWorld.m_nBloodType".to_string(), }), Value(ValueField { decoder: Unsigned64Decoder, name: "m_nRenderMode".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_nRenderMode".to_string(), + should_parse: true, + prop_id: 27060, + full_name: "CWorld.m_nRenderMode".to_string(), }), Value(ValueField { decoder: Unsigned64Decoder, name: "m_nRenderFX".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_nRenderFX".to_string(), + should_parse: true, + prop_id: 27061, + full_name: "CWorld.m_nRenderFX".to_string(), }), Value(ValueField { decoder: UnsignedDecoder, name: "m_clrRender".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_clrRender".to_string(), + should_parse: true, + prop_id: 27062, + full_name: "CWorld.m_clrRender".to_string(), }), Vector(VectorField { field_enum: Box::new(Serializer(SerializerField { @@ -933,16 +932,16 @@ mod tests { Value(ValueField { decoder: UnsignedDecoder, name: "m_ID".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_ID".to_string(), + should_parse: true, + prop_id: 27065, + full_name: "CWorld.EntityRenderAttribute_t.m_ID".to_string(), }), Value(ValueField { decoder: VectorNoscaleDecoder, name: "m_Values".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_Values".to_string(), + should_parse: true, + prop_id: 27066, + full_name: "CWorld.EntityRenderAttribute_t.m_Values".to_string(), }), ] .to_vec(), @@ -953,304 +952,304 @@ mod tests { Value(ValueField { decoder: BooleanDecoder, name: "m_bRenderToCubemaps".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_bRenderToCubemaps".to_string(), + should_parse: true, + prop_id: 27067, + full_name: "CWorld.m_bRenderToCubemaps".to_string(), }), Value(ValueField { decoder: Unsigned64Decoder, name: "m_nInteractsAs".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_nInteractsAs".to_string(), + should_parse: true, + prop_id: 27068, + full_name: "CWorld.m_nInteractsAs".to_string(), }), Value(ValueField { decoder: Unsigned64Decoder, name: "m_nInteractsWith".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_nInteractsWith".to_string(), + should_parse: true, + prop_id: 27069, + full_name: "CWorld.m_nInteractsWith".to_string(), }), Value(ValueField { decoder: Unsigned64Decoder, name: "m_nInteractsExclude".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_nInteractsExclude".to_string(), + should_parse: true, + prop_id: 27070, + full_name: "CWorld.m_nInteractsExclude".to_string(), }), Value(ValueField { decoder: UnsignedDecoder, name: "m_nEntityId".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_nEntityId".to_string(), + should_parse: true, + prop_id: 27071, + full_name: "CWorld.m_nEntityId".to_string(), }), Value(ValueField { decoder: UnsignedDecoder, name: "m_nOwnerId".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_nOwnerId".to_string(), + should_parse: true, + prop_id: 27072, + full_name: "CWorld.m_nOwnerId".to_string(), }), Value(ValueField { decoder: UnsignedDecoder, name: "m_nHierarchyId".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_nHierarchyId".to_string(), + should_parse: true, + prop_id: 27073, + full_name: "CWorld.m_nHierarchyId".to_string(), }), Value(ValueField { decoder: UnsignedDecoder, name: "m_nCollisionGroup".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_nCollisionGroup".to_string(), + should_parse: true, + prop_id: 27074, + full_name: "CWorld.m_nCollisionGroup".to_string(), }), Value(ValueField { decoder: UnsignedDecoder, name: "m_nCollisionFunctionMask".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_nCollisionFunctionMask".to_string(), + should_parse: true, + prop_id: 27075, + full_name: "CWorld.m_nCollisionFunctionMask".to_string(), }), Value(ValueField { decoder: VectorNoscaleDecoder, name: "m_vecMins".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_vecMins".to_string(), + should_parse: true, + prop_id: 27076, + full_name: "CWorld.m_vecMins".to_string(), }), Value(ValueField { decoder: VectorNoscaleDecoder, name: "m_vecMaxs".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_vecMaxs".to_string(), + should_parse: true, + prop_id: 27077, + full_name: "CWorld.m_vecMaxs".to_string(), }), Value(ValueField { decoder: UnsignedDecoder, name: "m_usSolidFlags".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_usSolidFlags".to_string(), + should_parse: true, + prop_id: 27078, + full_name: "CWorld.m_usSolidFlags".to_string(), }), Value(ValueField { decoder: Unsigned64Decoder, name: "m_nSolidType".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_nSolidType".to_string(), + should_parse: true, + prop_id: 27079, + full_name: "CWorld.m_nSolidType".to_string(), }), Value(ValueField { decoder: UnsignedDecoder, name: "m_triggerBloat".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_triggerBloat".to_string(), + should_parse: true, + prop_id: 27080, + full_name: "CWorld.m_triggerBloat".to_string(), }), Value(ValueField { decoder: Unsigned64Decoder, name: "m_nSurroundType".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_nSurroundType".to_string(), + should_parse: true, + prop_id: 27081, + full_name: "CWorld.m_nSurroundType".to_string(), }), Value(ValueField { decoder: UnsignedDecoder, name: "m_CollisionGroup".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_CollisionGroup".to_string(), + should_parse: true, + prop_id: 27082, + full_name: "CWorld.m_CollisionGroup".to_string(), }), Value(ValueField { decoder: UnsignedDecoder, name: "m_nEnablePhysics".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_nEnablePhysics".to_string(), + should_parse: true, + prop_id: 27083, + full_name: "CWorld.m_nEnablePhysics".to_string(), }), Value(ValueField { decoder: VectorNoscaleDecoder, name: "m_vecSpecifiedSurroundingMins".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_vecSpecifiedSurroundingMins".to_string(), + should_parse: true, + prop_id: 27084, + full_name: "CWorld.m_vecSpecifiedSurroundingMins".to_string(), }), Value(ValueField { decoder: VectorNoscaleDecoder, name: "m_vecSpecifiedSurroundingMaxs".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_vecSpecifiedSurroundingMaxs".to_string(), + should_parse: true, + prop_id: 27085, + full_name: "CWorld.m_vecSpecifiedSurroundingMaxs".to_string(), }), Value(ValueField { decoder: VectorNoscaleDecoder, name: "m_vCapsuleCenter1".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_vCapsuleCenter1".to_string(), + should_parse: true, + prop_id: 27086, + full_name: "CWorld.m_vCapsuleCenter1".to_string(), }), Value(ValueField { decoder: VectorNoscaleDecoder, name: "m_vCapsuleCenter2".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_vCapsuleCenter2".to_string(), + should_parse: true, + prop_id: 27087, + full_name: "CWorld.m_vCapsuleCenter2".to_string(), }), Value(ValueField { decoder: NoscaleDecoder, name: "m_flCapsuleRadius".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_flCapsuleRadius".to_string(), + should_parse: true, + prop_id: 27088, + full_name: "CWorld.m_flCapsuleRadius".to_string(), }), Value(ValueField { decoder: SignedDecoder, name: "m_iGlowType".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_iGlowType".to_string(), + should_parse: true, + prop_id: 27089, + full_name: "CWorld.m_iGlowType".to_string(), }), Value(ValueField { decoder: SignedDecoder, name: "m_iGlowTeam".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_iGlowTeam".to_string(), + should_parse: true, + prop_id: 27090, + full_name: "CWorld.m_iGlowTeam".to_string(), }), Value(ValueField { decoder: SignedDecoder, name: "m_nGlowRange".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_nGlowRange".to_string(), + should_parse: true, + prop_id: 27091, + full_name: "CWorld.m_nGlowRange".to_string(), }), Value(ValueField { decoder: SignedDecoder, name: "m_nGlowRangeMin".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_nGlowRangeMin".to_string(), + should_parse: true, + prop_id: 27092, + full_name: "CWorld.m_nGlowRangeMin".to_string(), }), Value(ValueField { decoder: UnsignedDecoder, name: "m_glowColorOverride".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_glowColorOverride".to_string(), + should_parse: true, + prop_id: 27093, + full_name: "CWorld.m_glowColorOverride".to_string(), }), Value(ValueField { decoder: BooleanDecoder, name: "m_bFlashing".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_bFlashing".to_string(), + should_parse: true, + prop_id: 27094, + full_name: "CWorld.m_bFlashing".to_string(), }), Value(ValueField { decoder: NoscaleDecoder, name: "m_flGlowTime".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_flGlowTime".to_string(), + should_parse: true, + prop_id: 27095, + full_name: "CWorld.m_flGlowTime".to_string(), }), Value(ValueField { decoder: NoscaleDecoder, name: "m_flGlowStartTime".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_flGlowStartTime".to_string(), + should_parse: true, + prop_id: 27096, + full_name: "CWorld.m_flGlowStartTime".to_string(), }), Value(ValueField { decoder: BooleanDecoder, name: "m_bEligibleForScreenHighlight".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_bEligibleForScreenHighlight".to_string(), + should_parse: true, + prop_id: 27097, + full_name: "CWorld.m_bEligibleForScreenHighlight".to_string(), }), Value(ValueField { decoder: NoscaleDecoder, name: "m_flGlowBackfaceMult".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_flGlowBackfaceMult".to_string(), + should_parse: true, + prop_id: 27098, + full_name: "CWorld.m_flGlowBackfaceMult".to_string(), }), Value(ValueField { decoder: NoscaleDecoder, name: "m_fadeMinDist".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_fadeMinDist".to_string(), + should_parse: true, + prop_id: 27099, + full_name: "CWorld.m_fadeMinDist".to_string(), }), Value(ValueField { decoder: NoscaleDecoder, name: "m_fadeMaxDist".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_fadeMaxDist".to_string(), + should_parse: true, + prop_id: 27100, + full_name: "CWorld.m_fadeMaxDist".to_string(), }), Value(ValueField { decoder: NoscaleDecoder, name: "m_flFadeScale".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_flFadeScale".to_string(), + should_parse: true, + prop_id: 27101, + full_name: "CWorld.m_flFadeScale".to_string(), }), Value(ValueField { decoder: NoscaleDecoder, name: "m_flShadowStrength".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_flShadowStrength".to_string(), + should_parse: true, + prop_id: 27102, + full_name: "CWorld.m_flShadowStrength".to_string(), }), Value(ValueField { decoder: UnsignedDecoder, name: "m_nObjectCulling".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_nObjectCulling".to_string(), + should_parse: true, + prop_id: 27103, + full_name: "CWorld.m_nObjectCulling".to_string(), }), Value(ValueField { decoder: SignedDecoder, name: "m_nAddDecal".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_nAddDecal".to_string(), + should_parse: true, + prop_id: 27104, + full_name: "CWorld.m_nAddDecal".to_string(), }), Value(ValueField { decoder: VectorNoscaleDecoder, name: "m_vDecalPosition".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_vDecalPosition".to_string(), + should_parse: true, + prop_id: 27105, + full_name: "CWorld.m_vDecalPosition".to_string(), }), Value(ValueField { decoder: VectorNoscaleDecoder, name: "m_vDecalForwardAxis".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_vDecalForwardAxis".to_string(), + should_parse: true, + prop_id: 27106, + full_name: "CWorld.m_vDecalForwardAxis".to_string(), }), Value(ValueField { decoder: NoscaleDecoder, name: "m_flDecalHealBloodRate".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_flDecalHealBloodRate".to_string(), + should_parse: true, + prop_id: 27107, + full_name: "CWorld.m_flDecalHealBloodRate".to_string(), }), Value(ValueField { decoder: NoscaleDecoder, name: "m_flDecalHealHeightRate".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_flDecalHealHeightRate".to_string(), + should_parse: true, + prop_id: 27108, + full_name: "CWorld.m_flDecalHealHeightRate".to_string(), }), Vector(VectorField { field_enum: Box::new(Value(ValueField { decoder: UnsignedDecoder, name: "m_ConfigEntitiesToPropagateMaterialDecalsTo".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_ConfigEntitiesToPropagateMaterialDecalsTo".to_string(), + should_parse: true, + prop_id: 27109, + full_name: "CWorld.m_ConfigEntitiesToPropagateMaterialDecalsTo".to_string(), })), decoder: UnsignedDecoder, }), @@ -1258,9 +1257,9 @@ mod tests { field_enum: Box::new(Value(ValueField { decoder: UnsignedDecoder, name: "m_bvDisabledHitGroups".to_string(), - should_parse: false, - prop_id: 0, - full_name: "None m_bvDisabledHitGroups".to_string(), + should_parse: true, + prop_id: 27110, + full_name: "CWorld.m_bvDisabledHitGroups".to_string(), })), length: 1, }), diff --git a/tests/parse.rs b/tests/parse.rs index 11d54d6..bdf1e2c 100644 --- a/tests/parse.rs +++ b/tests/parse.rs @@ -9,7 +9,11 @@ fn mirage_1() { let frame_iter = csdemo::FrameIterator::parse(container.inner); assert_eq!(123333, frame_iter.count()); - let output = csdemo::parser::parse(csdemo::FrameIterator::parse(container.inner)).unwrap(); + let output = csdemo::parser::parse( + csdemo::FrameIterator::parse(container.inner), + csdemo::parser::EntityFilter::disabled(), + ) + .unwrap(); assert_eq!("de_mirage", output.header.map_name()); @@ -47,7 +51,11 @@ fn ancient_1() { let frame_iter = csdemo::FrameIterator::parse(container.inner); assert_eq!(116676, frame_iter.count()); - let output = csdemo::parser::parse(csdemo::FrameIterator::parse(container.inner)).unwrap(); + let output = csdemo::parser::parse( + csdemo::FrameIterator::parse(container.inner), + csdemo::parser::EntityFilter::disabled(), + ) + .unwrap(); assert_eq!("de_ancient", output.header.map_name());