def disconnect(self): self.stopScripts() self.pm.sendQuitGame(self.mapSocket) event.removeSocket(self.mapSocket) self.mapSocket.close() self.inventory = [] self.cart = []
def disconnect(self): self.stopScripts() self.pm.sendQuitGame(self.mapSocket) event.removeSocket(self.mapSocket) self.mapSocket.close() self.inventory=[] self.cart=[]
def charParser(socket): data = socket.recv(1024) print len(data) if len(data) < 4: log.error("Char login bad error") return if data.startswith(conn.accountID): data = data[4:] if len(data) == 0: return (header,) = struct.unpack('H', data[0:2]) if header == 0x6c: log.error("Char login denied") return elif header == 0x81: log.error("Already logged in") return elif header == 0x71: mapname = data[6:22].split('\x00\x00')[0] conn.mapname = mapname socket.close() event.removeSocket(socket) event.addEvent(lambda: self.mapConnect(conn), 0) elif header == 0x6b: (length,) = struct.unpack('H', data[2:4]) if (length - 24) % 108 == 0: charlen = 108 elif (length - 24) % 106 == 0: charlen = 106 numChars = (length - 24) / charlen log.info("Number of characters: %d",numChars) for i in range(0, numChars): offset = 24 + i * charlen res = struct.unpack('IIIIIIIIIIHHHHHHHHHHHHHHHHH24sBBBBBBH', data[offset:offset+106]) if conn.slot == res[34]: conn.charID = res[0] log.info('CharId: %s', util.toHex(struct.pack('I', conn.charID))) conn.baseExp = res[1] conn.zeny = res[2] conn.jobExp = res[3] conn.jobLevel = res[4] conn.hp = res[11] conn.maxhp = res[12] conn.sp = res[13] conn.maxsp = res[14] conn.charname = res[27].split('\x00')[0] socket.send('\x87\x01' + conn.accountID); socket.send(struct.pack('bxb', 0x66, conn.slot));
def loginParser(socket): data = socket.recv(1024) (header,) = struct.unpack('H', data[0:2]) if header == 0x6a: log.info("Rejected from server") return elif header == 0x69: (length,) = struct.unpack('H', data[2:4]) numServers = (length-47)/32 connection.accountID =data[8:12]; connection.sessionID1=data[4:8]; connection.sessionID2=data[12:16]; log.info("AccountId: %s SessionId1: %s SessionId2 %s", connection.accountID, connection.sessionID1, connection.sessionID2) connection.sex = data[46] socket.close() event.removeSocket(socket) event.addEvent(lambda: self.charLogin(connection), 0)
def initialHandler(socket): header = socket.recv(2) if header == '\x83\x02': #Eat the account ID data = socket.recv(4) event.setSocketHandler(socket, self.receiveData) conn.mapSocket = socket conn.addEvent(lambda: self.syncLoop(conn), 0) self.connections[socket] = conn self.sendMapAck(socket) self.eventHandlers[socket] = {} conn.startScripts() else: header = struct.unpack('H', data[0:2]) socket.close() event.removeSocket(socket) return