mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-03 18:24:05 +02:00
0.2.5
This commit is contained in:
parent
5547e31810
commit
3ab0a1b325
3 changed files with 9 additions and 5 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -634,7 +634,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tf-demo-parser"
|
||||
version = "0.2.4"
|
||||
version = "0.2.5"
|
||||
dependencies = [
|
||||
"better-panic",
|
||||
"bitbuffer",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "tf-demo-parser"
|
||||
description = "parser for tf2 demo files"
|
||||
version = "0.2.4"
|
||||
version = "0.2.5"
|
||||
authors = ["Robin Appelman <robin@icewind.nl>"]
|
||||
edition = "2018"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
|
|
|||
|
|
@ -69,13 +69,17 @@ impl fmt::Display for PacketEntity {
|
|||
}
|
||||
|
||||
impl PacketEntity {
|
||||
pub fn get_prop_by_identifier(&mut self, index: &SendPropIdentifier) -> Option<&mut SendProp> {
|
||||
pub fn mut_prop_by_identifier(&mut self, index: &SendPropIdentifier) -> Option<&mut SendProp> {
|
||||
self.props.iter_mut().find(|prop| prop.index == *index)
|
||||
}
|
||||
|
||||
pub fn get_prop_by_identifier(&self, index: &SendPropIdentifier) -> Option<&SendProp> {
|
||||
self.props.iter().find(|prop| prop.index == *index)
|
||||
}
|
||||
|
||||
pub fn apply_update(&mut self, props: Vec<SendProp>) {
|
||||
for prop in props {
|
||||
match self.get_prop_by_identifier(&prop.index) {
|
||||
match self.mut_prop_by_identifier(&prop.index) {
|
||||
Some(existing_prop) => existing_prop.value = prop.value,
|
||||
None => self.props.push(prop),
|
||||
}
|
||||
|
|
@ -84,7 +88,7 @@ impl PacketEntity {
|
|||
|
||||
pub fn get_prop_by_name(&self, table_name: &str, name: &str) -> Option<&SendProp> {
|
||||
let identifier = SendPropIdentifier::new(table_name, name);
|
||||
self.props.iter().find(|prop| prop.index == identifier)
|
||||
self.get_prop_by_identifier(&identifier)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue