def reconstitute(full_packets, class_bits, recv_tables, string_tables): w = e_w.construct(recv_tables) st = string_tables st_mn = st['ModifierNames'] st_am = st['ActiveModifiers'] m = e_m.construct(st_mn, baseline=st_am) for _, fp in full_packets: for table in fp.string_table.tables: assert not table.items_clientside entries = [(_i, e.str, e.data) for _i, e in enumerate(table.items)] st[table.table_name].update_all(entries) if table.table_name == 'ActiveModifiers': m.reset() [m.note(e) for e in entries] if full_packets: _, fp = full_packets[-1] packet = ie_packet.construct(p_io.construct(fp.packet.data)) _, pe = packet.svc_packet_entities ct = pe.updated_entries bs = b_io.construct(pe.entity_data) unpacker = u_ent.construct(bs, -1, ct, False, class_bits, w) for index, mode, (cls, serial, diff) in unpacker: data = st['instancebaseline'].get(cls)[1] bs = b_io.construct(data) unpacker = u_ent.construct(bs, -1, 1, False, class_bits, w) state = unpacker.unpack_baseline(recv_tables[cls]) state.update(diff) w.create(cls, index, serial, state, dict(diff)) return w, m, st
def _parse_all_csvc_create_string_tables(pbmsgs): string_tables = c.OrderedDict() for pbmsg in pbmsgs: ne = pbmsg.num_entries eb = int(math.ceil(math.log(pbmsg.max_entries, 2))) sf = pbmsg.user_data_fixed_size sb = pbmsg.user_data_size_bits bs = b_io.construct(pbmsg.string_data) entries = list(u_st.construct(bs, ne, eb, sf, sb)) name = pbmsg.name string_tables[name] = stab.construct(name, eb, sf, sb, entries) return string_tables
def advance(self, tick, pbmsg): self.tick = tick packet = ie_packet.construct(p_io.construct(pbmsg.data)) am_entries = [] for _, _pbmsg in packet.all_svc_update_string_table: key = self.string_tables.keys()[_pbmsg.table_id] _st = self.string_tables[key] bs = b_io.construct(_pbmsg.string_data) ne = _pbmsg.num_changed_entries eb, sf, sb = _st.entry_bits, _st.size_fixed, _st.size_bits entries = u_st.construct(bs, ne, eb, sf, sb) if key == 'ActiveModifiers': am_entries = list(entries) else: [_st.update(e) for e in entries] um = packet.find_all(pb_n.svc_UserMessage) self.user_messages = [e_um.parse(p_io.parse(p.kind, m)) for p, m in um] ge = packet.find_all(pb_n.svc_GameEvent) gel = self.prologue.game_event_list self.game_events = [ e_ge.parse(p_io.parse(p.kind, m), gel) for p, m in ge ] p, m = packet.find(pb_n.svc_PacketEntities) pe = p_io.parse(p.kind, m) ct = pe.updated_entries bs = b_io.construct(pe.entity_data) class_bits = self.prologue.class_bits recv_tables = self.prologue.recv_tables unpacker = u_ent.construct(bs, -1, ct, False, class_bits, self.world) for index, mode, context in unpacker: if mode & u_ent.PVS.Entering: cls, serial, diff = context data = self.string_tables['instancebaseline'].get(cls)[1] bs = b_io.construct(data) unpacker = u_ent.construct(bs, -1, 1, False, class_bits, self.world) state = unpacker.unpack_baseline( self.prologue.recv_tables[cls]) state.update(diff) self.world.create(cls, index, serial, state, dict(diff)) elif mode & u_ent.PVS.Deleting: self.world.delete(index) elif mode ^ u_ent.PVS.Leaving: state = dict(context) if self.sparse else dict( self.world.find_index(index), **context) diff = state if self.sparse else dict(context) self.world.update(index, state, diff) [self.modifiers.note(e) for e in am_entries] self.modifiers.limit(self.world) _, gamerules = self.world.find_by_dt('DT_DOTAGamerulesProxy') game_time_key = ('DT_DOTAGamerulesProxy', 'DT_DOTAGamerules.m_fGameTime') self.modifiers.expire(gamerules[game_time_key])
def advance(self, tick, pbmsg): self.tick = tick packet = ie_packet.construct(p_io.construct(pbmsg.data)) am_entries = [] for _, _pbmsg in packet.all_svc_update_string_table: key = self.string_tables.keys()[_pbmsg.table_id] _st = self.string_tables[key] bs = b_io.construct(_pbmsg.string_data) ne = _pbmsg.num_changed_entries eb, sf, sb = _st.entry_bits, _st.size_fixed, _st.size_bits entries = u_st.construct(bs, ne, eb, sf, sb) if key == 'ActiveModifiers': am_entries = list(entries) else: [_st.update(e) for e in entries] um = packet.find_all(pb_n.svc_UserMessage) self.user_messages = [e_um.parse(p_io.parse(p.kind, m)) for p, m in um] ge = packet.find_all(pb_n.svc_GameEvent) gel = self.prologue.game_event_list self.game_events = [e_ge.parse(p_io.parse(p.kind, m), gel) for p, m in ge] p, m = packet.find(pb_n.svc_PacketEntities) pe = p_io.parse(p.kind, m) ct = pe.updated_entries bs = b_io.construct(pe.entity_data) class_bits = self.prologue.class_bits recv_tables = self.prologue.recv_tables unpacker = u_ent.construct(bs, -1, ct, False, class_bits, self.world) for index, mode, context in unpacker: if mode & u_ent.PVS.Entering: cls, serial, diff = context data = self.string_tables['instancebaseline'].get(cls)[1] bs = b_io.construct(data) unpacker = u_ent.construct(bs, -1, 1, False, class_bits, self.world) state = unpacker.unpack_baseline(self.prologue.recv_tables[cls]) state.update(diff) self.world.create(cls, index, serial, state, dict(diff)) elif mode & u_ent.PVS.Deleting: self.world.delete(index) elif mode ^ u_ent.PVS.Leaving: state = dict(context) if self.sparse else dict(self.world.find_index(index), **context) diff = state if self.sparse else dict(context) self.world.update(index, state, diff) [self.modifiers.note(e) for e in am_entries] self.modifiers.limit(self.world) _, gamerules = self.world.find_by_dt('DT_DOTAGamerulesProxy') game_time_key = ('DT_DOTAGamerulesProxy', 'DT_DOTAGamerules.m_fGameTime') self.modifiers.expire(gamerules[game_time_key])