Exemplo n.º 1
0
 def OnResponseEnterGame(self, buffer):
     global packet_format
     MsgType = struct.unpack("<h", buffer[:2])[0]
     buffer = buffer[2:]
     if MsgType == Packets.DEF_ENTERGAMERESTYPE_REJECT:
         self.Status = False
         return
     elif MsgType == Packets.DEF_ENTERGAMERESTYPE_CONFIRM:
         self.Status = True
         fmt = "<16sh"
         fmt_s = struct.calcsize(fmt)
         self.Status = map(packet_format, struct.unpack(fmt, buffer[:fmt_s]))
         return
     else:
         print Packets.reverse_lookup_without_mask(MsgType)
         self.Status = False
Exemplo n.º 2
0
    def OnAccountLogin(self, buffer):

        MsgType = struct.unpack('<h', buffer[:2])[0]
        buffer = buffer[2:]

        self.Status = MsgType

        if MsgType == Packets.DEF_MSGTYPE_CONFIRM:
            print "Account %s login ok... Retrieving character list." % self.Config[
                'Account']
            account_fmt = "<2H13xb"  #12x -> dates -> can skip
            account_size = struct.calcsize(account_fmt)
            account = struct.unpack(account_fmt, buffer[:account_size])
            buffer = buffer[account_size:]
            account = namedtuple(
                'Account',
                'LowerVersion UpperVersion CharCount')._make(account)
            char_format = "<10sx12xhi6h4x10x10s"
            char_size = struct.calcsize(char_format)
            character = namedtuple(
                'Character',
                'CharName Level Exp Str Vit Dex Int Mag Chr MapLoc')
            char_list = []
            for c in range(account.CharCount):
                tmp = buffer[:char_size]
                buffer = buffer[char_size:]
                tmp = map(packet_format, struct.unpack(char_format, tmp))
                char_list += [character._make(tmp)]
            self.char_list = char_list
            self.LoggedIn = True
            return True
        elif MsgType == Packets.DEF_LOGRESMSGTYPE_REJECT:
            print "Account %s blocked!" % self.Config['Account']
            return False
        elif MsgType == Packets.DEF_LOGRESMSGTYPE_PASSWORDMISMATCH:
            print "Account %s password mismatch!" % self.Config['Password']
            return False
        elif MsgType == Packets.DEF_LOGRESMSGTYPE_NOTEXISTINGACCOUNT:
            print "Account %s does not exists!" % self.Config['Account']
            return False
        elif MsgType == Packets.DEF_LOGRESMSGTYPE_NOTEXISTINGWORLDSERVER:
            print "Account %s: World server is not activated" % (
                self.Config['Account'])
            return False
        else:
            print Packets.reverse_lookup_without_mask(MsgType)
            return False
Exemplo n.º 3
0
 def OnResponseEnterGame(self, buffer):
     global packet_format
     MsgType = struct.unpack('<h', buffer[:2])[0]
     buffer = buffer[2:]
     if MsgType == Packets.DEF_ENTERGAMERESTYPE_REJECT:
         self.Status = False
         return
     elif MsgType == Packets.DEF_ENTERGAMERESTYPE_CONFIRM:
         self.Status = True
         fmt = "<16sh"
         fmt_s = struct.calcsize(fmt)
         self.Status = map(packet_format,
                           struct.unpack(fmt, buffer[:fmt_s]))
         return
     else:
         print Packets.reverse_lookup_without_mask(MsgType)
         self.Status = False
Exemplo n.º 4
0
    def OnAccountLogin(self, buffer):

        MsgType = struct.unpack("<h", buffer[:2])[0]
        buffer = buffer[2:]

        self.Status = MsgType

        if MsgType == Packets.DEF_MSGTYPE_CONFIRM:
            print "Account %s login ok... Retrieving character list." % self.Config["Account"]
            account_fmt = "<2H13xb"  # 12x -> dates -> can skip
            account_size = struct.calcsize(account_fmt)
            account = struct.unpack(account_fmt, buffer[:account_size])
            buffer = buffer[account_size:]
            account = namedtuple("Account", "LowerVersion UpperVersion CharCount")._make(account)
            char_format = "<10sx12xhi6h4x10x10s"
            char_size = struct.calcsize(char_format)
            character = namedtuple("Character", "CharName Level Exp Str Vit Dex Int Mag Chr MapLoc")
            char_list = []
            for c in range(account.CharCount):
                tmp = buffer[:char_size]
                buffer = buffer[char_size:]
                tmp = map(packet_format, struct.unpack(char_format, tmp))
                char_list += [character._make(tmp)]
            self.char_list = char_list
            self.LoggedIn = True
            return True
        elif MsgType == Packets.DEF_LOGRESMSGTYPE_REJECT:
            print "Account %s blocked!" % self.Config["Account"]
            return False
        elif MsgType == Packets.DEF_LOGRESMSGTYPE_PASSWORDMISMATCH:
            print "Account %s password mismatch!" % self.Config["Password"]
            return False
        elif MsgType == Packets.DEF_LOGRESMSGTYPE_NOTEXISTINGACCOUNT:
            print "Account %s does not exists!" % self.Config["Account"]
            return False
        elif MsgType == Packets.DEF_LOGRESMSGTYPE_NOTEXISTINGWORLDSERVER:
            print "Account %s: World server is not activated" % (self.Config["Account"])
            return False
        else:
            print Packets.reverse_lookup_without_mask(MsgType)
            return False