1
0
Fork 0
mirror of https://codeberg.org/demostf/parser.git synced 2026-06-03 10:14:06 +02:00

compare definitions by index

This commit is contained in:
Robin Appelman 2019-08-29 16:32:15 +02:00
commit 06d53573d4
2 changed files with 5 additions and 4 deletions

View file

@ -69,7 +69,7 @@ impl PacketEntity {
fn get_prop_by_definition(&mut self, definition: &SendPropDefinition) -> Option<&mut SendProp> {
self.props
.iter_mut()
.find(|prop| prop.definition.as_ref().eq(definition))
.find(|prop| prop.definition.index == definition.index)
}
pub fn apply_update(&mut self, props: Vec<SendProp>) {

View file

@ -49,7 +49,7 @@ pub struct SendPropDefinition {
impl PartialEq for SendPropDefinition {
fn eq(&self, other: &Self) -> bool {
self.owner_table == other.owner_table && self.name == other.name
self.index == other.index
}
}
@ -529,11 +529,12 @@ impl From<Vec<SendPropValue>> for SendPropValue {
}
#[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq)]
pub struct SendPropDefinitionIndex(usize, usize);
pub struct SendPropDefinitionIndex(u32);
impl SendPropDefinitionIndex {
pub fn new(table: usize, prop: usize) -> Self {
SendPropDefinitionIndex(table, prop)
// there can be at most 1024 (10 bits) props per table
SendPropDefinitionIndex((table * 1024 + prop) as u32)
}
}