mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-03 18:24:05 +02:00
rename pvs
This commit is contained in:
parent
5adcdd046b
commit
2617d8a611
3 changed files with 33 additions and 33 deletions
|
|
@ -56,11 +56,11 @@ impl PartialEq<u32> for EntityId {
|
||||||
)]
|
)]
|
||||||
#[discriminant_bits = 2]
|
#[discriminant_bits = 2]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum PVS {
|
pub enum UpdateType {
|
||||||
Preserve = 0,
|
Preserve = 0b00,
|
||||||
Leave = 1,
|
Leave = 0b01,
|
||||||
Enter = 2,
|
Enter = 0b10,
|
||||||
Delete = 3,
|
Delete = 0b11,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||||
|
|
@ -71,7 +71,7 @@ pub struct PacketEntity {
|
||||||
pub baseline_props: Vec<SendProp>,
|
pub baseline_props: Vec<SendProp>,
|
||||||
pub props: Vec<SendProp>,
|
pub props: Vec<SendProp>,
|
||||||
pub in_pvs: bool,
|
pub in_pvs: bool,
|
||||||
pub pvs: PVS,
|
pub update_type: UpdateType,
|
||||||
pub serial_number: u32,
|
pub serial_number: u32,
|
||||||
pub delay: Option<f32>,
|
pub delay: Option<f32>,
|
||||||
}
|
}
|
||||||
|
|
@ -207,7 +207,7 @@ fn get_send_table(state: &ParserState, class: ClassId) -> Result<&SendTable> {
|
||||||
fn get_entity_for_update(
|
fn get_entity_for_update(
|
||||||
state: &ParserState,
|
state: &ParserState,
|
||||||
entity_index: EntityId,
|
entity_index: EntityId,
|
||||||
pvs: PVS,
|
pvs: UpdateType,
|
||||||
) -> Result<PacketEntity> {
|
) -> Result<PacketEntity> {
|
||||||
let class_id = *state
|
let class_id = *state
|
||||||
.entity_classes
|
.entity_classes
|
||||||
|
|
@ -220,7 +220,7 @@ fn get_entity_for_update(
|
||||||
baseline_props: vec![],
|
baseline_props: vec![],
|
||||||
props: Vec::with_capacity(8),
|
props: Vec::with_capacity(8),
|
||||||
in_pvs: false,
|
in_pvs: false,
|
||||||
pvs,
|
update_type: pvs,
|
||||||
serial_number: 0,
|
serial_number: 0,
|
||||||
delay: None,
|
delay: None,
|
||||||
})
|
})
|
||||||
|
|
@ -247,23 +247,23 @@ impl Parse<'_> for PacketEntitiesMessage {
|
||||||
last_index = last_index.saturating_add(diff as i32).saturating_add(1);
|
last_index = last_index.saturating_add(diff as i32).saturating_add(1);
|
||||||
let entity_index = EntityId::from(last_index as u32);
|
let entity_index = EntityId::from(last_index as u32);
|
||||||
|
|
||||||
let pvs = data.read()?;
|
let update_type = data.read()?;
|
||||||
if pvs == PVS::Enter {
|
if update_type == UpdateType::Enter {
|
||||||
let mut entity =
|
let mut entity =
|
||||||
Self::read_enter(&mut data, entity_index, state, base_line as usize)?;
|
Self::read_enter(&mut data, entity_index, state, base_line as usize)?;
|
||||||
let send_table = get_send_table(state, entity.server_class)?;
|
let send_table = get_send_table(state, entity.server_class)?;
|
||||||
Self::read_update(&mut data, send_table, &mut entity.props)?;
|
Self::read_update(&mut data, send_table, &mut entity.props)?;
|
||||||
|
|
||||||
entities.push(entity);
|
entities.push(entity);
|
||||||
} else if pvs == PVS::Preserve {
|
} else if update_type == UpdateType::Preserve {
|
||||||
let mut entity = get_entity_for_update(state, entity_index, pvs)?;
|
let mut entity = get_entity_for_update(state, entity_index, update_type)?;
|
||||||
let send_table = get_send_table(state, entity.server_class)?;
|
let send_table = get_send_table(state, entity.server_class)?;
|
||||||
|
|
||||||
Self::read_update(&mut data, send_table, &mut entity.props)?;
|
Self::read_update(&mut data, send_table, &mut entity.props)?;
|
||||||
|
|
||||||
entities.push(entity);
|
entities.push(entity);
|
||||||
} else if state.entity_classes.contains_key(&entity_index) {
|
} else if state.entity_classes.contains_key(&entity_index) {
|
||||||
let entity = get_entity_for_update(state, entity_index, pvs)?;
|
let entity = get_entity_for_update(state, entity_index, update_type)?;
|
||||||
entities.push(entity);
|
entities.push(entity);
|
||||||
} else {
|
} else {
|
||||||
entities.push(PacketEntity {
|
entities.push(PacketEntity {
|
||||||
|
|
@ -272,7 +272,7 @@ impl Parse<'_> for PacketEntitiesMessage {
|
||||||
baseline_props: vec![],
|
baseline_props: vec![],
|
||||||
props: vec![],
|
props: vec![],
|
||||||
in_pvs: false,
|
in_pvs: false,
|
||||||
pvs,
|
update_type,
|
||||||
serial_number: 0,
|
serial_number: 0,
|
||||||
delay: None,
|
delay: None,
|
||||||
});
|
});
|
||||||
|
|
@ -318,15 +318,15 @@ impl Encode for PacketEntitiesMessage {
|
||||||
write_bit_var(diff as u32, stream)?;
|
write_bit_var(diff as u32, stream)?;
|
||||||
last_index = entity.entity_index.0 as i32;
|
last_index = entity.entity_index.0 as i32;
|
||||||
|
|
||||||
entity.pvs.write(stream)?;
|
entity.update_type.write(stream)?;
|
||||||
|
|
||||||
let send_table = get_send_table(state, entity.server_class)?;
|
let send_table = get_send_table(state, entity.server_class)?;
|
||||||
match entity.pvs {
|
match entity.update_type {
|
||||||
PVS::Enter => {
|
UpdateType::Enter => {
|
||||||
Self::write_enter(entity, stream, state)?;
|
Self::write_enter(entity, stream, state)?;
|
||||||
Self::write_update(&entity.props, stream, send_table)?;
|
Self::write_update(&entity.props, stream, send_table)?;
|
||||||
}
|
}
|
||||||
PVS::Preserve => {
|
UpdateType::Preserve => {
|
||||||
Self::write_update(&entity.props, stream, send_table)?;
|
Self::write_update(&entity.props, stream, send_table)?;
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
@ -373,7 +373,7 @@ impl PacketEntitiesMessage {
|
||||||
baseline_props,
|
baseline_props,
|
||||||
props: vec![],
|
props: vec![],
|
||||||
in_pvs: true,
|
in_pvs: true,
|
||||||
pvs: PVS::Enter,
|
update_type: UpdateType::Enter,
|
||||||
serial_number: serial,
|
serial_number: serial,
|
||||||
delay: None,
|
delay: None,
|
||||||
})
|
})
|
||||||
|
|
@ -543,7 +543,7 @@ fn test_packet_entitier_message_roundtrip() {
|
||||||
baseline_props: vec![],
|
baseline_props: vec![],
|
||||||
props: vec![],
|
props: vec![],
|
||||||
in_pvs: true,
|
in_pvs: true,
|
||||||
pvs: PVS::Enter,
|
update_type: UpdateType::Enter,
|
||||||
serial_number: 0,
|
serial_number: 0,
|
||||||
delay: None,
|
delay: None,
|
||||||
}],
|
}],
|
||||||
|
|
@ -564,7 +564,7 @@ fn test_packet_entitier_message_roundtrip() {
|
||||||
baseline_props: vec![],
|
baseline_props: vec![],
|
||||||
props: vec![],
|
props: vec![],
|
||||||
in_pvs: true,
|
in_pvs: true,
|
||||||
pvs: PVS::Enter,
|
update_type: UpdateType::Enter,
|
||||||
serial_number: 0,
|
serial_number: 0,
|
||||||
delay: None,
|
delay: None,
|
||||||
},
|
},
|
||||||
|
|
@ -585,7 +585,7 @@ fn test_packet_entitier_message_roundtrip() {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
in_pvs: false,
|
in_pvs: false,
|
||||||
pvs: PVS::Preserve,
|
update_type: UpdateType::Preserve,
|
||||||
serial_number: 0,
|
serial_number: 0,
|
||||||
delay: None,
|
delay: None,
|
||||||
},
|
},
|
||||||
|
|
@ -606,7 +606,7 @@ fn test_packet_entitier_message_roundtrip() {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
in_pvs: true,
|
in_pvs: true,
|
||||||
pvs: PVS::Enter,
|
update_type: UpdateType::Enter,
|
||||||
serial_number: 0,
|
serial_number: 0,
|
||||||
delay: None,
|
delay: None,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::demo::gamevent::GameEventDefinition;
|
use crate::demo::gamevent::GameEventDefinition;
|
||||||
|
|
||||||
use crate::demo::message::packetentities::{EntityId, PacketEntitiesMessage, PVS};
|
use crate::demo::message::packetentities::{EntityId, PacketEntitiesMessage, UpdateType};
|
||||||
use crate::demo::message::stringtable::StringTableMeta;
|
use crate::demo::message::stringtable::StringTableMeta;
|
||||||
use crate::demo::message::{Message, MessageType};
|
use crate::demo::message::{Message, MessageType};
|
||||||
use crate::demo::packet::datatable::{
|
use crate::demo::packet::datatable::{
|
||||||
|
|
@ -203,7 +203,7 @@ impl<'a> ParserState {
|
||||||
}
|
}
|
||||||
|
|
||||||
for entity in ent_message.entities.iter() {
|
for entity in ent_message.entities.iter() {
|
||||||
if entity.pvs == PVS::Delete {
|
if entity.update_type == UpdateType::Delete {
|
||||||
self.entity_classes.remove(&entity.entity_index);
|
self.entity_classes.remove(&entity.entity_index);
|
||||||
self.instance_baselines[0].remove(&entity.entity_index);
|
self.instance_baselines[0].remove(&entity.entity_index);
|
||||||
self.instance_baselines[1].remove(&entity.entity_index);
|
self.instance_baselines[1].remove(&entity.entity_index);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use test_case::test_case;
|
||||||
use fnv::FnvHashMap;
|
use fnv::FnvHashMap;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::io::{BufRead, BufReader};
|
use std::io::{BufRead, BufReader};
|
||||||
use tf_demo_parser::demo::message::packetentities::{EntityId, PacketEntity, PVS};
|
use tf_demo_parser::demo::message::packetentities::{EntityId, PacketEntity, UpdateType};
|
||||||
use tf_demo_parser::demo::message::Message;
|
use tf_demo_parser::demo::message::Message;
|
||||||
use tf_demo_parser::demo::packet::datatable::{
|
use tf_demo_parser::demo::packet::datatable::{
|
||||||
ParseSendTable, SendTableName, ServerClass, ServerClassName,
|
ParseSendTable, SendTableName, ServerClass, ServerClassName,
|
||||||
|
|
@ -25,13 +25,13 @@ pub enum PVSCompat {
|
||||||
Delete = 6,
|
Delete = 6,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<PVS> for PVSCompat {
|
impl From<UpdateType> for PVSCompat {
|
||||||
fn from(pvs: PVS) -> Self {
|
fn from(pvs: UpdateType) -> Self {
|
||||||
match pvs {
|
match pvs {
|
||||||
PVS::Preserve => PVSCompat::Preserve,
|
UpdateType::Preserve => PVSCompat::Preserve,
|
||||||
PVS::Leave => PVSCompat::Leave,
|
UpdateType::Leave => PVSCompat::Leave,
|
||||||
PVS::Enter => PVSCompat::Enter,
|
UpdateType::Enter => PVSCompat::Enter,
|
||||||
PVS::Delete => PVSCompat::Delete,
|
UpdateType::Delete => PVSCompat::Delete,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -57,7 +57,7 @@ impl EntityDump {
|
||||||
tick,
|
tick,
|
||||||
server_class: classes[usize::from(entity.server_class)].name.clone(),
|
server_class: classes[usize::from(entity.server_class)].name.clone(),
|
||||||
id: entity.entity_index,
|
id: entity.entity_index,
|
||||||
pvs: entity.pvs.into(),
|
pvs: entity.update_type.into(),
|
||||||
props: entity
|
props: entity
|
||||||
.into_props()
|
.into_props()
|
||||||
.map(|prop| {
|
.map(|prop| {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue