1
0
Fork 0
mirror of https://codeberg.org/demostf/parser.git synced 2026-06-04 02:24:12 +02:00

medigun type, spy class data

This commit is contained in:
Robin Appelman 2025-06-28 18:26:29 +02:00
commit 15046e8744
11 changed files with 1093 additions and 54 deletions

View file

@ -82,7 +82,7 @@ impl PartialOrd<u32> for EntityId {
#[discriminant_bits = 2]
#[repr(u8)]
pub enum UpdateType {
Preserve = 0b00,
Delta = 0b00,
Leave = 0b01,
Enter = 0b10,
Delete = 0b11,
@ -177,6 +177,17 @@ impl PacketEntity {
.find(|prop| prop.identifier == *index)
}
pub fn get_own_prop_value_by_identifier<T: for<'a> TryFrom<&'a SendPropValue>>(
&self,
index: SendPropIdentifier,
) -> Option<T> {
self.props
.iter()
.find(|prop| prop.identifier == index)
.map(|prop| &prop.value)
.and_then(|value| value.try_into().ok())
}
pub fn apply_update(&mut self, props: &[SendProp]) {
for prop in props {
match self.mut_prop_by_identifier(&prop.identifier) {
@ -370,7 +381,7 @@ impl Parse<'_> for PacketEntitiesMessage {
Self::read_update(&mut data, send_table, &mut entity.props, entity_index)?;
entities.push(entity);
} else if update_type == UpdateType::Preserve {
} else if update_type == UpdateType::Delta {
let mut entity = get_entity_for_update(state, entity_index, update_type, delta)?;
let send_table = get_send_table(state, entity.server_class)?;
@ -445,7 +456,7 @@ impl Encode for PacketEntitiesMessage {
Self::write_enter(entity, stream, state)?;
Self::write_update(&entity.props, stream, send_table, entity.entity_index)?;
}
UpdateType::Preserve => {
UpdateType::Delta => {
Self::write_update(&entity.props, stream, send_table, entity.entity_index)?;
}
_ => {}
@ -717,7 +728,7 @@ fn test_packet_entitier_message_roundtrip() {
},
],
in_pvs: true,
update_type: UpdateType::Preserve,
update_type: UpdateType::Delta,
serial_number: 0,
delay: None,
delta: None,