mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-03 18:24:05 +02:00
improved? baseline handling
This commit is contained in:
parent
079881ea6e
commit
c90a7a3371
2 changed files with 6 additions and 10 deletions
|
|
@ -87,19 +87,19 @@ impl fmt::Display for PacketEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PacketEntity {
|
impl PacketEntity {
|
||||||
pub fn mut_prop_by_identifier(&mut self, index: &SendPropIdentifier) -> Option<&mut SendProp> {
|
fn mut_prop_by_identifier(&mut self, index: &SendPropIdentifier) -> Option<&mut SendProp> {
|
||||||
self.props_mut().find(|prop| prop.identifier == *index)
|
self.props.iter_mut().find(|prop| prop.identifier == *index)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_prop_by_identifier(&self, index: &SendPropIdentifier) -> Option<&SendProp> {
|
pub fn get_prop_by_identifier(&self, index: &SendPropIdentifier) -> Option<&SendProp> {
|
||||||
self.props().find(|prop| prop.identifier == *index)
|
self.props().find(|prop| prop.identifier == *index)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apply_update(&mut self, props: Vec<SendProp>) {
|
pub fn apply_update(&mut self, props: &[SendProp]) {
|
||||||
for prop in props {
|
for prop in props {
|
||||||
match self.mut_prop_by_identifier(&prop.identifier) {
|
match self.mut_prop_by_identifier(&prop.identifier) {
|
||||||
Some(existing_prop) => existing_prop.value = prop.value,
|
Some(existing_prop) => existing_prop.value = prop.value.clone(),
|
||||||
None => self.props.push(prop),
|
None => self.props.push(prop.clone()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -113,10 +113,6 @@ impl PacketEntity {
|
||||||
self.baseline_props.iter().chain(self.props.iter())
|
self.baseline_props.iter().chain(self.props.iter())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn props_mut(&mut self) -> impl Iterator<Item = &mut SendProp> {
|
|
||||||
self.baseline_props.iter_mut().chain(self.props.iter_mut())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn into_props(self) -> impl Iterator<Item = SendProp> {
|
pub fn into_props(self) -> impl Iterator<Item = SendProp> {
|
||||||
self.baseline_props
|
self.baseline_props
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|
|
||||||
|
|
@ -218,7 +218,7 @@ impl<'a> ParserState {
|
||||||
if ent_message.updated_base_line {
|
if ent_message.updated_base_line {
|
||||||
let old_index = ent_message.base_line as usize;
|
let old_index = ent_message.base_line as usize;
|
||||||
let new_index = 1 - old_index;
|
let new_index = 1 - old_index;
|
||||||
self.instance_baselines.swap(0, 1);
|
self.instance_baselines[new_index] = self.instance_baselines[old_index].clone();
|
||||||
|
|
||||||
for entity in ent_message.entities {
|
for entity in ent_message.entities {
|
||||||
self.instance_baselines[new_index]
|
self.instance_baselines[new_index]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue