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()?;
|
let update_type = data.read()?;
|
||||||
if update_type == UpdateType::Enter {
|
if update_type == UpdateType::Enter {
|
||||||
let mut entity =
|
let mut entity = Self::read_enter(
|
||||||
Self::read_enter(&mut data, entity_index, state, base_line as usize)?;
|
&mut data,
|
||||||
|
entity_index,
|
||||||
|
state,
|
||||||
|
base_line as usize,
|
||||||
|
delta.is_some(),
|
||||||
|
)?;
|
||||||
let send_table = get_send_table(state, entity.server_class)?;
|
let send_table = get_send_table(state, entity.server_class)?;
|
||||||
Self::read_update(&mut data, send_table, &mut entity.props)?;
|
Self::read_update(&mut data, send_table, &mut entity.props)?;
|
||||||
|
|
||||||
|
|
@ -354,6 +359,7 @@ impl PacketEntitiesMessage {
|
||||||
entity_index: EntityId,
|
entity_index: EntityId,
|
||||||
state: &ParserState,
|
state: &ParserState,
|
||||||
baseline_index: usize,
|
baseline_index: usize,
|
||||||
|
is_delta: bool,
|
||||||
) -> Result<PacketEntity> {
|
) -> Result<PacketEntity> {
|
||||||
let bits = log_base2(state.server_classes.len()) + 1;
|
let bits = log_base2(state.server_classes.len()) + 1;
|
||||||
let class_index: ClassId = stream.read_sized::<u16>(bits as usize)?.into();
|
let class_index: ClassId = stream.read_sized::<u16>(bits as usize)?.into();
|
||||||
|
|
@ -364,8 +370,13 @@ impl PacketEntitiesMessage {
|
||||||
.get(usize::from(class_index))
|
.get(usize::from(class_index))
|
||||||
.ok_or(ParseError::UnknownServerClass(class_index))?;
|
.ok_or(ParseError::UnknownServerClass(class_index))?;
|
||||||
|
|
||||||
let baseline_props =
|
let baseline_props = state.get_baseline(
|
||||||
state.get_baseline(baseline_index, entity_index, class_index, send_table)?;
|
baseline_index,
|
||||||
|
entity_index,
|
||||||
|
class_index,
|
||||||
|
send_table,
|
||||||
|
is_delta,
|
||||||
|
)?;
|
||||||
|
|
||||||
Ok(PacketEntity {
|
Ok(PacketEntity {
|
||||||
server_class: class_index,
|
server_class: class_index,
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ pub struct ParserState {
|
||||||
pub entity_classes: HashMap<EntityId, ClassId, NullHasherBuilder>,
|
pub entity_classes: HashMap<EntityId, ClassId, NullHasherBuilder>,
|
||||||
pub send_tables: Vec<SendTable>, // indexed by ClassId
|
pub send_tables: Vec<SendTable>, // indexed by ClassId
|
||||||
pub server_classes: Vec<ServerClass>,
|
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,
|
pub demo_meta: DemoMeta,
|
||||||
analyser_handles: fn(message_type: MessageType) -> bool,
|
analyser_handles: fn(message_type: MessageType) -> bool,
|
||||||
handle_entities: bool,
|
handle_entities: bool,
|
||||||
|
|
@ -109,10 +109,13 @@ impl<'a> ParserState {
|
||||||
entity_index: EntityId,
|
entity_index: EntityId,
|
||||||
class_id: ClassId,
|
class_id: ClassId,
|
||||||
send_table: &SendTable,
|
send_table: &SendTable,
|
||||||
|
is_delta: bool,
|
||||||
) -> Result<Vec<SendProp>> {
|
) -> Result<Vec<SendProp>> {
|
||||||
match self.instance_baselines[baseline_index].get(&entity_index) {
|
match self.instance_baselines[baseline_index].get(&entity_index) {
|
||||||
Some(baseline) => Ok(baseline.clone()),
|
Some((baseline, baseline_class)) if baseline_class == &class_id && is_delta => {
|
||||||
None => match self.static_baselines.get(&class_id) {
|
Ok(baseline.clone())
|
||||||
|
}
|
||||||
|
_ => match self.static_baselines.get(&class_id) {
|
||||||
Some(_static_baseline) => self.get_static_baseline(class_id, send_table),
|
Some(_static_baseline) => self.get_static_baseline(class_id, send_table),
|
||||||
None => Ok(Vec::with_capacity(8)),
|
None => Ok(Vec::with_capacity(8)),
|
||||||
},
|
},
|
||||||
|
|
@ -219,7 +222,7 @@ impl<'a> ParserState {
|
||||||
|
|
||||||
for entity in ent_message.entities {
|
for entity in ent_message.entities {
|
||||||
self.instance_baselines[new_index]
|
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