#!/usr/bin/env python3 import struct from .packets_in import in_packets from .packets_out import out_packets class Char(object): """ Author: jak1 License: GPLv2+ State: Testing (Draft) Class Char: handles Char Packets (some packets can only get used in the right order!) socket: bound char server socket debugging: enabled if True, disabled otherwise NOTE: does the stored data allready have the right type? may i need to convert/cast them. """ def __init__(self, socket, debugging=False): self.socket = socket self.debugging = debugging def sendLogin(self, char_logindata, client_protocol_version): """ Function: sendLogin send login data to char server char_logindata: (dict) (of Login.getCharLoginData) returns: None """ out_packets[0x0065].send_data( self.socket, [char_logindata['account_id'], char_logindata['session_id_p1'], char_logindata['session_id_p2'], client_protocol_version, char_logindata['gender']], self.debugging) out_packets[0x0065].process_data() def getLoginChars(self): """ Function: getLoginChars recvs character-slots returns: TODO: desc-> [chars(...)] """ # FIXME: can hit the size, better using 2048 (breaking or lagging), while logging in it # should not matter to have lag, so i guess its better save then sorry in_packets[0x006b].recv_data(self.socket, 1024, self.debugging) in_packets[0x006b].process_data() char_packet_len = 144 chars_raw = in_packets[0x006b].get_list_data()[10] char_count = int(len(chars_raw) / char_packet_len) # slot[%] = {char_data} slots = [{}] for x in range(char_count): GID, exp, money, jobexp, joblevel, bodystate, healthstate, effectstate, virtue, honor, jobpoint, hp, \ maxhp, sp, maxsp, speed, job, head, weapon, level, sppoint, accessory, shield, accessory2, accessory3, \ headpalette, bodypalette, name, Str, Agi, Vit, Int, Dex, Luk, CharNum, haircolor, bIsChangedCharName, \ lastMap, DeleteDate, Robe, SlotAddon, RenameAddon = struct.unpack( "