mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-03 10:14:06 +02:00
method for getting prop index
This commit is contained in:
parent
f83be2375c
commit
dee3609b8a
1 changed files with 12 additions and 1 deletions
|
|
@ -35,7 +35,8 @@ pub struct ParserState {
|
|||
pub event_definitions: Vec<GameEventDefinition>,
|
||||
pub string_tables: Vec<StringTableMeta>,
|
||||
pub entity_classes: HashMap<EntityId, ClassId, NullHasherBuilder>,
|
||||
pub send_tables: Vec<SendTable>, // indexed by ClassId
|
||||
// indexed by ClassId
|
||||
pub send_tables: Vec<SendTable>,
|
||||
pub server_classes: Vec<ServerClass>,
|
||||
pub instance_baselines: [Baseline; 2],
|
||||
pub demo_meta: DemoMeta,
|
||||
|
|
@ -276,6 +277,16 @@ impl<'a> ParserState {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn index_for_prop(&self, class: ClassId, prop: SendPropIdentifier) -> Option<u32> {
|
||||
let send_table = self.send_tables.get(usize::from(class))?;
|
||||
send_table
|
||||
.flattened_props
|
||||
.iter()
|
||||
.enumerate()
|
||||
.find(|(_i, def)| def.identifier == prop)
|
||||
.map(|(index, _)| index as u32)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue