Exemplo n.º 1
0
def get_str(data: DataView, offset: int) -> str:
    size = data.get_uint_8(offset)
    offset += 1
    return "".join([
        chr(
            data.get_uint_8((idx := (offset + 2 * counter)) + 1)
            | data.get_uint_8(idx) << 8) for counter in range(size)
    ])
Exemplo n.º 2
0
def parse_user(_data: bytes) -> Union[Player, int]:
    data = DataView(_data)
    player_id = data.get_int_32(size := 1)
    username = get_str(data, size := size + 4)
    skin_id = data.get_int_32(size := size + 2 * len(username) + 1)
    badge = 0

    if len(data) >= (size := size + 4 + 4) - 1:
        if data.get_int_32(size - 4) == -1:  # left?
            return player_id
 def _init_dataview(self):
     dv_basic = DataView()
     dv_basic.load_dataview(self.basic_path)
     start_date = dv_basic.start_date
     end_date = dv_basic.end_date
     index_member = dv_basic.get_field("index_member")
     trade_status = dv_basic.get_field("trade_status")
     index_member = index_member.loc[start_date:end_date]
     trade_status = trade_status.loc[start_date:end_date]
     index_member.columns = pd.Series(
         index_member.columns).apply(lambda x: x[:-3])
     trade_status.columns = pd.Series(
         trade_status.columns).apply(lambda x: x[:-3])
     return index_member, trade_status, start_date, end_date
Exemplo n.º 4
0
def parse_teams(_data: bytes, _players: Dict[int, Player]) -> Server:
    data = DataView(_data)

    team_size = data.get_uint_8(1)
    team_count = data.get_uint_8(2)

    server = Server(teams=list(), team_size=team_size, team_count=team_count)

    offset = 3
    for _ in itertools.repeat(None, team_count):
        team_id = data.get_uint_32(offset)

        map_percent = data.get_float_32(offset := offset + 4)
        map_percent = max(0, map_percent)

        available = bool(data.get_uint_8(offset := offset + 4))
Exemplo n.º 5
0
def create_login_phase(username: str, token: str, skin: int,
                       game_played: int) -> bytes:
    buffer = DataView(b"\x00" * (2 + (2 * len(username)) + 1 +
                                 (2 * len(token)) + 4 + 4))
    buffer.set_uint_8(idx := 0, 1)
    buffer.write_string(idx := idx + 1, username)
    buffer.write_string(idx := idx + 1 + 2 * len(username), token)
    buffer.set_int_32(idx := idx + 1 + 2 * len(token), skin)
    buffer.set_int_32(idx := idx + 4, game_played)
    return buffer.array