mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-03 10:14:06 +02:00
more tracing
This commit is contained in:
parent
67d08f06da
commit
614dbb2f47
2 changed files with 21 additions and 4 deletions
|
|
@ -12,6 +12,8 @@ use std::cmp::{min, Ordering};
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::num::NonZeroU32;
|
use std::num::NonZeroU32;
|
||||||
|
#[cfg(feature = "trace")]
|
||||||
|
use tracing::trace;
|
||||||
|
|
||||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||||
#[derive(
|
#[derive(
|
||||||
|
|
@ -340,10 +342,10 @@ impl Encode for PacketEntitiesMessage {
|
||||||
match entity.update_type {
|
match entity.update_type {
|
||||||
UpdateType::Enter => {
|
UpdateType::Enter => {
|
||||||
Self::write_enter(entity, stream, state)?;
|
Self::write_enter(entity, stream, state)?;
|
||||||
Self::write_update(&entity.props, stream, send_table)?;
|
Self::write_update(&entity.props, stream, send_table, entity.entity_index)?;
|
||||||
}
|
}
|
||||||
UpdateType::Preserve => {
|
UpdateType::Preserve => {
|
||||||
Self::write_update(&entity.props, stream, send_table)?;
|
Self::write_update(&entity.props, stream, send_table, entity.entity_index)?;
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
@ -417,10 +419,15 @@ impl PacketEntitiesMessage {
|
||||||
stream: &mut Stream,
|
stream: &mut Stream,
|
||||||
send_table: &SendTable,
|
send_table: &SendTable,
|
||||||
props: &mut Vec<SendProp>,
|
props: &mut Vec<SendProp>,
|
||||||
_entity_index: EntityId,
|
entity_index: EntityId,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let mut index: i32 = -1;
|
let mut index: i32 = -1;
|
||||||
|
|
||||||
|
#[cfg(feature = "trace")]
|
||||||
|
trace!(entity_index = display(entity_index), "reading update");
|
||||||
|
#[cfg(not(feature = "trace"))]
|
||||||
|
let _ = entity_index;
|
||||||
|
|
||||||
while stream.read()? {
|
while stream.read()? {
|
||||||
let diff: u32 = read_bit_var(stream)?;
|
let diff: u32 = read_bit_var(stream)?;
|
||||||
index = index.saturating_add(diff as i32).saturating_add(1);
|
index = index.saturating_add(diff as i32).saturating_add(1);
|
||||||
|
|
@ -428,6 +435,15 @@ impl PacketEntitiesMessage {
|
||||||
match send_table.flattened_props.get(index as usize) {
|
match send_table.flattened_props.get(index as usize) {
|
||||||
Some(definition) => {
|
Some(definition) => {
|
||||||
let value = SendPropValue::parse(stream, &definition.parse_definition)?;
|
let value = SendPropValue::parse(stream, &definition.parse_definition)?;
|
||||||
|
|
||||||
|
#[cfg(feature = "trace")]
|
||||||
|
trace!(
|
||||||
|
entity_index = display(entity_index),
|
||||||
|
index = display(index),
|
||||||
|
value = debug(&value),
|
||||||
|
definition = display(definition.identifier),
|
||||||
|
"reading prop"
|
||||||
|
);
|
||||||
props.push(SendProp {
|
props.push(SendProp {
|
||||||
index: index as u32,
|
index: index as u32,
|
||||||
identifier: definition.identifier,
|
identifier: definition.identifier,
|
||||||
|
|
@ -451,6 +467,7 @@ impl PacketEntitiesMessage {
|
||||||
props: Props,
|
props: Props,
|
||||||
stream: &mut BitWriteStream<LittleEndian>,
|
stream: &mut BitWriteStream<LittleEndian>,
|
||||||
send_table: &SendTable,
|
send_table: &SendTable,
|
||||||
|
_entity_index: EntityId,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let mut last_index: i32 = -1;
|
let mut last_index: i32 = -1;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ impl Encode for TempEntitiesMessage {
|
||||||
.send_tables
|
.send_tables
|
||||||
.get(usize::from(event.class_id))
|
.get(usize::from(event.class_id))
|
||||||
.ok_or(ParseError::UnknownServerClass(event.class_id))?;
|
.ok_or(ParseError::UnknownServerClass(event.class_id))?;
|
||||||
PacketEntitiesMessage::write_update(&event.props, stream, send_table)?;
|
PacketEntitiesMessage::write_update(&event.props, stream, send_table, 0u32.into())?;
|
||||||
}
|
}
|
||||||
let end = stream.bit_len();
|
let end = stream.bit_len();
|
||||||
Ok(encode_var_int_fixed((end - start) as u32))
|
Ok(encode_var_int_fixed((end - start) as u32))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue