mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-03 18:24:05 +02:00
dont use wrong class baseline?
This commit is contained in:
parent
a9a527fb5c
commit
079881ea6e
2 changed files with 22 additions and 8 deletions
|
|
@ -249,8 +249,13 @@ impl Parse<'_> for PacketEntitiesMessage {
|
|||
|
||||
let update_type = data.read()?;
|
||||
if update_type == UpdateType::Enter {
|
||||
let mut entity =
|
||||
Self::read_enter(&mut data, entity_index, state, base_line as usize)?;
|
||||
let mut entity = Self::read_enter(
|
||||
&mut data,
|
||||
entity_index,
|
||||
state,
|
||||
base_line as usize,
|
||||
delta.is_some(),
|
||||
)?;
|
||||
let send_table = get_send_table(state, entity.server_class)?;
|
||||
Self::read_update(&mut data, send_table, &mut entity.props)?;
|
||||
|
||||
|
|
@ -354,6 +359,7 @@ impl PacketEntitiesMessage {
|
|||
entity_index: EntityId,
|
||||
state: &ParserState,
|
||||
baseline_index: usize,
|
||||
is_delta: bool,
|
||||
) -> Result<PacketEntity> {
|
||||
let bits = log_base2(state.server_classes.len()) + 1;
|
||||
let class_index: ClassId = stream.read_sized::<u16>(bits as usize)?.into();
|
||||
|
|
@ -364,8 +370,13 @@ impl PacketEntitiesMessage {
|
|||
.get(usize::from(class_index))
|
||||
.ok_or(ParseError::UnknownServerClass(class_index))?;
|
||||
|
||||
let baseline_props =
|
||||
state.get_baseline(baseline_index, entity_index, class_index, send_table)?;
|
||||
let baseline_props = state.get_baseline(
|
||||
baseline_index,
|
||||
entity_index,
|
||||
class_index,
|
||||
send_table,
|
||||
is_delta,
|
||||
)?;
|
||||
|
||||
Ok(PacketEntity {
|
||||
server_class: class_index,
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ pub struct ParserState {
|
|||
pub entity_classes: HashMap<EntityId, ClassId, NullHasherBuilder>,
|
||||
pub send_tables: Vec<SendTable>, // indexed by ClassId
|
||||
pub server_classes: Vec<ServerClass>,
|
||||
pub instance_baselines: [HashMap<EntityId, Vec<SendProp>, NullHasherBuilder>; 2],
|
||||
pub instance_baselines: [HashMap<EntityId, (Vec<SendProp>, ClassId), NullHasherBuilder>; 2],
|
||||
pub demo_meta: DemoMeta,
|
||||
analyser_handles: fn(message_type: MessageType) -> bool,
|
||||
handle_entities: bool,
|
||||
|
|
@ -109,10 +109,13 @@ impl<'a> ParserState {
|
|||
entity_index: EntityId,
|
||||
class_id: ClassId,
|
||||
send_table: &SendTable,
|
||||
is_delta: bool,
|
||||
) -> Result<Vec<SendProp>> {
|
||||
match self.instance_baselines[baseline_index].get(&entity_index) {
|
||||
Some(baseline) => Ok(baseline.clone()),
|
||||
None => match self.static_baselines.get(&class_id) {
|
||||
Some((baseline, baseline_class)) if baseline_class == &class_id && is_delta => {
|
||||
Ok(baseline.clone())
|
||||
}
|
||||
_ => match self.static_baselines.get(&class_id) {
|
||||
Some(_static_baseline) => self.get_static_baseline(class_id, send_table),
|
||||
None => Ok(Vec::with_capacity(8)),
|
||||
},
|
||||
|
|
@ -219,7 +222,7 @@ impl<'a> ParserState {
|
|||
|
||||
for entity in ent_message.entities {
|
||||
self.instance_baselines[new_index]
|
||||
.insert(entity.entity_index, entity.props);
|
||||
.insert(entity.entity_index, (entity.props, entity.server_class));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue