From 94bf57efde81ece9899d73e3ed5e75b324295ad9 Mon Sep 17 00:00:00 2001 From: Lol3rrr Date: Sat, 21 Sep 2024 00:34:00 +0200 Subject: [PATCH 1/2] Reduce deep nesting and partially improve error handling Reduce deep nesting in certain cases, where there was only a single happy path anyway to make the code easier to read and less confusing. Try to improve error handling by switch elaborate matches with map_err and ?-operator --- src/parser/Cargo.lock | 8 +- src/parser/src/first_pass/frameparser.rs | 12 +- src/parser/src/first_pass/sendtables.rs | 188 +++++++++++----------- src/parser/src/first_pass/stringtables.rs | 83 ++++------ 4 files changed, 131 insertions(+), 160 deletions(-) diff --git a/src/parser/Cargo.lock b/src/parser/Cargo.lock index 6f9e77a3..77af82ac 100644 --- a/src/parser/Cargo.lock +++ b/src/parser/Cargo.lock @@ -301,9 +301,9 @@ dependencies = [ [[package]] name = "protobuf" -version = "3.5.0" +version = "3.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df67496db1a89596beaced1579212e9b7c53c22dca1d9745de00ead76573d514" +checksum = "0bcc343da15609eaecd65f8aa76df8dc4209d325131d8219358c0aaaebab0bf6" dependencies = [ "bytes", "once_cell", @@ -313,9 +313,9 @@ dependencies = [ [[package]] name = "protobuf-support" -version = "3.5.0" +version = "3.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70e2d30ab1878b2e72d1e2fc23ff5517799c9929e2cf81a8516f9f4dcf2b9cf3" +checksum = "f0766e3675a627c327e4b3964582594b0e8741305d628a98a5de75a1d15f99b9" dependencies = [ "thiserror", ] diff --git a/src/parser/src/first_pass/frameparser.rs b/src/parser/src/first_pass/frameparser.rs index 8ef30d39..04daef3b 100644 --- a/src/parser/src/first_pass/frameparser.rs +++ b/src/parser/src/first_pass/frameparser.rs @@ -55,9 +55,9 @@ impl FrameParser { frame_ends_at: ptr, size: size as usize, tick: tick as i32, - frame_starts_at: frame_starts_at, - is_compressed: is_compressed, - demo_cmd: demo_cmd, + frame_starts_at, + is_compressed, + demo_cmd, }) } #[inline(always)] @@ -75,9 +75,9 @@ impl FrameParser { frame_ends_at: *ptr, size: size as usize, tick: tick as i32, - frame_starts_at: frame_starts_at, - is_compressed: is_compressed, - demo_cmd: demo_cmd, + frame_starts_at, + is_compressed, + demo_cmd, }) } diff --git a/src/parser/src/first_pass/sendtables.rs b/src/parser/src/first_pass/sendtables.rs index b08fad34..d3bdb5d7 100644 --- a/src/parser/src/first_pass/sendtables.rs +++ b/src/parser/src/first_pass/sendtables.rs @@ -165,31 +165,41 @@ impl<'a> FirstPassParser<'a> { big: &CSVCMsg_FlattenedSerializer, serializers: &AHashMap, ) -> Result { - match big.symbols.get(serializer_msg.serializer_name_sym() as usize) { + let sid = match big.symbols.get(serializer_msg.serializer_name_sym() as usize) { + Some(sid) => sid, None => return Err(DemoParserError::MalformedMessage), - Some(sid) => { - let mut fields_this_ser: Vec = vec![Field::None; serializer_msg.fields_index.len()]; - for (idx, field_this_ser) in fields_this_ser.iter_mut().enumerate() { - if let Some(fi) = serializer_msg.fields_index.get(idx) { - let fi = *fi as usize; - if let Some(Some(f)) = field_data.get_mut(fi) { - if f.field_enum_type.is_none() { - f.field_enum_type = Some(create_field(&sid, f, serializers)?) - } - if let Some(Some(f)) = &field_data.get(fi) { - if let Some(field) = &f.field_enum_type { - *field_this_ser = field.clone() - } - } - }; - } + }; + + // TODO + // This loop could probably just be an iterator over serializer_msg.fields_index that returns + // a Field::None by default but could also return whatever is the found field (which + // currently overwrites the entry) and then collect that iterator into a vec + let mut fields_this_ser: Vec = vec![Field::None; serializer_msg.fields_index.len()]; + for (idx, field_this_ser) in fields_this_ser.iter_mut().enumerate() { + let fi = match serializer_msg.fields_index.get(idx) { + Some(i) => *i as usize, + None => continue, + }; + + let f = match field_data.get_mut(fi) { + Some(Some(f)) => f, + _ => continue, + }; + + if f.field_enum_type.is_none() { + f.field_enum_type = Some(create_field(&sid, f, serializers)?) + } + if let Some(Some(f)) = &field_data.get(fi) { + if let Some(field) = &f.field_enum_type { + *field_this_ser = field.clone() } - Ok(Serializer { - name: sid.clone(), - fields: fields_this_ser, - }) } } + + Ok(Serializer { + name: sid.clone(), + fields: fields_this_ser, + }) } fn generate_field_data( @@ -207,19 +217,14 @@ impl<'a> FirstPassParser<'a> { let mut field = field_from_msg(&msg, &big, ft.clone())?; field.category = find_category(&mut field); - let f = field.find_decoder(qf_mapper); - field.decoder = f; + field.decoder = field.find_decoder(qf_mapper); match field.var_name.as_str() { - "m_PredFloatVariables" => field.decoder = NoscaleDecoder, - "m_OwnerOnlyPredNetFloatVariables" => field.decoder = NoscaleDecoder, - "m_OwnerOnlyPredNetVectorVariables" => field.decoder = VectorNoscaleDecoder, - "m_PredVectorVariables" => field.decoder = VectorNoscaleDecoder, + "m_PredFloatVariables" | "m_OwnerOnlyPredNetFloatVariables" => field.decoder = NoscaleDecoder, + "m_OwnerOnlyPredNetVectorVariables" | "m_PredVectorVariables" => field.decoder = VectorNoscaleDecoder, + "m_pGameModeRules" => field.decoder = GameModeRulesDecoder, _ => {} }; - if field.var_name == "m_pGameModeRules" { - field.decoder = GameModeRulesDecoder - } if field.encoder == "qangle_precise" { field.decoder = QanglePresDecoder; } @@ -320,7 +325,7 @@ impl ArrayField { pub fn new(field_enum: Field, length: usize) -> ArrayField { ArrayField { field_enum: Box::new(field_enum), - length: length, + length, } } } @@ -333,7 +338,7 @@ impl PointerField { }; PointerField { serializer: serializer.clone(), - decoder: decoder, + decoder, } } } @@ -347,7 +352,7 @@ impl SerializerField { impl ValueField { pub fn new(decoder: Decoder, name: &str) -> ValueField { ValueField { - decoder: decoder, + decoder, name: name.to_string(), prop_id: 0, should_parse: false, @@ -397,9 +402,9 @@ pub fn field_from_msg( let f = ConstructorField { field_enum_type: None, bitcount: field.bit_count(), - var_name: var_name, - var_type: var_type, - send_node: send_node, + var_name, + var_type, + send_node, serializer_name: ser_name, encoder: enc_name, encode_flags: field.encode_flags(), @@ -455,54 +460,53 @@ pub fn get_decoder_from_field(field: &Field) -> Result } pub fn get_propinfo(field: &Field, path: &FieldPath) -> Option { - let info = match field { - Field::Value(v) => Some(FieldInfo { + let mut fi = match field { + Field::Value(v) => FieldInfo { decoder: v.decoder, should_parse: v.should_parse, prop_id: v.prop_id, - }), + }, Field::Vector(v) => match field.get_inner(0) { - Ok(Field::Value(inner)) => Some(FieldInfo { + Ok(Field::Value(inner)) => FieldInfo { decoder: v.decoder, should_parse: inner.should_parse, prop_id: inner.prop_id, - }), - _ => None, + }, + _ => return None, }, - _ => None, + _ => return None, }; // Flatten vector props - if let Some(mut fi) = info { - if fi.prop_id == MY_WEAPONS_OFFSET { - if path.last == 1 { - } else { - fi.prop_id = MY_WEAPONS_OFFSET + path.path[2] as u32 + 1; - } + if fi.prop_id == MY_WEAPONS_OFFSET { + if path.last == 1 { + // TODO + // Why is this part here? + } else { + fi.prop_id = MY_WEAPONS_OFFSET + path.path[2] as u32 + 1; } - if fi.prop_id == WEAPON_SKIN_ID { - fi.prop_id = WEAPON_SKIN_ID + path.path[1] as u32; + } + if fi.prop_id == WEAPON_SKIN_ID { + fi.prop_id = WEAPON_SKIN_ID + path.path[1] as u32; + } + if path.path[1] != 1 { + if fi.prop_id >= ITEM_PURCHASE_COUNT && fi.prop_id < ITEM_PURCHASE_COUNT + FLATTENED_VEC_MAX_LEN { + fi.prop_id = ITEM_PURCHASE_COUNT + path.path[2] as u32; } - if path.path[1] != 1 { - if fi.prop_id >= ITEM_PURCHASE_COUNT && fi.prop_id < ITEM_PURCHASE_COUNT + FLATTENED_VEC_MAX_LEN { - fi.prop_id = ITEM_PURCHASE_COUNT + path.path[2] as u32; - } - if fi.prop_id >= ITEM_PURCHASE_DEF_IDX && fi.prop_id < ITEM_PURCHASE_DEF_IDX + FLATTENED_VEC_MAX_LEN { - fi.prop_id = ITEM_PURCHASE_DEF_IDX + path.path[2] as u32; - } - if fi.prop_id >= ITEM_PURCHASE_COST && fi.prop_id < ITEM_PURCHASE_COST + FLATTENED_VEC_MAX_LEN { - fi.prop_id = ITEM_PURCHASE_COST + path.path[2] as u32; - } - if fi.prop_id >= ITEM_PURCHASE_HANDLE && fi.prop_id < ITEM_PURCHASE_HANDLE + FLATTENED_VEC_MAX_LEN { - fi.prop_id = ITEM_PURCHASE_HANDLE + path.path[2] as u32; - } - if fi.prop_id >= ITEM_PURCHASE_NEW_DEF_IDX && fi.prop_id < ITEM_PURCHASE_NEW_DEF_IDX + FLATTENED_VEC_MAX_LEN { - fi.prop_id = ITEM_PURCHASE_NEW_DEF_IDX + path.path[2] as u32; - } + if fi.prop_id >= ITEM_PURCHASE_DEF_IDX && fi.prop_id < ITEM_PURCHASE_DEF_IDX + FLATTENED_VEC_MAX_LEN { + fi.prop_id = ITEM_PURCHASE_DEF_IDX + path.path[2] as u32; + } + if fi.prop_id >= ITEM_PURCHASE_COST && fi.prop_id < ITEM_PURCHASE_COST + FLATTENED_VEC_MAX_LEN { + fi.prop_id = ITEM_PURCHASE_COST + path.path[2] as u32; + } + if fi.prop_id >= ITEM_PURCHASE_HANDLE && fi.prop_id < ITEM_PURCHASE_HANDLE + FLATTENED_VEC_MAX_LEN { + fi.prop_id = ITEM_PURCHASE_HANDLE + path.path[2] as u32; + } + if fi.prop_id >= ITEM_PURCHASE_NEW_DEF_IDX && fi.prop_id < ITEM_PURCHASE_NEW_DEF_IDX + FLATTENED_VEC_MAX_LEN { + fi.prop_id = ITEM_PURCHASE_NEW_DEF_IDX + path.path[2] as u32; } - return Some(fi); } - return None; + return Some(fi); } fn create_field( @@ -570,8 +574,8 @@ fn find_field_type(name: &str, field_type_map: &mut AHashMap) }; let mut ft = FieldType { - base_type: base_type, - pointer: pointer, + base_type, + pointer, generic_type: None, count: None, element_type: None, @@ -675,42 +679,30 @@ impl ConstructorField { } pub fn find_category(field: &mut ConstructorField) -> FieldCategory { - let is_pointer = is_pointer(&field); - let is_array = is_array(&field); - let is_vector = is_vector(&field); - - if is_pointer { - FieldCategory::Pointer - } else if is_vector { - FieldCategory::Vector - } else if is_array { - FieldCategory::Array - } else { - FieldCategory::Value + if is_pointer(&field) { + return FieldCategory::Pointer + } + if is_vector(&field) { + return FieldCategory::Vector } + if is_array(&field) { + return FieldCategory::Array + } + FieldCategory::Value } pub fn is_pointer(field: &ConstructorField) -> bool { - match field.field_type.pointer { - true => true, - false => match field.field_type.base_type.as_str() { - "CBodyComponent" => true, - "CLightComponent" => true, - "CPhysicsComponent" => true, - "CRenderComponent" => true, - "CPlayerLocalData" => true, - _ => false, - }, + if field.field_type.pointer { + return true; } + + matches!(field.field_type.base_type.as_str(), "CBodyComponent" | "CLightComponent" | "CPhysicsComponent" | "CRenderComponent" | "CPlayerLocalData") } pub fn is_vector(field: &ConstructorField) -> bool { if field.serializer_name.is_some() { return true; - }; - match field.field_type.base_type.as_str() { - "CUtlVector" => true, - "CNetworkUtlVectorBase" => true, - _ => false, } + + matches!(field.field_type.base_type.as_str(), "CUtlVector" | "CNetworkUtlVectorBase") } pub fn is_array(field: &ConstructorField) -> bool { if field.field_type.count.is_some() { diff --git a/src/parser/src/first_pass/stringtables.rs b/src/parser/src/first_pass/stringtables.rs index 63a5d357..23efecec 100644 --- a/src/parser/src/first_pass/stringtables.rs +++ b/src/parser/src/first_pass/stringtables.rs @@ -34,38 +34,29 @@ pub struct UserInfo { impl<'a> FirstPassParser<'a> { pub fn update_string_table(&mut self, bytes: &[u8]) -> Result<(), DemoParserError> { - let table: CSVCMsg_UpdateStringTable = match Message::parse_from_bytes(&bytes) { - Ok(table) => table, - Err(_) => return Err(DemoParserError::MalformedMessage), - }; - match self.string_tables.get(table.table_id() as usize) { - Some(st) => self.parse_string_table( - table.string_data().to_vec(), - table.num_changed_entries(), - st.name.clone(), - st.user_data_fixed, - st.user_data_size, - st.flags, - st.var_bit_counts, - )?, - None => return Err(DemoParserError::StringTableNotFound), - } + let table: CSVCMsg_UpdateStringTable = Message::parse_from_bytes(&bytes).map_err(|_| DemoParserError::MalformedMessage)?; + + let st = self.string_tables.get(table.table_id() as usize).ok_or(DemoParserError::StringTableNotFound)?; + self.parse_string_table( + table.string_data().to_vec(), + table.num_changed_entries(), + st.name.clone(), + st.user_data_fixed, + st.user_data_size, + st.flags, + st.var_bit_counts, + )?; Ok(()) } pub fn parse_create_stringtable(&mut self, bytes: &[u8]) -> Result<(), DemoParserError> { - let table: CSVCMsg_CreateStringTable = match Message::parse_from_bytes(&bytes) { - Ok(table) => table, - Err(_) => return Err(DemoParserError::MalformedMessage), - }; + let table: CSVCMsg_CreateStringTable = Message::parse_from_bytes(&bytes).map_err(|_| DemoParserError::MalformedMessage)?; + if !(table.name() == "instancebaseline" || table.name() == "userinfo") { return Ok(()); } let bytes = match table.data_compressed() { - true => match snap::raw::Decoder::new().decompress_vec(table.string_data()) { - Ok(bytes) => bytes, - Err(_) => return Err(DemoParserError::MalformedMessage), - }, + true => snap::raw::Decoder::new().decompress_vec(table.string_data()).map_err(|_| DemoParserError::MalformedMessage)?, false => table.string_data().to_vec(), }; self.parse_string_table( @@ -175,28 +166,25 @@ impl<'a> FirstPassParser<'a> { }; } items.push(StringTableEntry { - idx: idx, - key: key, - value: value, + idx, + key, + value, }); } } self.string_tables.push(StringTable { data: items, - name: name, - user_data_size: user_data_size, + name, + user_data_size, user_data_fixed: udf, - flags: flags, + flags, var_bit_counts: variant_bit_count, }); Ok(()) } } pub fn parse_userinfo(bytes: &[u8]) -> Result { - let player = match CMsgPlayerInfo::parse_from_bytes(bytes) { - Err(_e) => return Err(DemoParserError::MalformedMessage), - Ok(player) => player, - }; + let player = CMsgPlayerInfo::parse_from_bytes(bytes).map_err(|_| DemoParserError::MalformedMessage)?; Ok(UserInfo { is_hltv: player.ishltv(), steamid: player.xuid(), @@ -207,10 +195,7 @@ pub fn parse_userinfo(bytes: &[u8]) -> Result { impl<'a> SecondPassParser<'a> { pub fn update_string_table(&mut self, bytes: &[u8]) -> Result<(), DemoParserError> { - let table: CSVCMsg_UpdateStringTable = match Message::parse_from_bytes(&bytes) { - Ok(table) => table, - Err(_) => return Err(DemoParserError::MalformedMessage), - }; + let table: CSVCMsg_UpdateStringTable = Message::parse_from_bytes(&bytes).map_err(|_| DemoParserError::MalformedMessage)?; match self.string_tables.get(table.table_id() as usize) { Some(st) => self.parse_string_table( table.string_data().to_vec(), @@ -228,15 +213,9 @@ impl<'a> SecondPassParser<'a> { Ok(()) } pub fn parse_create_stringtable(&mut self, bytes: &[u8]) -> Result<(), DemoParserError> { - let table: CSVCMsg_CreateStringTable = match Message::parse_from_bytes(&bytes) { - Ok(table) => table, - Err(_) => return Err(DemoParserError::MalformedMessage), - }; + let table: CSVCMsg_CreateStringTable = Message::parse_from_bytes(&bytes).map_err(|_| DemoParserError::MalformedMessage)?; let bytes = match table.data_compressed() { - true => match snap::raw::Decoder::new().decompress_vec(table.string_data()) { - Ok(bytes) => bytes, - Err(_) => return Err(DemoParserError::MalformedMessage), - }, + true => snap::raw::Decoder::new().decompress_vec(table.string_data()).map_err(|_| DemoParserError::MalformedMessage)?, false => table.string_data().to_vec(), }; self.parse_string_table( @@ -345,18 +324,18 @@ impl<'a> SecondPassParser<'a> { }; } items.push(StringTableEntry { - idx: idx, - key: key, - value: value, + idx, + key, + value, }); } } self.string_tables.push(StringTable { data: items, - name: name, - user_data_size: user_data_size, + name, + user_data_size, user_data_fixed: udf, - flags: flags, + flags, var_bit_counts: variant_bit_count, }); Ok(()) From 04f043a987b92455909fd047306c31a8f2305788 Mon Sep 17 00:00:00 2001 From: Lol3rrr Date: Sat, 21 Sep 2024 14:58:38 +0200 Subject: [PATCH 2/2] Shorten some struct constructors and switch &mut Vec to &mut [] Shortened some more struct constructors from 'field: field' to just 'field'. Change some usage from '&mut Vec<>' to '&mut []' as recommended by rust itself, if we are not using any Vec specific api --- src/parser/src/first_pass/parser.rs | 6 ++--- src/parser/src/first_pass/prop_controller.rs | 10 ++++----- src/parser/src/second_pass/collect_data.rs | 10 ++++----- src/parser/src/second_pass/entities.rs | 4 ++-- src/parser/src/second_pass/game_events.rs | 22 +++++++++---------- .../src/second_pass/other_netmessages.rs | 4 ++-- src/parser/src/second_pass/parser.rs | 6 ++--- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/parser/src/first_pass/parser.rs b/src/parser/src/first_pass/parser.rs index b13963d5..3a3090f5 100644 --- a/src/parser/src/first_pass/parser.rs +++ b/src/parser/src/first_pass/parser.rs @@ -126,9 +126,9 @@ impl<'a> FirstPassParser<'a> { Ok(Frame { size: size as usize, - frame_starts_at: frame_starts_at, - is_compressed: is_compressed, - demo_cmd: demo_cmd, + frame_starts_at, + is_compressed, + demo_cmd, tick: self.tick, }) } diff --git a/src/parser/src/first_pass/prop_controller.rs b/src/parser/src/first_pass/prop_controller.rs index 77b0b024..45bcdab4 100644 --- a/src/parser/src/first_pass/prop_controller.rs +++ b/src/parser/src/first_pass/prop_controller.rs @@ -133,19 +133,19 @@ impl PropController { ) -> Self { PropController { id: NORMAL_PROP_BASEID, - wanted_player_props: wanted_player_props, + wanted_player_props, wanted_prop_ids: vec![], prop_infos: vec![], name_to_id: AHashMap::default(), special_ids: SpecialIDs::new(), id_to_name: AHashMap::default(), name_to_special_id: AHashMap::default(), - wanted_other_props: wanted_other_props, - real_name_to_og_name: real_name_to_og_name, + wanted_other_props, + real_name_to_og_name, 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_states, wanted_prop_state_infos: vec![], } } @@ -442,7 +442,7 @@ impl PropController { }; } } - fn traverse_fields(&mut self, fields: &mut Vec, ser_name: String, path_og: Vec) { + fn traverse_fields(&mut self, fields: &mut [Field], ser_name: String, path_og: Vec) { for (idx, f) in fields.iter_mut().enumerate() { let mut path = path_og.clone(); path.push(idx as i32); diff --git a/src/parser/src/second_pass/collect_data.rs b/src/parser/src/second_pass/collect_data.rs index 32aef23a..0697cdb1 100644 --- a/src/parser/src/second_pass/collect_data.rs +++ b/src/parser/src/second_pass/collect_data.rs @@ -285,8 +285,8 @@ impl<'a> SecondPassParser<'a> { }; self.projectile_records.push(ProjectileRecord { - steamid: steamid, - name: name, + steamid, + name, x: float_x, y: float_y, z: float_z, @@ -1010,10 +1010,10 @@ impl<'a> SecondPassParser<'a> { self.players.insert( e, PlayerMetaData { - name: name, - team_num: team_num, + name, + team_num, player_entity_id: player_entid, - steamid: steamid, + steamid, controller_entid: Some(*entity_id), }, ); diff --git a/src/parser/src/second_pass/entities.rs b/src/parser/src/second_pass/entities.rs index a45f2cb5..25b8bf03 100644 --- a/src/parser/src/second_pass/entities.rs +++ b/src/parser/src/second_pass/entities.rs @@ -315,9 +315,9 @@ impl<'a> SecondPassParser<'a> { }; let entity = Entity { entity_id: *entity_id, - cls_id: cls_id, + cls_id, props: AHashMap::with_capacity(0), - entity_type: entity_type, + entity_type, }; if self.entities.len() as i32 <= *entity_id { // if corrupt, this can cause oom allocations diff --git a/src/parser/src/second_pass/game_events.rs b/src/parser/src/second_pass/game_events.rs index fcaeae12..19d1a242 100644 --- a/src/parser/src/second_pass/game_events.rs +++ b/src/parser/src/second_pass/game_events.rs @@ -432,7 +432,7 @@ impl<'a> SecondPassParser<'a> { }; EventField { name: prefix.to_owned() + "_steamid", - data: data, + data, } } pub fn player_from_steamid32(&self, steamid32: i32) -> Option { @@ -476,7 +476,7 @@ impl<'a> SecondPassParser<'a> { fields.extend(self.find_non_player_props()); let ge = GameEvent { name: "server_cvar".to_string(), - fields: fields, + fields, tick: self.tick, }; self.game_events.push(ge); @@ -575,7 +575,7 @@ impl<'a> SecondPassParser<'a> { fields.extend(self.find_non_player_props()); let ge = GameEvent { name: "item_sold".to_string(), - fields: fields, + fields, tick: self.tick, }; self.game_events.push(ge); @@ -742,7 +742,7 @@ impl<'a> SecondPassParser<'a> { fields.extend(self.find_non_player_props()); let ge = GameEvent { name: "item_purchase".to_string(), - fields: fields, + fields, tick: self.tick, }; self.game_events.push(ge); @@ -819,7 +819,7 @@ impl<'a> SecondPassParser<'a> { }); let ge = GameEvent { name: "round_end".to_string(), - fields: fields, + fields, tick: self.tick, }; self.game_events.push(ge); @@ -855,7 +855,7 @@ impl<'a> SecondPassParser<'a> { }); let ge = GameEvent { name: "round_officially_ended".to_string(), - fields: fields, + fields, tick: self.tick, }; self.game_events.push(ge); @@ -879,7 +879,7 @@ impl<'a> SecondPassParser<'a> { }); let ge = GameEvent { name: "cs_win_panel_match".to_string(), - fields: fields, + fields, tick: self.tick, }; self.game_events.push(ge); @@ -929,7 +929,7 @@ impl<'a> SecondPassParser<'a> { fields.extend(self.find_non_player_props()); let ge = GameEvent { name: "chat_message".to_string(), - fields: fields, + fields, tick: self.tick, }; self.game_events.push(ge); @@ -956,7 +956,7 @@ impl<'a> SecondPassParser<'a> { fields.extend(self.find_non_player_props()); let ge = GameEvent { name: "server_message".to_string(), - fields: fields, + fields, tick: self.tick, }; self.game_events.push(ge); @@ -981,7 +981,7 @@ impl<'a> SecondPassParser<'a> { fields.extend(self.find_non_player_props()); let ge = GameEvent { name: "round_start".to_string(), - fields: fields, + fields, tick: self.tick, }; self.game_events.push(ge); @@ -1037,7 +1037,7 @@ impl<'a> SecondPassParser<'a> { fields.extend(self.find_non_player_props()); let ge = GameEvent { name: "rank_update".to_string(), - fields: fields, + fields, tick: self.tick, }; self.game_events.push(ge); diff --git a/src/parser/src/second_pass/other_netmessages.rs b/src/parser/src/second_pass/other_netmessages.rs index 812657a1..c698fbf4 100644 --- a/src/parser/src/second_pass/other_netmessages.rs +++ b/src/parser/src/second_pass/other_netmessages.rs @@ -31,7 +31,7 @@ impl<'a> SecondPassParser<'a> { Some(name) => Some(name.to_string()), None => None, }; - self.item_drops.push(EconItem { account_id: item.accountid, item_id: item.itemid, def_index: item.defindex, paint_index: item.paintindex, rarity: item.rarity, quality: item.quality, paint_seed: item.paintseed, paint_wear: item.paintwear, quest_id: item.questid, dropreason: item.dropreason, custom_name: item.customname.clone(), inventory: item.inventory, ent_idx: item.entindex, steamid: None, item_name: item_name, skin_name: skin_name }); + self.item_drops.push(EconItem { account_id: item.accountid, item_id: item.itemid, def_index: item.defindex, paint_index: item.paintindex, rarity: item.rarity, quality: item.quality, paint_seed: item.paintseed, paint_wear: item.paintwear, quest_id: item.questid, dropreason: item.dropreason, custom_name: item.customname.clone(), inventory: item.inventory, ent_idx: item.entindex, steamid: None, item_name, skin_name }); } Ok(()) } @@ -70,7 +70,7 @@ impl<'a> SecondPassParser<'a> { Some(name) => Some(name.to_string()), None => None, }; - self.skins.push(EconItem { account_id: item.accountid, item_id: item.itemid, def_index: item.defindex, paint_index: item.paintindex, rarity: item.rarity, quality: item.quality, paint_seed: item.paintseed, paint_wear: item.paintwear, quest_id: item.questid, dropreason: item.dropreason, custom_name: item.customname.clone(), inventory: item.inventory, ent_idx: item.entindex, steamid: player.xuid, item_name: item_name, skin_name: skin_name }); + self.skins.push(EconItem { account_id: item.accountid, item_id: item.itemid, def_index: item.defindex, paint_index: item.paintindex, rarity: item.rarity, quality: item.quality, paint_seed: item.paintseed, paint_wear: item.paintwear, quest_id: item.questid, dropreason: item.dropreason, custom_name: item.customname.clone(), inventory: item.inventory, ent_idx: item.entindex, steamid: player.xuid, item_name, skin_name }); } } } diff --git a/src/parser/src/second_pass/parser.rs b/src/parser/src/second_pass/parser.rs index effdc4d2..3f77b4f5 100644 --- a/src/parser/src/second_pass/parser.rs +++ b/src/parser/src/second_pass/parser.rs @@ -123,9 +123,9 @@ impl<'a> SecondPassParser<'a> { Ok(Frame { size: size as usize, - frame_starts_at: frame_starts_at, - is_compressed: is_compressed, - demo_cmd: demo_cmd, + frame_starts_at, + is_compressed, + demo_cmd, tick: self.tick, }) }