Esempio n. 1
0
File: demo.py Progetto: minjit/skadi
  def advance(self, tick, pbmsg):
    packet = i.construct(p_io.construct(pbmsg.data))
    all_ust = packet.find_all(pb_n.svc_UpdateStringTable)

    for _pbmsg in [p_io.parse(p.kind, m) for p, m in all_ust]:
      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

      for entry in u_st.construct(bs, ne, eb, sf, sb):
        _st.update(entry)

    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)
      elif mode & u_ent.PVS.Deleting:
        self.world.delete(index)
      elif mode ^ u_ent.PVS.Leaving:
        state = {} if self.sparse else dict(self.world.find_index(index))
        state.update(context)

        self.world.update(index, state)

    all_um = packet.find_all(pb_n.svc_UserMessage)
    user_messages = [e_um.parse(p_io.parse(p.kind, m)) for p, m in all_um]

    all_ge = packet.find_all(pb_n.svc_GameEvent)
    gel = self.prologue.game_event_list
    game_events = [e_ge.parse(p_io.parse(p.kind, m), gel) for p, m in all_ge]

    modifiers = self.string_tables['ActiveModifiers'].observer

    _, gamerules = self.world.find_by_dt('DT_DOTAGamerulesProxy')
    modifiers.expire(gamerules[('DT_DOTAGamerules', 'm_fGameTime')])

    return tick, user_messages, game_events, self.world, modifiers
Esempio n. 2
0
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
Esempio n. 3
0
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
Esempio n. 4
0
    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])
Esempio n. 5
0
  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])
Esempio n. 6
0
File: demo.py Progetto: minjit/skadi
    def advance(self, tick, pbmsg):
        packet = i.construct(p_io.construct(pbmsg.data))
        all_ust = packet.find_all(pb_n.svc_UpdateStringTable)

        for _pbmsg in [p_io.parse(p.kind, m) for p, m in all_ust]:
            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

            for entry in u_st.construct(bs, ne, eb, sf, sb):
                _st.update(entry)

        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)
            elif mode & u_ent.PVS.Deleting:
                self.world.delete(index)
            elif mode ^ u_ent.PVS.Leaving:
                state = {} if self.sparse else dict(
                    self.world.find_index(index))
                state.update(context)

                self.world.update(index, state)

        all_um = packet.find_all(pb_n.svc_UserMessage)
        user_messages = [e_um.parse(p_io.parse(p.kind, m)) for p, m in all_um]

        all_ge = packet.find_all(pb_n.svc_GameEvent)
        gel = self.prologue.game_event_list
        game_events = [
            e_ge.parse(p_io.parse(p.kind, m), gel) for p, m in all_ge
        ]

        modifiers = self.string_tables['ActiveModifiers'].observer

        _, gamerules = self.world.find_by_dt('DT_DOTAGamerulesProxy')
        modifiers.expire(gamerules[('DT_DOTAGamerules', 'm_fGameTime')])

        return tick, user_messages, game_events, self.world, modifiers