mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-03 18:24:05 +02:00
only handle entities when the analyser needs them
This commit is contained in:
parent
a7702856d0
commit
b0e295c4a3
1 changed files with 8 additions and 2 deletions
|
|
@ -32,6 +32,7 @@ pub struct ParserState {
|
|||
pub instance_baselines: [HashMap<EntityId, Vec<SendProp>>; 2],
|
||||
pub demo_meta: DemoMeta,
|
||||
analyser_handles: fn(message_type: MessageType) -> bool,
|
||||
handle_entities: bool,
|
||||
}
|
||||
|
||||
pub struct StaticBaseline {
|
||||
|
|
@ -62,6 +63,7 @@ impl ParserState {
|
|||
instance_baselines: [HashMap::new(), HashMap::new()],
|
||||
demo_meta: DemoMeta::default(),
|
||||
analyser_handles,
|
||||
handle_entities: analyser_handles(MessageType::PacketEntities),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -99,9 +101,13 @@ impl ParserState {
|
|||
}
|
||||
|
||||
pub fn should_parse_message(&self, message_type: MessageType) -> bool {
|
||||
if message_type == MessageType::PacketEntities {
|
||||
(self.analyser_handles)(message_type)
|
||||
} else {
|
||||
Self::does_handle(message_type) || (self.analyser_handles)(message_type)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MessageHandler for ParserState {
|
||||
type Output = Self;
|
||||
|
|
@ -111,7 +117,7 @@ impl MessageHandler for ParserState {
|
|||
MessageType::ServerInfo
|
||||
| MessageType::GameEventList
|
||||
| MessageType::CreateStringTable
|
||||
| MessageType::PacketEntities // TODO entity tracking is only needed when the analyser uses entities
|
||||
| MessageType::PacketEntities
|
||||
| MessageType::UpdateStringTable => true,
|
||||
_ => false,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue