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

save definition id in sendpropdefinition

This commit is contained in:
Robin Appelman 2019-08-29 12:45:39 +02:00
commit e1f1f6c201
2 changed files with 29 additions and 7 deletions

View file

@ -44,6 +44,7 @@ pub struct SendPropDefinition {
pub bit_count: Option<u32>,
pub element_count: Option<u16>,
pub array_property: Option<Box<SendPropDefinition>>,
pub index: SendPropDefinitionIndex,
}
impl PartialEq for SendPropDefinition {
@ -129,6 +130,7 @@ impl SendPropDefinition {
element_count: self.element_count,
array_property: Some(Box::new(array_property)),
owner_table: self.owner_table,
index: self.index,
}
}
@ -145,7 +147,11 @@ impl SendPropDefinition {
}
}
pub fn read(stream: &mut Stream, owner_table: SendTableName) -> ReadResult<Self> {
pub fn read(
stream: &mut Stream,
owner_table: SendTableName,
index: SendPropDefinitionIndex,
) -> ReadResult<Self> {
let prop_type = SendPropType::read(stream)?;
let name = stream.read_string(None)?.into();
let flags = SendPropFlags::read(stream)?;
@ -189,6 +195,7 @@ impl SendPropDefinition {
element_count,
array_property: None,
owner_table,
index,
})
}
@ -521,6 +528,15 @@ impl From<Vec<SendPropValue>> for SendPropValue {
}
}
#[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq)]
pub struct SendPropDefinitionIndex(usize, usize);
impl SendPropDefinitionIndex {
pub fn new(table: usize, prop: usize) -> Self {
SendPropDefinitionIndex(table, prop)
}
}
#[derive(Debug, Clone, Display)]
#[display("{definition.owner_table}::{definition.name} = {value}")]
pub struct SendProp {