From 2049facdf6cf208942bc0af3f945433e9bc379bd Mon Sep 17 00:00:00 2001 From: Laiho Date: Tue, 21 Nov 2023 16:28:23 +0200 Subject: [PATCH 1/2] fix stringtables in wasm --- src/parser/src/parser_threads.rs | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/parser/src/parser_threads.rs b/src/parser/src/parser_threads.rs index 2c1c2c39..e9afc784 100644 --- a/src/parser/src/parser_threads.rs +++ b/src/parser/src/parser_threads.rs @@ -17,12 +17,16 @@ use EDemoCommands::*; impl ParserThread { pub fn start(&mut self) -> Result<(), DemoParserError> { let started_at = self.ptr; + loop { let cmd = self.read_varint()?; let tick = self.read_varint()?; let size = self.read_varint()?; self.tick = tick as i32; + if self.tick == 130404 { + println!("{:?}", tick); + } self.packets_parsed += 1; if self.ptr + size as usize >= self.bytes.get_len() { @@ -50,10 +54,12 @@ impl ParserThread { DEM_Packet => self.parse_packet(&bytes), DEM_FullPacket => { match self.parse_all_packets { - true => {} + true => { + self.parse_full_packet(&bytes, false)?; + } false => { if self.fullpackets_parsed == 0 && started_at != 16 { - self.parse_full_packet(&bytes)?; + self.parse_full_packet(&bytes, true)?; self.fullpackets_parsed += 1; } else { break; @@ -62,7 +68,9 @@ impl ParserThread { } Ok(()) } - DEM_Stop => break, + DEM_Stop => { + break; + } _ => Ok(()), }; ok?; @@ -138,7 +146,9 @@ impl ParserThread { self.net_tick = message.tick(); Ok(()) } - pub fn parse_full_packet(&mut self, bytes: &[u8]) -> Result<(), DemoParserError> { + pub fn parse_full_packet(&mut self, bytes: &[u8], should_parse_entities: bool) -> Result<(), DemoParserError> { + self.string_tables = vec![]; + let full_packet: CDemoFullPacket = match Message::parse_from_bytes(bytes) { Err(_e) => return Err(DemoParserError::MalformedMessage), Ok(p) => p, @@ -169,7 +179,13 @@ impl ParserThread { let msg_bytes = bitreader.read_n_bytes(size as usize)?; let ok = match netmessage_type_from_int(msg_type as i32) { - svc_PacketEntities => self.parse_packet_ents(&msg_bytes), + svc_PacketEntities => { + if should_parse_entities { + self.parse_packet_ents(&msg_bytes)?; + } + Ok(()) + } + // svc_PacketEntities => self.parse_packet_ents(&msg_bytes), svc_CreateStringTable => self.parse_create_stringtable(&msg_bytes), svc_UpdateStringTable => self.update_string_table(&msg_bytes), CS_UM_SendPlayerItemDrops => self.parse_item_drops(&msg_bytes), From eaaad7d74b126df0c722a2f3bfc07975f1958bac Mon Sep 17 00:00:00 2001 From: Laiho Date: Tue, 21 Nov 2023 16:30:46 +0200 Subject: [PATCH 2/2] rm debug stuff --- src/parser/src/parser_threads.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/parser/src/parser_threads.rs b/src/parser/src/parser_threads.rs index e9afc784..2e62a296 100644 --- a/src/parser/src/parser_threads.rs +++ b/src/parser/src/parser_threads.rs @@ -24,9 +24,6 @@ impl ParserThread { let size = self.read_varint()?; self.tick = tick as i32; - if self.tick == 130404 { - println!("{:?}", tick); - } self.packets_parsed += 1; if self.ptr + size as usize >= self.bytes.get_len() { @@ -68,9 +65,7 @@ impl ParserThread { } Ok(()) } - DEM_Stop => { - break; - } + DEM_Stop => break, _ => Ok(()), }; ok?; @@ -185,7 +180,6 @@ impl ParserThread { } Ok(()) } - // svc_PacketEntities => self.parse_packet_ents(&msg_bytes), svc_CreateStringTable => self.parse_create_stringtable(&msg_bytes), svc_UpdateStringTable => self.update_string_table(&msg_bytes), CS_UM_SendPlayerItemDrops => self.parse_item_drops(&msg_bytes),