mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-03 10:14:06 +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 {
|
return Err(ParseError::PropIndexOutOfBounds {
|
||||||
index,
|
index,
|
||||||
prop_count: send_table.flattened_props.len(),
|
prop_count: send_table.flattened_props.len(),
|
||||||
|
table: send_table.name.to_string(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -438,13 +439,14 @@ impl PacketEntitiesMessage {
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let mut last_index: i32 = -1;
|
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 {
|
for prop in props {
|
||||||
true.write(stream)?;
|
true.write(stream)?;
|
||||||
|
|
||||||
let index = prop.index as usize;
|
let index = prop.index as usize;
|
||||||
if index >= send_table.flattened_props.len() {
|
|
||||||
dbg!(&send_table.name);
|
|
||||||
}
|
|
||||||
let definition =
|
let definition =
|
||||||
send_table
|
send_table
|
||||||
.flattened_props
|
.flattened_props
|
||||||
|
|
@ -452,6 +454,7 @@ impl PacketEntitiesMessage {
|
||||||
.ok_or(ParseError::PropIndexOutOfBounds {
|
.ok_or(ParseError::PropIndexOutOfBounds {
|
||||||
index: index as i32,
|
index: index as i32,
|
||||||
prop_count: send_table.flattened_props.len(),
|
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)?;
|
write_bit_var((index as i32 - last_index - 1) as u32, stream)?;
|
||||||
last_index = index as i32;
|
last_index = index as i32;
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,11 @@ pub enum ParseError {
|
||||||
_0,
|
_0,
|
||||||
_1
|
_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)]
|
#[error(display = "An attempt was made to update an unknown entity: {}", _0)]
|
||||||
UnknownEntity(EntityId),
|
UnknownEntity(EntityId),
|
||||||
#[error(display = "No sendprop definition found for property")]
|
#[error(display = "No sendprop definition found for property")]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue