예제 #1
0
    def apply(self, peek):
        self.tick = peek.tick
        st, cb, rt = self.string_tables, self.class_bits, self.recv_tables
        st_ib = st['instancebaseline']

        packet = di.read(self.io, peek)
        p_io = io.BufferedReader(io.BytesIO(packet.data))
        index = pi.index(p_io)

        csvc_update_string_table_peeks = \
          index.find_all(pb_n.CSVCMsg_UpdateStringTable)
        all_csvc_update_string_table = \
          [pi.read(p_io, p) for p in csvc_update_string_table_peeks]

        for pbmsg in all_csvc_update_string_table:
            key = self.string_tables.keys()[pbmsg.table_id]
            _st = self.string_tables[key]

            bitstream = bs.construct(pbmsg.string_data)
            ne = pbmsg.num_changed_entries
            eb, sf, sb = _st.entry_bits, _st.size_fixed, _st.size_bits

            for entry in ust.unpack(bitstream, ne, eb, sf, sb):
                _st.update(entry)

        csvc_packet_entities = \
          pi.read(p_io, index.find(pb_n.CSVCMsg_PacketEntities))

        bitstream = bs.construct(csvc_packet_entities.entity_data)
        ct = csvc_packet_entities.updated_entries

        unpacker = uent.unpack(bitstream, -1, ct, False, cb, self.world)

        for index, mode, context in unpacker:
            if mode & PVS.Entering:
                cls, serial, diff = context

                if cls not in self._baseline_cache:
                    bitstream = bs.construct(
                        st['instancebaseline'].get(cls)[1])
                    unpacker = uent.unpack(bitstream, -1, 1, False, cb,
                                           self.world)

                    self._baseline_cache[cls] = unpacker.unpack_baseline(
                        rt[cls])

                state = dict(self._baseline_cache[cls])
                state.update(diff)

                self.world.create(cls, index, serial, state)
            elif mode & PVS.Deleting:
                self.world.delete(index)
            elif mode ^ PVS.Leaving:
                state = dict(self.world.find_index(index))
                state.update(context)

                self.world.update(index, state)

        return peek.tick, self.string_tables, self.world
예제 #2
0
파일: stream.py 프로젝트: Muzzoid/skadi
  def apply(self, peek):
    self.tick = peek.tick
    st, cb, rt = self.string_tables, self.class_bits, self.recv_tables
    st_ib = st['instancebaseline']

    packet = di.read(self.io, peek)
    p_io = io.BufferedReader(io.BytesIO(packet.data))
    index = pi.index(p_io)

    csvc_update_string_table_peeks = \
      index.find_all(pb_n.CSVCMsg_UpdateStringTable)
    all_csvc_update_string_table = \
      [pi.read(p_io, p) for p in csvc_update_string_table_peeks]

    for pbmsg in all_csvc_update_string_table:
      key = self.string_tables.keys()[pbmsg.table_id]
      _st = self.string_tables[key]

      bitstream = bs.construct(pbmsg.string_data)
      ne = pbmsg.num_changed_entries
      eb, sf, sb = _st.entry_bits, _st.size_fixed, _st.size_bits

      for entry in ust.unpack(bitstream, ne, eb, sf, sb):
        _st.update(entry)

    csvc_packet_entities = \
      pi.read(p_io, index.find(pb_n.CSVCMsg_PacketEntities))

    bitstream = bs.construct(csvc_packet_entities.entity_data)
    ct = csvc_packet_entities.updated_entries

    unpacker = uent.unpack(bitstream, -1, ct, False, cb, self.world)

    for index, mode, context in unpacker:
      if mode & PVS.Entering:
        cls, serial, diff = context

        if cls not in self._baseline_cache:
          bitstream = bs.construct(st['instancebaseline'].get(cls)[1])
          unpacker = uent.unpack(bitstream, -1, 1, False, cb, self.world)

          self._baseline_cache[cls] = unpacker.unpack_baseline(rt[cls])

        state = dict(self._baseline_cache[cls])
        state.update(diff)

        self.world.create(cls, index, serial, state)
      elif mode & PVS.Deleting:
        self.world.delete(index)
      elif mode ^ PVS.Leaving:
        state = dict(self.world.find_index(index))
        state.update(context)

        self.world.update(index, state)

    return peek.tick, self.string_tables, self.world
예제 #3
0
파일: demo.py 프로젝트: mugsy-mcgeee/skadi
  def stream(self, tick=0):
    match = self.index.match
    cb, rt = self.class_bits, self.recv_tables
    st = copy.deepcopy(self.string_tables)
    st_ib = st['instancebaseline']

    full_packet_peeks = \
      filter(lambda peek: peek.tick <= tick, match.full_packet_peeks)

    for peek in full_packet_peeks:
      full_packet = di.read(self.io, peek)

      for table in full_packet.string_table.tables:
        assert not table.items_clientside

        if table.table_name == 'ActiveModifiers':
          observer = o_am.construct()
        else:
          observer = None

        entries = [(i, e.str, e.data) for i, e in enumerate(table.items)]
        st[table.table_name].update_all(entries)

    full_packet = di.read(self.io, full_packet_peeks[-1])
    p_io = io.BufferedReader(io.BytesIO(full_packet.packet.data))
    index = pi.index(p_io)

    csvc_packet_entities = \
      pi.read(p_io, index.find(pb_n.CSVCMsg_PacketEntities))

    world = w.construct(rt)

    bitstream = bs.construct(csvc_packet_entities.entity_data)
    ct = csvc_packet_entities.updated_entries
    unpacker = uent.unpack(bitstream, -1, ct, False, cb, world)

    for index, mode, (cls, serial, diff) in unpacker:
      bitstream = bs.construct(st['instancebaseline'].get(cls)[1])
      unpacker = uent.unpack(bitstream, -1, 1, False, cb, world)
      state = dict(unpacker.unpack_baseline(rt[cls]))
      state.update(diff)

      try:
        world.create(cls, index, serial, state)
      except AssertionError, e:
        print e
예제 #4
0
파일: demo.py 프로젝트: twocngdagz/skadi
    def stream(self, tick=0):
        match = self.index.match
        cb, rt = self.class_bits, self.recv_tables
        st = copy.deepcopy(self.string_tables)
        st_ib = st['instancebaseline']

        full_packet_peeks = \
          filter(lambda peek: peek.tick <= tick, match.full_packet_peeks)

        for peek in full_packet_peeks:
            full_packet = di.read(self.io, peek)

            for table in full_packet.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)

        full_packet = di.read(self.io, full_packet_peeks[-1])
        p_io = io.BufferedReader(io.BytesIO(full_packet.packet.data))
        index = pi.index(p_io)

        csvc_packet_entities = \
          pi.read(p_io, index.find(pb_n.CSVCMsg_PacketEntities))

        world = w.construct(rt)

        bitstream = bs.construct(csvc_packet_entities.entity_data)
        ct = csvc_packet_entities.updated_entries
        unpacker = uent.unpack(bitstream, -1, ct, False, cb, world)

        for index, mode, (cls, serial, diff) in unpacker:
            bitstream = bs.construct(st['instancebaseline'].get(cls)[1])
            unpacker = uent.unpack(bitstream, -1, 1, False, cb, world)
            state = dict(unpacker.unpack_baseline(rt[cls]))
            state.update(diff)

            try:
                world.create(cls, index, serial, state)
            except AssertionError, e:
                print e