Ejemplo n.º 1
0
    def sendShamanSkills(self, refresh):
        packet = ByteArray().writeByte(len(self.client.playerSkills))
        for skill in self.client.playerSkills.items():
            packet.writeByte(skill[0]).writeByte(skill[1])

        packet.writeBoolean(refresh)

        self.client.sendPacket(Identifiers.send.Shaman_Skills, packet.toByteArray())
Ejemplo n.º 2
0
 def sendShamanSkills(this, newBoolean):
     p = ByteArray().writeByte(len(this.client.playerSkills))
     for skill in this.client.playerSkills.items():
         p.writeUnsignedByte(skill[0]).writeUnsignedByte(
             5 if this.client.playerSkills[skill[0]] >= 6 else skill[1])
     this.client.sendPacket(Identifiers.send.Shaman_Skills,
                            p.writeBoolean(newBoolean).toByteArray())
Ejemplo n.º 3
0
    def sendShopList(self, sendItems=True):
        shopItems = [] if self.client.shopItems == "" else self.client.shopItems.split(
            ",")

        packet = ByteArray().writeInt(self.client.shopCheeses).writeInt(
            self.client.shopFraises).writeUTF(self.client.playerLook).writeInt(
                len(shopItems))
        for item in shopItems:
            if "_" in item:
                itemSplited = item.split("_")
                realItem = itemSplited[0]
                custom = itemSplited[1] if len(itemSplited) >= 2 else ""
                realCustom = [] if custom == "" else custom.split("+")

                packet.writeByte(len(realCustom) + 1).writeInt(int(realItem))

                x = 0
                while x < len(realCustom):
                    packet.writeInt(int(realCustom[x], 16))
                    x += 1
            else:
                packet.writeByte(0).writeInt(int(item))

        shop = self.server.shopList if sendItems else []
        packet.writeInt(len(shop))

        for item in shop:
            value = item.split(",")
            packet.writeShort(int(value[0])).writeShort(int(
                value[1])).writeByte(int(value[2])).writeByte(
                    int(value[3])).writeByte(int(value[4])).writeInt(
                        int(value[5])).writeInt(int(value[6])).writeShort(0)

        visuais = self.server.newVisuList
        packet.writeByte(len(visuais))
        i = len(visuais)
        for visual in visuais.items():
            packet.writeShort(visual[0])
            a = visual[1]
            packet.writeUTF("".join(a))
            packet.writeByte(visual[2])
            i -= 1

        packet.writeShort(len(self.client.clothes))

        for clothe in self.client.clothes:
            clotheSplited = clothe.split("/")
            packet.writeUTF(clotheSplited[1] + ";" + clotheSplited[2] + ";" +
                            clotheSplited[3])

        shamanItems = [] if self.client.shamanItems == "" else self.client.shamanItems.split(
            ",")
        packet.writeShort(len(shamanItems))

        for item in shamanItems:
            if "_" in item:
                itemSplited = item.split("_")
                realItem = itemSplited[0]
                custom = itemSplited[1] if len(itemSplited) >= 2 else ""
                realCustom = [] if custom == "" else custom.split("+")

                packet.writeShort(int(realItem))

                packet.writeBoolean(item in self.client.shamanLook.split(
                    ",")).writeByte(len(realCustom) + 1)

                x = 0
                while x < len(realCustom):
                    packet.writeInt(int(realCustom[x], 16))
                    x += 1
            else:
                packet.writeShort(int(item)).writeBoolean(
                    item in self.client.shamanLook.split(",")).writeByte(0)

        shamanShop = self.server.shamanShopList if sendItems else []
        packet.writeShort(len(shamanShop))

        for item in shamanShop:
            value = item.split(",")
            packet.writeInt(int(value[0])).writeByte(int(value[1])).writeByte(
                int(value[2])).writeByte(int(value[3])).writeInt(int(
                    value[4])).writeShort(int(value[5]))

        self.client.sendPacket(Identifiers.send.Shop_List,
                               packet.toByteArray())
    def sendShopList(this, sendItems=True):
        shopItems = [] if this.client.shopItems == "" else this.client.shopItems.split(
            ",")

        packet = ByteArray().writeInt(this.client.shopCheeses).writeInt(
            this.client.shopFraises).writeUTF(this.client.playerLook).writeInt(
                len(shopItems))
        for item in shopItems:
            if "_" in item:
                itemSplited = item.split("_")
                realItem = itemSplited[0]
                custom = itemSplited[1] if len(itemSplited) >= 2 else ""
                realCustom = [] if custom == "" else custom.split("+")

                packet.writeByte(len(realCustom) + 1).writeInt(int(realItem))

                x = 0
                while x < len(realCustom):
                    packet.writeInt(int(realCustom[x], 16))
                    x += 1
            else:
                packet.writeByte(0).writeInt(int(item))

        shop = this.server.shopList if sendItems else []
        packet.writeInt(len(shop))

        for item in shop:
            value = item.split(",")
            packet.writeShort(int(value[0])).writeShort(int(
                value[1])).writeByte(int(value[2])).writeByte(
                    int(value[3])).writeByte(int(value[4])).writeInt(
                        int(value[5])).writeInt(int(value[6])).writeShort(0)

        looks = []
        packet.writeByte(len(looks))
        for look in looks:
            packet.writeShort(look[0])
            packet.writeUTF(look[1])
            packet.writeByte(look[2])

        packet.writeShort(len(this.client.clothes))

        for clothe in this.client.clothes:
            clotheSplited = clothe.split("/")
            packet.writeUTF(clotheSplited[1] + ";" + clotheSplited[2] + ";" +
                            clotheSplited[3])

        shamanItems = [] if this.client.shamanItems == "" else this.client.shamanItems.split(
            ",")
        packet.writeShort(len(shamanItems))

        for item in shamanItems:
            if "_" in item:
                itemSplited = item.split("_")
                realItem = itemSplited[0]
                custom = itemSplited[1] if len(itemSplited) >= 2 else ""
                realCustom = [] if custom == "" else custom.split("+")

                packet.writeShort(int(realItem))

                packet.writeBoolean(item in this.client.shamanLook.split(
                    ",")).writeByte(len(realCustom) + 1)

                x = 0
                while x < len(realCustom):
                    packet.writeInt(int(realCustom[x], 16))
                    x += 1
            else:
                packet.writeShort(int(item)).writeBoolean(
                    item in this.client.shamanLook.split(",")).writeByte(0)

        shamanShop = this.server.shamanShopList if sendItems else []
        packet.writeShort(len(shamanShop))

        for item in shamanShop:
            value = item.split(",")
            packet.writeInt(int(value[0])).writeByte(int(value[1])).writeByte(
                int(value[2])).writeByte(int(value[3])).writeInt(int(
                    value[4])).writeShort(int(value[5]))

        this.client.sendPacket(Identifiers.send.Shop_List,
                               packet.toByteArray())
Ejemplo n.º 5
0
    def openModoPwet(self,
                     isOpen=False,
                     modopwetOnlyPlayerReports=False,
                     sortBy=False):
        if isOpen:
            if len(self.server.reports) <= 0:
                self.client.sendPacket(Identifiers.send.Modopwet_Open, 0)
            else:
                self.client.sendPacket(Identifiers.send.Modopwet_Open, 0)
                reports, bannedList, deletedList, disconnectList = self.sortReports(
                    self.server.reports, sortBy), {}, {}, []
                sayi = 0
                p = ByteArray()
                for i in reports:
                    isim = i[0]
                    v = self.server.reports[isim]
                    if self.client.modoPwetLangue == 'ALL' or v[
                            "dil"] == self.client.modoPwetLangue:
                        oyuncu = self.server.players.get(isim)
                        saat = math.floor(oyuncu.playerTime /
                                          3600) if oyuncu else 0
                        odaisim = oyuncu.roomName if oyuncu else "0"
                        sayi += 1
                        self.client.lastReportID += 1
                        if sayi >= 255:
                            break
                        p.writeByte(sayi)
                        p.writeShort(self.client.lastReportID)
                        p.writeUTF(v["dil"])
                        p.writeUTF(isim)
                        p.writeUTF(odaisim)
                        p.writeByte(1)  # alttaki modname uzunlugu ile alakali
                        p.writeUTF(self.getRoomMods(odaisim))
                        p.writeInt(saat)  #idk
                        p.writeByte(int(len(v["reporters"])))
                        for name in v["reporters"]:
                            r = v["reporters"][name]
                            p.writeUTF(name)
                            p.writeShort(self.getPlayerKarma(name))  #karma
                            p.writeUTF(r[1])
                            p.writeByte(r[0])
                            p.writeShort(int(Utils.getSecondsDiff(r[2]) /
                                             60))  #05m felan rep suresi

                        mute = v["isMuted"]
                        p.writeBoolean(mute)  #isMute
                        if mute:
                            p.writeUTF(v["mutedBy"])
                            p.writeShort(v["muteHours"])
                            p.writeUTF(v["muteReason"])

                        if v['durum'] == 'banned':
                            x = {}
                            x['banhours'] = v['banhours']
                            x['banreason'] = v['banreason']
                            x['bannedby'] = v['bannedby']
                            bannedList[isim] = x
                        if v['durum'] == 'deleted':
                            x = {}
                            x['deletedby'] = v['deletedby']
                            deletedList[isim] = x
                        if v['durum'] == 'disconnected':
                            disconnectList.append(isim)

                self.client.sendPacket(
                    Identifiers.send.Modopwet_Open,
                    ByteArray().writeByte(int(len(reports))).writeBytes(
                        p.toByteArray()).toByteArray())
                for user in disconnectList:
                    self.changeReportStatusDisconnect(user)

                for user in deletedList.keys():
                    self.changeReportStatusDeleted(
                        user, deletedList[user]['deletedby'])

                for user in bannedList.keys():
                    self.changeReportStatusBanned(
                        user, bannedList[user]['banhours'],
                        bannedList[user]['banreason'],
                        bannedList[user]['bannedby'])
Ejemplo n.º 6
0
    def openThread(self, thread_id, page):
        if page == -1: page = 0
        if page != 0: limit1, limit2 = (page * 20) - 1, page * 40
        else: limit1, limit2 = 0, 20
        dbcur.execute("SELECT * FROM forum_threads where thread_id = ?",
                      [thread_id])
        topicData = dbcur.fetchone()
        dbcur.execute(
            "SELECT * FROM forum_comments where thread_id = ? ORDER BY time  LIMIT ?, ?;",
            [thread_id, limit1, limit2])
        topicStartMessage = dbcur.fetchall()[0]
        forum_id = topicData[0]
        self.forum_id = forum_id
        self.thread_id = thread_id

        p = ByteArray("\x02\x05")
        # [FORUM INFO] #
        p.writeInt(forum_id)  # forumEnCours
        p.writeInt(thread_id)  # sujetEnCours
        canEdit = self.user_type in self.userTypeNeededForPeutModerer
        if canEdit: canEdit = 10
        elif self.username == topicStartMessage[3]: canEdit = 1
        p.writeByte(canEdit)  # edition
        p.writeBoolean(self.user_type != 19)  # peutSuppr
        peutReponder = self.username != ""
        if bool(topicData[7]): peutReponder = False
        if not self.login: openthread = False
        if self.username in om: peutReponder = False
        p.writeBoolean(peutReponder)  # peutRepondre
        p.writeBoolean(bool(topicData[7]))  # fin
        p.writeBoolean(self.user_type != 19)  # modTribu
        p.writeUTF(topicData[2])  # titre
        p.writeInt(page)  # pageEnCours
        p.writeInt(int(
            len(self.getcommentsbythread(thread_id, forum_id)) /
            20))  # nobrePage
        dbcur.execute(
            "SELECT * FROM forum_comments where thread_id = ? ORDER BY time LIMIT ?, ?",
            [thread_id, limit1, limit2])
        messages = dbcur.fetchall()
        p.writeByte(len(messages) - 1)  # message
        for message in messages:
            p.writeInt(message[2])  # id
            p.writeByte(self.getJoueurType(
                message[3].encode("cp1251")))  # typeAuteurMessage
            p.writeUTF(message[3])  # auteur
            p.writeByte(self.getJoueurType(
                message[3].encode("cp1251")))  # typeAuteurCourant
            p.writeInt(10000)  # avatar
            p.writeInt(message[6])  # date
            p.writeUTF(message[5])  # texte
            p.writeByte(message[7])  # etat
            p.writeUTF(message[8].encode('utf-8', 'replace'))  # nomModerateur
            p.writeUTF(message[9].encode('utf-8', 'replace'))  # raisonEtat
            p.writeUTF("")  # infos
            p.writeBoolean(True)  # multiLangues
            p.writeBoolean(False)  # etatSignalement
            #p.writeUTF("TEST Title")
        self.transport.write(p.toPack())
Ejemplo n.º 7
0
    def openForums(self, forum_id, page):
        if page == -1: page = 0
        self.forum_id = forum_id
        if page != 0: limit1, limit2 = page * 20, page * 40
        else: limit1, limit2 = 0, 20

        p = ByteArray("\x02\x04")
        if forum_id == 1:
            openthread = self.user_type in [17, 18, 14, 20]
        else:
            openthread = True
        if self.username in om:
            openthread = False
        if not self.login:
            openthread = False
        p.writeBoolean(openthread)  # peutCreerSujet

        # [FORUM INFO] #

        ###Tribe Forums###
        if forum_id > 2000:
            dbcur.execute("SELECT * FROM forum_forums where id = ?",
                          [int(forum_id)])
            td = dbcur.fetchone()
            if not td == None:
                pass
            else:
                dbcur.execute("INSERT INTO forum_forums VALUES (?,?,?)",
                              ["xx", (forum_id), "9"])
            dbcur.execute("SELECT * FROM tribu where Code = ?",
                          [int(forum_id) - 2000])
            ntd = dbcur.fetchone()
            p.writeInt(forum_id)
            p.writeUTF("xx")
            p.writeShort(9)
            p.writeByte(False)
            p.writeUTF(ntd[1], True)
            dbcur.execute("SELECT * FROM forum_forums where id=?", [forum_id])
            forum = dbcur.fetchone()
        else:
            dbcur.execute("SELECT * FROM forum_forums where id=?", [forum_id])
            forum = dbcur.fetchone()
            p.writeInt(int(forum[1]))  # forumId
            p.writeUTF(str(forum[0]))  # forumCountry
            p.writeShort(int(forum[2]))  # forumIcon
        p.writeInt(page)  # pageCurrent
        p.writeInt(self.generateThreadsPage(forum_id) + 1)  # pageTotal
        #
        p.writeBoolean(
            False)  # masquerSujetCourrant # публичный форум : boolean

        dbcur.execute(
            "SELECT * FROM forum_threads where forum_id=? ORDER BY sticky DESC, date DESC LIMIT ?, ?",
            [forum_id, limit1, limit2])
        threads = dbcur.fetchall()
        threadNum = 0
        for row in threads:
            z = row[1]
            # [InfoServeurSujet] #
            dbcur.execute(
                "SELECT * FROM forum_comments where thread_id=? ORDER BY time DESC",
                [z])
            topicLastMessage = dbcur.fetchall()[0]
            p.writeInt(row[1])  # code
            p.writeUTF(row[2])  # titre
            p.writeInt(int(row[3]))  # date
            p.writeUTF(row[4].encode("cp1251"))  # auteur
            p.writeByte(self.getJoueurType(
                row[4].encode("cp1251")))  # typeAuteur
            p.writeUTF(topicLastMessage[3].encode("cp1251"))  # last_posteur
            p.writeInt(len(self.getcommentsbythread(row[1],
                                                    forum[1])))  # numMessage
            typeThread = 0
            if bool(row[7]): typeThread = 2
            p.writeByte(typeThread)  # type
            p.writeBoolean(bool(row[6]))  # postIt
            p.writeInt(threadNum)  # nombreSignalements
            threadNum += 1
        self.transport.write(p.toPack())