mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-03 18:24:05 +02:00
early sendprop cleanup
This commit is contained in:
parent
2602e23de8
commit
e3ddd9f3e2
3 changed files with 36 additions and 28 deletions
|
|
@ -18,10 +18,10 @@ impl EntityId {
|
|||
#[derive(BitRead, Clone, Copy, Debug)]
|
||||
#[discriminant_bits = 3]
|
||||
pub enum PVS {
|
||||
PRESERVE = 0,
|
||||
ENTER = 1,
|
||||
LEAVE = 2,
|
||||
DELETE = 4,
|
||||
Preserve = 0,
|
||||
Leave = 1,
|
||||
Enter = 2,
|
||||
Delete = 3,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -79,3 +79,15 @@ impl ParseBitSkip for PacketEntitiesMessage {
|
|||
stream.skip_bits(length as usize).map_err(ParseError::from)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct EntityUpdate {
|
||||
props: Vec<SendProp>
|
||||
}
|
||||
|
||||
impl Parse for EntityUpdate {
|
||||
fn parse(stream: &mut Stream, _state: &ParserState) -> Result<Self> {
|
||||
Ok(EntityUpdate {
|
||||
props: Vec::new()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -29,7 +29,7 @@ impl Parse for SendTable {
|
|||
|
||||
for _ in 0..prop_count {
|
||||
let prop: SendPropDefinition =
|
||||
SendPropDefinition::read(stream, name.clone())?;
|
||||
SendPropDefinition::read(stream)?;
|
||||
if prop.flags.contains(SendPropFlag::InsideArray) {
|
||||
if array_element_prop.is_some()
|
||||
|| prop.flags.contains(SendPropFlag::ChangesOften)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use bitstream_reader::{BitRead, LittleEndian};
|
|||
use enumflags2::BitFlags;
|
||||
use enumflags2_derive::EnumFlags;
|
||||
|
||||
use crate::{ReadResult, Result, Stream};
|
||||
use crate::{ReadResult, Result, Stream, Parse};
|
||||
|
||||
use super::packet::datatable::SendTable;
|
||||
use super::vector::{Vector, VectorXY};
|
||||
|
|
@ -17,14 +17,29 @@ pub struct SendPropDefinition {
|
|||
pub high_value: Option<f32>,
|
||||
pub bit_count: Option<u32>,
|
||||
pub original_bit_count: Option<u32>,
|
||||
pub table: Option<SendTable>,
|
||||
pub element_count: Option<u16>,
|
||||
pub array_property: Option<Box<SendPropDefinition>>,
|
||||
pub owner_table_name: String,
|
||||
}
|
||||
|
||||
impl SendPropDefinition {
|
||||
pub fn read(stream: &mut Stream, owner_table_name: String) -> Result<Self> {
|
||||
pub fn with_array_property(self, array_property: Self) -> Self {
|
||||
SendPropDefinition {
|
||||
prop_type: self.prop_type,
|
||||
name: self.name,
|
||||
flags: self.flags,
|
||||
exclude_dt_name: self.exclude_dt_name,
|
||||
low_value: self.low_value,
|
||||
high_value: self.high_value,
|
||||
bit_count: self.bit_count,
|
||||
original_bit_count: self.original_bit_count,
|
||||
element_count: self.element_count,
|
||||
array_property: Some(Box::new(array_property)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl BitRead<LittleEndian> for SendPropDefinition {
|
||||
fn read(stream: &mut Stream) -> ReadResult<Self> {
|
||||
let prop_type = SendPropType::read(stream)?;
|
||||
let name = stream.read_string(None)?;
|
||||
let flags = SendPropFlags::read(stream)?;
|
||||
|
|
@ -67,29 +82,10 @@ impl SendPropDefinition {
|
|||
high_value,
|
||||
bit_count,
|
||||
original_bit_count,
|
||||
table: None,
|
||||
element_count,
|
||||
array_property: None,
|
||||
owner_table_name,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn with_array_property(self, array_property: Self) -> Self {
|
||||
SendPropDefinition {
|
||||
prop_type: self.prop_type,
|
||||
name: self.name,
|
||||
flags: self.flags,
|
||||
exclude_dt_name: self.exclude_dt_name,
|
||||
low_value: self.low_value,
|
||||
high_value: self.high_value,
|
||||
bit_count: self.bit_count,
|
||||
original_bit_count: self.original_bit_count,
|
||||
table: None,
|
||||
element_count: self.element_count,
|
||||
array_property: Some(Box::new(array_property)),
|
||||
owner_table_name: self.owner_table_name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(BitRead, Copy, Clone, PartialEq, Debug)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue