1
0
Fork 0
mirror of https://codeberg.org/demostf/parser.git synced 2026-06-04 02:24:12 +02:00
This commit is contained in:
Robin Appelman 2019-03-06 22:20:51 +01:00
commit 9f622385ca
20 changed files with 132 additions and 173 deletions

View file

@ -28,7 +28,6 @@ pub struct DataTablePacket {
impl Parse for DataTablePacket {
fn parse(stream: &mut Stream, _state: &ParserState) -> Result<Self> {
let tick = stream.read()?;
let start = stream.pos();
let len = stream.read_int::<usize>(32)?;
let mut packet_data = stream.read_bits(len * 8)?;
@ -41,7 +40,7 @@ impl Parse for DataTablePacket {
let mut array_element_prop = None;
let mut props = Vec::with_capacity(prop_count);
for i in 0..prop_count {
for _ in 0..prop_count {
let prop: SendPropDefinition =
SendPropDefinition::read(&mut packet_data, name.clone())?;
if prop.flags.contains(SendPropFlag::InsideArray) {

View file

@ -2,7 +2,7 @@ use bitstream_reader::{BitRead, BitSize, LazyBitRead, LittleEndian};
use crate::demo::message::Message;
use crate::demo::vector::Vector;
use crate::{Parse, ParseError, ParserState, ReadResult, Result, Stream};
use crate::{Parse, ParserState, ReadResult, Result, Stream};
#[derive(Debug)]
pub struct MessagePacket {

View file

@ -3,7 +3,6 @@ use std::fmt;
use bitstream_reader::{BitRead, LittleEndian};
use crate::demo::message::stringtable::StringTableMeta;
use crate::demo::sendprop::SendPropFlag::Exclude;
use crate::{Parse, ParseError, ParserState, ReadResult, Result, Stream};
#[derive(BitRead, Clone, Copy, Debug)]
@ -88,7 +87,7 @@ impl BitRead<LittleEndian> for StringTableEntry {
fn read(stream: &mut Stream) -> ReadResult<Self> {
Ok(StringTableEntry {
text: Some(stream.read()?),
extra_data: stream.read()?
extra_data: stream.read()?,
})
}
}
@ -100,7 +99,8 @@ impl fmt::Debug for StringTableEntry {
Some(extra_data) => write!(
f,
"StringTableEntry{{ text: \"{}\" extra_data: {} bytes }}",
self.text(), extra_data.byte_len
self.text(),
extra_data.byte_len
),
}
}
@ -115,7 +115,6 @@ pub struct StringTablePacket {
impl Parse for StringTablePacket {
fn parse(stream: &mut Stream, _state: &ParserState) -> Result<Self> {
let tick = stream.read_int(32)?;
let start = stream.pos();
let length: usize = stream.read_int(32)?;
let mut packet_data = stream.read_bits(length * 8)?;
let count: usize = packet_data.read_int(8)?;