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

use more nullhasher

This commit is contained in:
Robin Appelman 2019-08-29 16:57:38 +02:00
commit 089f615a47
2 changed files with 15 additions and 7 deletions

View file

@ -23,14 +23,14 @@ pub struct DemoMeta {
} }
pub struct ParserState { pub struct ParserState {
pub static_baselines: HashMap<ClassId, StaticBaseline>, pub static_baselines: HashMap<ClassId, StaticBaseline, NullHasherBuilder>,
pub parsed_static_baselines: RefCell<HashMap<ClassId, Vec<SendProp>>>, pub parsed_static_baselines: RefCell<HashMap<ClassId, Vec<SendProp>, NullHasherBuilder>>,
pub event_definitions: Vec<GameEventDefinition>, pub event_definitions: Vec<GameEventDefinition>,
pub string_tables: Vec<StringTableMeta>, pub string_tables: Vec<StringTableMeta>,
pub entity_classes: HashMap<EntityId, ClassId, NullHasherBuilder>, pub entity_classes: HashMap<EntityId, ClassId, NullHasherBuilder>,
pub send_tables: Vec<SendTable>, // indexed by ClassId pub send_tables: Vec<SendTable>, // indexed by ClassId
pub server_classes: Vec<ServerClass>, pub server_classes: Vec<ServerClass>,
pub instance_baselines: [HashMap<EntityId, Vec<SendProp>>; 2], pub instance_baselines: [HashMap<EntityId, Vec<SendProp>, NullHasherBuilder>; 2],
pub demo_meta: DemoMeta, pub demo_meta: DemoMeta,
analyser_handles: fn(message_type: MessageType) -> bool, analyser_handles: fn(message_type: MessageType) -> bool,
handle_entities: bool, handle_entities: bool,
@ -54,14 +54,17 @@ impl StaticBaseline {
impl ParserState { impl ParserState {
pub fn new(analyser_handles: fn(message_type: MessageType) -> bool) -> Self { pub fn new(analyser_handles: fn(message_type: MessageType) -> bool) -> Self {
ParserState { ParserState {
static_baselines: HashMap::new(), static_baselines: HashMap::with_hasher(NullHasherBuilder),
parsed_static_baselines: RefCell::new(HashMap::new()), parsed_static_baselines: RefCell::new(HashMap::with_hasher(NullHasherBuilder)),
event_definitions: Vec::new(), event_definitions: Vec::new(),
string_tables: Vec::new(), string_tables: Vec::new(),
entity_classes: HashMap::with_hasher(NullHasherBuilder), entity_classes: HashMap::with_hasher(NullHasherBuilder),
send_tables: Vec::new(), send_tables: Vec::new(),
server_classes: Vec::new(), server_classes: Vec::new(),
instance_baselines: [HashMap::new(), HashMap::new()], instance_baselines: [
HashMap::with_hasher(NullHasherBuilder),
HashMap::with_hasher(NullHasherBuilder),
],
demo_meta: DemoMeta::default(), demo_meta: DemoMeta::default(),
analyser_handles, analyser_handles,
handle_entities: analyser_handles(MessageType::PacketEntities), handle_entities: analyser_handles(MessageType::PacketEntities),

View file

@ -15,7 +15,12 @@ impl Hasher for NullHasher {
#[inline] #[inline]
fn write(&mut self, _msg: &[u8]) { fn write(&mut self, _msg: &[u8]) {
panic!("can only hash u64 as u32"); panic!("can only hash u64,u32,u16");
}
#[inline]
fn write_u16(&mut self, data: u16) {
self.data = data as u64
} }
#[inline] #[inline]