1
0
Fork 0
mirror of https://codeberg.org/demostf/parser.git synced 2026-06-03 18:24:05 +02:00

better skips

This commit is contained in:
Robin Appelman 2020-01-19 14:50:35 +01:00
commit f5504cd682
4 changed files with 25 additions and 27 deletions

View file

@ -235,8 +235,6 @@ impl PacketEntitiesMessage {
props: &mut Vec<SendProp>,
) -> Result<()> {
let mut index = -1;
//let mut props: HashMap<i32, SendProp> = HashMap::new();
//let mut props = Vec::with_capacity(8);
while stream.read()? {
let diff: u32 = read_bit_var(stream)?;
@ -260,18 +258,19 @@ impl PacketEntitiesMessage {
}
Ok(())
//Ok(props.into_iter().map(|(_, prop)| prop).collect())
}
}
impl ParseBitSkip for PacketEntitiesMessage {
fn parse_skip(stream: &mut Stream) -> Result<()> {
let _: u16 = stream.read_sized(11)?;
let _: Option<u32> = stream.read()?;
let _: u8 = stream.read_sized(1)?;
let _: u16 = stream.read_sized(11)?;
stream.skip_bits(11)?;
if stream.read()? {
stream.skip_bits(32)?;
}
stream.skip_bits(12)?;
let length: u32 = stream.read_sized(20)?;
let _: bool = stream.read()?;
stream.skip_bits(length as usize).map_err(ParseError::from)
stream
.skip_bits(length as usize + 1)
.map_err(ParseError::from)
}
}

View file

@ -297,6 +297,10 @@ impl BitRead<LittleEndian> for SendPropFlags {
// since all 16 bits worth of flags are used there are no invalid flags
Ok(SendPropFlags(BitFlags::from_bits_truncate(stream.read()?)))
}
fn bit_size() -> Option<usize> {
Some(16)
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@ -400,7 +404,6 @@ impl SendPropValue {
.map(|int| int as i64)
} else if definition.flags.contains(SendPropFlag::Unsigned) {
let unsigned: u32 = stream.read_sized(definition.bit_count.unwrap_or(32) as usize)?;
//const MAX: u32 = std::i32::MAX as u32;
Ok(unsigned as i64)
} else {
stream