def serialize(self, stream): """ Serializes the packet """ stream.write(c_int64(self.objid)) stream.write(c_uint32(self.unknown1)) stream.write(self.character_name, allocated_length=33) stream.write(self.character_unapproved_name, allocated_length=33) stream.write(c_bool(self.is_name_rejected)) stream.write(c_bool(self.free_to_play)) stream.write(self.unknown2) stream.write(c_uint32(self.shirt_color)) stream.write(c_uint32(self.shirt_style)) stream.write(c_uint32(self.pants_color)) stream.write(c_uint32(self.hair_style)) stream.write(c_uint32(self.hair_color)) stream.write(c_uint32(self.lh)) stream.write(c_uint32(self.rh)) stream.write(c_uint32(self.eyebrows)) stream.write(c_uint32(self.eyes)) stream.write(c_uint32(self.mouth)) stream.write(c_uint32(self.unknown3)) stream.write(c_uint16(self.last_zone)) stream.write(c_uint16(self.last_instance)) stream.write(c_uint32(self.last_clone)) stream.write(c_uint64(self.last_login)) stream.write(c_uint16(len(self.equipped_items))) for item in self.equipped_items: stream.write(c_uint32(item))
def serialize(self, stream: bitstream.WriteStream) -> None: key_num = len(self._keys) stream.write(bitstream.c_uint(key_num)) for key in self._keys: name = key[0] value = key[1] value_type = key[2] stream.write(bitstream.c_uint8(len(name) * 2)) for char in name: stream.write(char.encode('latin1')) stream.write(b'\0') stream.write(bitstream.c_ubyte(value_type)) if value_type == 0: stream.write(value, length_type=bitstream.c_uint) elif value_type == 1: stream.write(bitstream.c_int(value)) elif value_type == 3: stream.write(bitstream.c_float(value)) elif value_type == 5: stream.write(bitstream.c_uint(value)) elif value_type == 7: stream.write(bitstream.c_bool(value)) elif value_type == 8 or value_type == 9: stream.write(bitstream.c_int64(value)) elif value_type == 13: xml_str = bytes(ElementTree.tostring(value)) xml_str = b'<?xml version="1.0">' + xml_str stream.write(bitstream.c_ulong(xml_str.__len__())) stream.write(xml_str)
def serialize(self, stream: bitstream.WriteStream) -> None: temp_stream = bitstream.WriteStream() temp_stream.write(self.ldf) temp_bytes = temp_stream.__bytes__() compressed_bytes = zlib.compress(temp_bytes) stream.write(bitstream.c_ulong(len(compressed_bytes) + 9)) stream.write(bitstream.c_bool(True)) stream.write(bitstream.c_ulong(len(temp_bytes))) stream.write(bitstream.c_ulong(len(compressed_bytes))) stream.write(compressed_bytes)
def serialize(self, stream: WriteStream): """ Serializes the packet """ super().serialize(stream) stream.write(c_uint8(self.auth_status_code)) stream.write(CString(self.unknown, allocated_length=33)) stream.write(CString(self.unknown1, allocated_length=33*7)) stream.write(self.client_version) stream.write(self.auth_token, allocated_length=33) stream.write(CString(self.char_ip, allocated_length=33)) stream.write(CString(self.chat_ip, allocated_length=33)) stream.write(c_uint16(self.char_port)) stream.write(c_uint16(self.chat_port)) stream.write(CString(self.unknown2, allocated_length=33)) stream.write(CString(self.unknown3, allocated_length=37)) stream.write(c_uint32(self.unknown4)) stream.write(CString(self.localization, allocated_length=3)) stream.write(c_bool(self.new_subscriber)) stream.write(c_bool(self.is_ftp)) stream.write(c_uint64(self.unknown5)) stream.write(self.permission_error, length_type=c_uint16) # TODO: Implement stamps stream.write(c_uint32(4))
def serialize(self, stream): """ Serializes the packet """ super().serialize(stream) # TODO: Make this stuff dynamic instead of just empty ldf = LegoData() ldf.write('accountID', self.account_id, data_type=c_int64) ldf.write('chatmode', 0, data_type=c_int32) ldf.write('editor_enabled', False, data_type=c_bool) ldf.write('editor_level', 0, data_type=c_int32) ldf.write('gmlevel', 0, data_type=c_int32) ldf.write('levelid', self.zone_id, data_type=c_int64) ldf.write('objid', self.objid, data_type=c_int64, data_num=9) ldf.write('reputation', 100, data_type=c_int64) ldf.write('template', 1, data_type=c_int32) xml = ElementTree.TreeBuilder() xml.start('obj', {'v': '1'}) xml.start('buff', {}) xml.end('buff') xml.start('skill', {}) xml.end('skill') xml.start('inv', {}) xml.start('bag', {}) xml.start('b', {'t': '0', 'm': str(self.inventory_space)}) xml.end('b') xml.end('bag') xml.start('items', {}) xml.start('in', {}) # TODO: inventory stuff here xml.end('in') xml.end('items') xml.end('inv') xml.start('mf', {}) xml.end('mf') xml.start('char', {'cc': str(self.currency)}) xml.end('char') xml.start('lvl', {'l': str(self.level)}) xml.end('lvl') xml.start('flag', {}) xml.end('flag') xml.start('pet', {}) xml.end('pet') xml.start('mis', {}) xml.start('cur', {}) for mission in [ mission for mission in self.missions if mission.state == 2 ]: xml.start('m', {'id': str(mission.mission), 'o': '1'}) xml.start('sv', {'v': str(mission.progress)}) xml.end('sv') xml.end('m') xml.end('cur') xml.start('done', {}) for mission in [ mission for mission in self.missions if mission.state == 8 ]: xml.start( 'm', { 'cct': str(mission.times_completed), 'id': str(mission.mission), 'cts': str(mission.last_completion) }) xml.end('m') xml.end('done') xml.end('mis') xml.start('mnt', {}) xml.end('mnt') xml.start('dest', {}) xml.end('dest') xml.end('obj') ldf.write('xmlData', xml.close()) ldf.write('name', self.name, data_type=str) ldf_stream = WriteStream() ldf_stream.write(ldf) ldf_bytes = bytes(ldf_stream) compressed = zlib.compress(ldf_bytes) stream.write(c_uint32(len(compressed) + 9)) stream.write(c_bool(True)) stream.write(c_uint32(len(ldf_bytes))) stream.write(c_uint32(len(compressed))) stream.write(compressed)
def serialize(self, stream: WriteStream): super().serialize(stream) stream.write(CString(self.ip, allocated_length=33)) stream.write(c_uint16(self.port)) stream.write(c_bool(self.mythran_notification))