mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-03 18:24:05 +02:00
encode props in order
This commit is contained in:
parent
a8d395d39b
commit
f72e84dc1a
2 changed files with 11 additions and 4 deletions
|
|
@ -423,6 +423,7 @@ impl PacketEntitiesMessage {
|
|||
return Err(ParseError::PropIndexOutOfBounds {
|
||||
index,
|
||||
prop_count: send_table.flattened_props.len(),
|
||||
table: send_table.name.to_string(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -438,13 +439,14 @@ impl PacketEntitiesMessage {
|
|||
) -> Result<()> {
|
||||
let mut last_index: i32 = -1;
|
||||
|
||||
let mut props: Vec<&SendProp> = props.into_iter().collect();
|
||||
props.sort_by(|a, b| a.index.cmp(&b.index));
|
||||
|
||||
for prop in props {
|
||||
true.write(stream)?;
|
||||
|
||||
let index = prop.index as usize;
|
||||
if index >= send_table.flattened_props.len() {
|
||||
dbg!(&send_table.name);
|
||||
}
|
||||
|
||||
let definition =
|
||||
send_table
|
||||
.flattened_props
|
||||
|
|
@ -452,6 +454,7 @@ impl PacketEntitiesMessage {
|
|||
.ok_or(ParseError::PropIndexOutOfBounds {
|
||||
index: index as i32,
|
||||
prop_count: send_table.flattened_props.len(),
|
||||
table: send_table.name.to_string(),
|
||||
})?;
|
||||
write_bit_var((index as i32 - last_index - 1) as u32, stream)?;
|
||||
last_index = index as i32;
|
||||
|
|
|
|||
|
|
@ -72,7 +72,11 @@ pub enum ParseError {
|
|||
_0,
|
||||
_1
|
||||
)]
|
||||
PropIndexOutOfBounds { index: i32, prop_count: usize },
|
||||
PropIndexOutOfBounds {
|
||||
index: i32,
|
||||
prop_count: usize,
|
||||
table: String,
|
||||
},
|
||||
#[error(display = "An attempt was made to update an unknown entity: {}", _0)]
|
||||
UnknownEntity(EntityId),
|
||||
#[error(display = "No sendprop definition found for property")]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue