def unpack(self, buf: BinaryIO) -> None: self.magic_number = Packet.unpack_uint32(buf) self.version = Packet.unpack_uint32(buf) self.offset = Packet.unpack_uint32(buf) self.file_time = Packet.unpack_int64(buf) self.player = Packet.unpack_uint32(buf) self.flags_size = Packet.unpack_uint32(buf) self.world_size = Packet.unpack_uint32(buf) self.callsign = Packet.unpack_string(buf, NetworkProtocol.CALLSIGN_LEN) self.motto = Packet.unpack_string(buf, NetworkProtocol.MOTTO_LEN) self.server_version = Packet.unpack_string(buf, NetworkProtocol.SERVER_LEN) self.app_version = Packet.unpack_string(buf, NetworkProtocol.MESSAGE_LEN) self.real_hash = Packet.unpack_string(buf, NetworkProtocol.HASH_LEN) self.length = ReplayDuration(self.file_time) # Skip the appropriate number of bytes since we're not making use of this # data yet buf.read(4 + NetworkProtocol.WORLD_SETTING_SIZE) if self.flags_size > 0: buf.read(self.flags_size) buf.read(self.world_size)
def _unpack(self): self.player_index = Packet.unpack_uint8(self.buffer) self.player_type = Packet.unpack_uint16(self.buffer) self.team_value = Packet.unpack_uint16(self.buffer) self.score.wins = Packet.unpack_uint16(self.buffer) self.score.losses = Packet.unpack_uint16(self.buffer) self.score.team_kills = Packet.unpack_uint16(self.buffer) self.callsign = Packet.unpack_string(self.buffer, NetworkProtocol.CALLSIGN_LEN) self.motto = Packet.unpack_string(self.buffer, NetworkProtocol.MOTTO_LEN)
def _unpack(self): count: int = Packet.unpack_uint16(self.buffer) for i in range(0, count): setting: BZDBSetting = BZDBSetting() name_len: int = Packet.unpack_uint8(self.buffer) setting.name = Packet.unpack_string(self.buffer, name_len) value_len: int = Packet.unpack_uint8(self.buffer) setting.value = Packet.unpack_string(self.buffer, value_len) self.settings.append(setting)
def _unpack(self): self.player_from_id = Packet.unpack_uint8(self.buffer) self.player_to_id = Packet.unpack_uint8(self.buffer) self.message = Packet.unpack_string(self.buffer, -1)