Skip to content

Commit

Permalink
Need to parse fullpacket userinfo (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
LaihoE authored Nov 13, 2023
1 parent 4653ef1 commit a243950
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 2 deletions.
Binary file modified src/node/tests/zipped_testdata.zip
Binary file not shown.
10 changes: 10 additions & 0 deletions src/parser/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::parser_thread_settings::*;
use crate::parser_threads::demo_cmd_type_from_int;
use crate::prop_controller::PropController;
use crate::read_bits::Bitreader;
use crate::stringtables::parse_userinfo;
use crate::stringtables::StringTable;
use crate::stringtables::UserInfo;
use crate::variants::PropColumn;
Expand Down Expand Up @@ -191,6 +192,15 @@ impl Parser {
self.baselines.insert(k, i.data.as_ref().unwrap().clone());
}
}
if item.table_name == Some("userinfo".to_string()) {
for i in &item.items {
if let Ok(player) = parse_userinfo(&i.data()) {
if player.steamid != 0 {
self.stringtable_players.insert(player.steamid, player);
}
}
}
}
}
Ok(())
}
Expand Down
10 changes: 10 additions & 0 deletions src/parser/src/parser_threads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::netmessage_types::netmessage_type_from_int;
use crate::netmessage_types::NetmessageType;
use crate::parser_thread_settings::ParserThread;
use crate::read_bits::Bitreader;
use crate::stringtables::parse_userinfo;
use bitter::BitReader;
use csgoproto::demo::*;
use csgoproto::netmessages::*;
Expand Down Expand Up @@ -149,6 +150,15 @@ impl ParserThread {
self.baselines.insert(k, i.data.as_ref().unwrap().clone());
}
}
if item.table_name == Some("userinfo".to_string()) {
for i in &item.items {
if let Ok(player) = parse_userinfo(&i.data()) {
if player.steamid != 0 {
self.stringtable_players.insert(player.steamid, player);
}
}
}
}
}
let p = full_packet.packet.0.unwrap();
let mut bitreader = Bitreader::new(p.data());
Expand Down
2 changes: 1 addition & 1 deletion src/parser/src/stringtables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl Parser {
Ok(())
}
}
fn parse_userinfo(bytes: &[u8]) -> Result<UserInfo, DemoParserError> {
pub fn parse_userinfo(bytes: &[u8]) -> Result<UserInfo, DemoParserError> {
let player = match CMsgPlayerInfo::parse_from_bytes(bytes) {
Err(_e) => return Err(DemoParserError::MalformedMessage),
Ok(player) => player,
Expand Down
5 changes: 4 additions & 1 deletion src/python/tests/gen_test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,8 @@ def gen_event_with_prop_tests():
wanted_prop = "is_alive"
gen_prop_test(wanted_prop)"""

wanted_props = ["velocity", "velocity_X", "velocity_Y", "velocity_Z"]
for prop in wanted_props:
gen_prop_test(prop)

gen_event_with_prop_tests()
# gen_event_with_prop_tests()
Binary file modified src/python/tests/zipped_testdata.zip
Binary file not shown.

0 comments on commit a243950

Please sign in to comment.