Example #1
0
 def __unpackPlayerData(self, packedData):
     sz = self._PLAYER_DATA_SIZE
     accountDBID, accountID, timeJoin, role, igrType, rating, peripheryID, clanDBID = struct.unpack_from(self._PLAYER_DATA, packedData)
     nickName, lenNickBytes = unpackPascalString(packedData, sz)
     clanAbbrev, lenClanBytes = unpackPascalString(packedData, sz + lenNickBytes)
     blockLength = sz + lenNickBytes + lenClanBytes
     badgesLength = struct.unpack_from('<B', packedData, blockLength)[0]
     blockLength += struct.calcsize('<B')
     if badgesLength:
         fmt = '<%dI' % badgesLength
         badges = list(struct.unpack_from(fmt, packedData, blockLength))
         blockLength += struct.calcsize(fmt)
     else:
         badges = list()
     return (blockLength,
      accountDBID,
      accountID,
      timeJoin,
      role,
      igrType,
      rating,
      peripheryID,
      clanDBID,
      nickName,
      clanAbbrev,
      badges)
Example #2
0
 def _unpackPlayer(self, packedOps):
     sz = self._qiiBBHH_SIZE
     (playerID, accountID, timeJoin, role, igrType, rating, peripheryID,) = struct.unpack_from('<qiIBBHH', packedOps)
     (nickName, lenNickBytes,) = unpackPascalString(packedOps, sz)
     (clanAbbrev, lenClanBytes,) = unpackPascalString(packedOps, sz + lenNickBytes)
     playerInfo = dict(accountID=accountID, role=role, timeJoin=timeJoin, rating=rating, nickName=nickName, clanAbbrev=clanAbbrev, peripheryID=peripheryID, igrType=igrType)
     self._addPlayer(playerID, **playerInfo)
     return packedOps[(sz + lenNickBytes + lenClanBytes):]
Example #3
0
 def _unpackPlayer(self, packedOps):
     sz = self._PLAYER_DATA_SIZE
     accountDBID, accountID, timeJoin, role, igrType, rating, peripheryID = struct.unpack_from(self._PLAYER_DATA, packedOps)
     nickName, lenNickBytes = unpackPascalString(packedOps, sz)
     clanAbbrev, lenClanBytes = unpackPascalString(packedOps, sz + lenNickBytes)
     playerInfo = dict(accountID=accountID, role=role, timeJoin=timeJoin, rating=rating, nickName=nickName, clanAbbrev=clanAbbrev, peripheryID=peripheryID, igrType=igrType)
     self._addPlayer(accountDBID, **playerInfo)
     return packedOps[sz + lenNickBytes + lenClanBytes:]
Example #4
0
 def _unpackPlayer(self, packedOps):
     sz = self._PLAYER_DATA_SIZE
     accountDBID, accountID, timeJoin, role, igrType, rating, peripheryID = struct.unpack_from(self._PLAYER_DATA, packedOps)
     nickName, lenNickBytes = unpackPascalString(packedOps, sz)
     clanAbbrev, lenClanBytes = unpackPascalString(packedOps, sz + lenNickBytes)
     playerInfo = dict(accountID=accountID, role=role, timeJoin=timeJoin, rating=rating, nickName=nickName, clanAbbrev=clanAbbrev, peripheryID=peripheryID, igrType=igrType)
     self._addPlayer(accountDBID, **playerInfo)
     return packedOps[sz + lenNickBytes + lenClanBytes:]
Example #5
0
    def unpack(self, packed):
        self._initClean()
        self._rosterTypeID, self._extrasHandlerID, self._prebattleTypeID = struct.unpack_from(self._IDS, packed)
        RosterType = ROSTER_TYPE_TO_CLASS.get(self._rosterTypeID)
        self._roster = RosterType()
        self._initExtrasHandler()
        unpacking = packed[self._IDS_SIZE :]
        unpacking = self._roster.unpack(unpacking)
        slotCount = self.getMaxSlotCount()
        self._freeSlots = set(xrange(0, slotCount))
        memberCount, vehCount, playerCount, extrasLen, self._readyMask, self._flags, self._closedSlotMask, self._modalTimestamp, self._gameplaysMask = struct.unpack_from(
            self._HEADER, unpacking
        )
        unpacking = unpacking[self._HEADER_SIZE :]
        for i in xrange(0, vehCount):
            accountDBID, vehInvID, vehTypeCompDescr = struct.unpack_from(self._PLAYER_VEHICLES, unpacking)
            self._setVehicle(accountDBID, vehTypeCompDescr, vehInvID)
            unpacking = unpacking[self._PLAYER_VEHICLES_SIZE :]

        for i in xrange(0, memberCount):
            slotIdx, accountDBID = struct.unpack_from(self._SLOT_PLAYERS, unpacking)
            self._setMember(accountDBID, slotIdx)
            unpacking = unpacking[self._SLOT_PLAYERS_SIZE :]

        sz = self._PLAYER_DATA_SIZE
        for i in xrange(0, playerCount):
            accountDBID, accountID, timeJoin, role, igrType, rating, peripheryID = struct.unpack_from(
                self._PLAYER_DATA, unpacking
            )
            nickName, lenNickBytes = unpackPascalString(unpacking, sz)
            clanAbbrev, lenClanBytes = unpackPascalString(unpacking, sz + lenNickBytes)
            unpacking = unpacking[sz + lenNickBytes + lenClanBytes :]
            self._addPlayer(
                accountDBID,
                accountID=accountID,
                timeJoin=timeJoin,
                role=role,
                rating=rating,
                nickName=nickName,
                clanAbbrev=clanAbbrev,
                peripheryID=peripheryID,
                igrType=igrType,
            )

        self._extras = self._extrasHandler.unpack(unpacking[:extrasLen])
        unpacking = unpacking[extrasLen:]
        for slotIdx in range(0, 7):
            slotMask = 1 << slotIdx
            if self._closedSlotMask & slotMask:
                self._closeSlot(slotIdx)

        self._strComment, lenCommentBytes = unpackPascalString(unpacking)
        unpacking = unpacking[lenCommentBytes:]
        lengthDiff = len(packed) - len(unpacking)
        self._packed = packed[:lengthDiff]
        self._packedOps = ""
        self._dirty = 0
        return unpacking
Example #6
0
    def unpack(self, packed):
        self._initClean()
        self._rosterTypeID, self._extrasHandlerID, self._prebattleTypeID = struct.unpack_from(self._IDS, packed)
        RosterType = ROSTER_TYPE_TO_CLASS.get(self._rosterTypeID)
        self._roster = RosterType()
        self._initExtrasHandler()
        unpacking = packed[self._IDS_SIZE:]
        unpacking = self._roster.unpack(unpacking)
        slotCount = self.getMaxSlotCount()
        self._freeSlots = set(xrange(0, slotCount))
        memberCount, vehCount, playerCount, extrasLen, self._readyMask, self._flags, self._closedSlotMask, self._modalTimestamp, self._gameplaysMask = struct.unpack_from(self._HEADER, unpacking)
        unpacking = unpacking[self._HEADER_SIZE:]
        for i in xrange(0, vehCount):
            accountDBID, vehListCount = struct.unpack_from(self._PLAYER_VEHICLES_LIST, unpacking)
            unpacking = unpacking[self._PLAYER_VEHICLES_LIST_SIZE:]
            vehDataList = []
            for i in xrange(0, vehListCount):
                vehInvID, vehTypeCompDescr = struct.unpack_from(self._PLAYER_VEHICLE_TUPLE, unpacking)
                unpacking = unpacking[self._PLAYER_VEHICLE_TUPLE_SIZE:]
                vehDataList.append((vehInvID, vehTypeCompDescr))

            self._setVehicleList(accountDBID, vehDataList)

        for i in xrange(0, memberCount):
            slotIdx, accountDBID = struct.unpack_from(self._SLOT_PLAYERS, unpacking)
            self._setMember(accountDBID, slotIdx)
            unpacking = unpacking[self._SLOT_PLAYERS_SIZE:]

        sz = self._PLAYER_DATA_SIZE
        for i in xrange(0, playerCount):
            accountDBID, accountID, timeJoin, role, igrType, rating, peripheryID = struct.unpack_from(self._PLAYER_DATA, unpacking)
            nickName, lenNickBytes = unpackPascalString(unpacking, sz)
            clanAbbrev, lenClanBytes = unpackPascalString(unpacking, sz + lenNickBytes)
            unpacking = unpacking[sz + lenNickBytes + lenClanBytes:]
            self._addPlayer(accountDBID, accountID=accountID, timeJoin=timeJoin, role=role, rating=rating, nickName=nickName, clanAbbrev=clanAbbrev, peripheryID=peripheryID, igrType=igrType)

        self._extras = self._extrasHandler.unpack(unpacking[:extrasLen])
        unpacking = unpacking[extrasLen:]
        for slotIdx in range(0, 7):
            slotMask = 1 << slotIdx
            if self._closedSlotMask & slotMask:
                self._closeSlot(slotIdx)

        self._strComment, lenCommentBytes = unpackPascalString(unpacking)
        unpacking = unpacking[lenCommentBytes:]
        lengthDiff = len(packed) - len(unpacking)
        self._packed = packed[:lengthDiff]
        self._packedOps = ''
        self._dirty = 0
        return unpacking
Example #7
0
 def __unpackPlayerData(self, packedData):
     sz = self._PLAYER_DATA_SIZE
     accountDBID, accountID, timeJoin, role, igrType, rating, peripheryID, clanDBID, isPremium = struct.unpack_from(
         self._PLAYER_DATA, packedData)
     offset = sz
     nickName, lenNickBytes = unpackPascalString(packedData, offset)
     offset += lenNickBytes
     clanAbbrev, lenClanBytes = unpackPascalString(packedData, offset)
     offset += lenClanBytes
     badges, lenBadgesInfo = BadgesCommon.unpackPlayerBadges(
         packedData, offset)
     offset += lenBadgesInfo
     return (offset, accountDBID, accountID, timeJoin, role, igrType,
             rating, peripheryID, clanDBID, isPremium, nickName, clanAbbrev,
             badges)
    def unpack(self, packedData):
        self._packed = packedData
        if len(packedData) <= 1:
            self._empty()
            return
        lenBattles, lenBattleUnits = struct.unpack_from(self.FORMAT_HEADER, packedData)
        self.battles = {}
        offset = self.SIZE_HEADER
        sz = self.SIZE_ADD_BATTLE_HEADER
        fmt = self.FORMAT_ADD_BATTLE_HEADER
        for i in xrange(lenBattles):
            battleID, peripheryID, createTime, startTime, isFinished = struct.unpack_from(fmt, packedData, offset)
            localizedDataStr, localizedDataLen = unpackPascalString(packedData, offset + sz)
            localizedData = cPickle.loads(localizedDataStr)
            offset += sz + localizedDataLen
            self.battles[battleID] = {'peripheryID': peripheryID,
             'createTime': createTime,
             'startTime': startTime,
             'isFinished': isFinished,
             'localizedData': localizedData}

        self.battleUnits = {}
        sz = self.SIZE_ADD_BATTLE_UNIT_HEADER
        fmt = self.FORMAT_ADD_BATTLE_UNIT_HEADER
        for i in xrange(lenBattleUnits):
            battleID, unitStrLen = struct.unpack_from(fmt, packedData, offset)
            offset += sz
            unitStr = packedData[offset:offset + unitStrLen]
            offset += unitStrLen
            self.battleUnits[battleID] = unitStr

        raise offset == len(packedData) or AssertionError
Example #9
0
    def unpack(self, packedData):
        self._packed = packedData
        if len(packedData) <= 1:
            self._empty()
            return
        lenBattles, lenBattleUnits = struct.unpack_from(self.FORMAT_HEADER, packedData)
        self.battles = {}
        offset = self.SIZE_HEADER
        sz = self.SIZE_ADD_BATTLE_HEADER
        fmt = self.FORMAT_ADD_BATTLE_HEADER
        for i in xrange(lenBattles):
            battleID, peripheryID, createTime, startTime, isFinished = struct.unpack_from(fmt, packedData, offset)
            localizedDataStr, localizedDataLen = unpackPascalString(packedData, offset + sz)
            localizedData = cPickle.loads(localizedDataStr)
            offset += sz + localizedDataLen
            self.battles[battleID] = {'peripheryID': peripheryID,
             'createTime': createTime,
             'startTime': startTime,
             'isFinished': isFinished,
             'localizedData': localizedData}

        self.battleUnits = {}
        sz = self.SIZE_ADD_BATTLE_UNIT_HEADER
        fmt = self.FORMAT_ADD_BATTLE_UNIT_HEADER
        for i in xrange(lenBattleUnits):
            battleID, unitStrLen = struct.unpack_from(fmt, packedData, offset)
            offset += sz
            unitStr = packedData[offset:offset + unitStrLen]
            offset += unitStrLen
            self.battleUnits[battleID] = unitStr

        raise offset == len(packedData) or AssertionError
Example #10
0
 def _unpackBattle(self, packedData):
     battleID, peripheryID, createTime, startTime, isFinished = struct.unpack_from(self.FORMAT_ADD_BATTLE_HEADER, packedData)
     localizedDataStr, localizedDataStrLen = unpackPascalString(packedData, self.SIZE_ADD_BATTLE_HEADER)
     self.battles[battleID] = {'peripheryID': peripheryID,
      'createTime': createTime,
      'startTime': startTime,
      'isFinished': isFinished,
      'localizedData': cPickle.loads(localizedDataStr)}
     return packedData[self.SIZE_ADD_BATTLE_HEADER + localizedDataStrLen:]
Example #11
0
 def _unpackBattle(self, packedData):
     battleID, peripheryID, createTime, startTime, isFinished = struct.unpack_from(self.FORMAT_ADD_BATTLE_HEADER, packedData)
     localizedDataStr, localizedDataStrLen = unpackPascalString(packedData, self.SIZE_ADD_BATTLE_HEADER)
     self.battles[battleID] = {'peripheryID': peripheryID,
      'createTime': createTime,
      'startTime': startTime,
      'isFinished': isFinished,
      'localizedData': cPickle.loads(localizedDataStr)}
     return packedData[self.SIZE_ADD_BATTLE_HEADER + localizedDataStrLen:]
Example #12
0
    def unpack(self, packed):
        self._initClean()
        self._rosterTypeID, self._extrasHandlerID = struct.unpack_from('<BB', packed)
        RosterType = ROSTER_TYPE_TO_CLASS.get(self._rosterTypeID)
        self._extrasHandler = EXTRAS_HANDLER_TYPE_TO_HANDLER[self._extrasHandlerID](self)
        self._roster = RosterType()
        unpacking = packed[self._BB_SIZE:]
        unpacking = self._roster.unpack(unpacking)
        slotCount = self.getMaxSlotCount()
        self._freeSlots = set(xrange(0, slotCount))
        memberCount, vehCount, playerCount, extrasLen, self._readyMask, self._state, self._closedSlotMask, self._modalTimestamp = struct.unpack_from(self._HEADER, unpacking)
        unpacking = unpacking[self._HEADER_SIZE:]
        for i in xrange(0, vehCount):
            playerID, vehInvID, vehTypeCompDescr = struct.unpack_from('<qiH', unpacking)
            self._setVehicle(playerID, vehTypeCompDescr, vehInvID)
            unpacking = unpacking[self._qiH_SIZE:]

        for i in xrange(0, memberCount):
            slotIdx, playerID = struct.unpack_from('<Bq', unpacking)
            self._setMember(playerID, slotIdx)
            unpacking = unpacking[self._Bq_SIZE:]

        sz = self._PLAYER_DATA_SIZE
        for i in xrange(0, playerCount):
            playerID, accountID, timeJoin, role, igrType, rating, peripheryID = struct.unpack_from(self._PLAYER_DATA, unpacking)
            nickName, lenNickBytes = unpackPascalString(unpacking, sz)
            clanAbbrev, lenClanBytes = unpackPascalString(unpacking, sz + lenNickBytes)
            unpacking = unpacking[sz + lenNickBytes + lenClanBytes:]
            self._addPlayer(playerID, accountID=accountID, timeJoin=timeJoin, role=role, rating=rating, nickName=nickName, clanAbbrev=clanAbbrev, peripheryID=peripheryID, igrType=igrType)

        self._extras = self._extrasHandler.unpack(unpacking[:extrasLen])
        unpacking = unpacking[extrasLen:]
        for slotIdx in range(0, 7):
            slotMask = 1 << slotIdx
            if self._closedSlotMask & slotMask:
                self._closeSlot(slotIdx)

        self._strComment, lenCommentBytes = unpackPascalString(unpacking, 0)
        unpacking = unpacking[lenCommentBytes:]
        lengthDiff = len(packed) - len(unpacking)
        self._packed = packed[:lengthDiff]
        self._packedOps = ''
        self._dirty = 0
        return unpacking
Example #13
0
    def unpack(self, packed):
        self._initClean()
        self._rosterTypeID = struct.unpack_from('<B', packed)[0]
        RosterType = ROSTER_TYPE_TO_CLASS.get(self._rosterTypeID)
        self._roster = RosterType()
        unpacking = packed[self._B_SIZE:]
        unpacking = self._roster.unpack(unpacking)
        slotCount = self.getMaxSlotCount()
        self._freeSlots = set(xrange(0, slotCount))
        (memberCount, vehCount, playerCount, self._readyMask, self._state, self._closedSlotMask, self._modalTimestamp,) = struct.unpack_from('<HHHHBBi', unpacking)
        unpacking = unpacking[self._HEADER_SIZE:]
        for i in xrange(0, vehCount):
            (playerID, vehInvID, vehTypeCompDescr,) = struct.unpack_from('<qiH', unpacking)
            self._setVehicle(playerID, vehTypeCompDescr, vehInvID)
            unpacking = unpacking[self._qiH_SIZE:]

        for i in xrange(0, memberCount):
            (slotIdx, playerID,) = struct.unpack_from('<Bq', unpacking)
            self._setMember(playerID, slotIdx)
            unpacking = unpacking[self._Bq_SIZE:]

        sz = self._qiiBBHH_SIZE
        for i in xrange(0, playerCount):
            (playerID, accountID, timeJoin, role, igrType, rating, peripheryID,) = struct.unpack_from('<qiIBBHH', unpacking)
            (nickName, lenNickBytes,) = unpackPascalString(unpacking, sz)
            (clanAbbrev, lenClanBytes,) = unpackPascalString(unpacking, sz + lenNickBytes)
            unpacking = unpacking[(sz + lenNickBytes + lenClanBytes):]
            self._addPlayer(playerID, accountID=accountID, timeJoin=timeJoin, role=role, rating=rating, nickName=nickName, clanAbbrev=clanAbbrev, peripheryID=peripheryID, igrType=igrType)

        for slotIdx in range(0, 7):
            slotMask = 1 << slotIdx
            if self._closedSlotMask & slotMask:
                self._closeSlot(slotIdx)

        (self._strComment, lenCommentBytes,) = unpackPascalString(unpacking, 0)
        unpacking = unpacking[lenCommentBytes:]
        lengthDiff = len(packed) - len(unpacking)
        self._packed = packed[:lengthDiff]
        self._packedOps = ''
        self._dirty = 0
        return unpacking