Example #1
0
 def _addPlayer(self, playerID, **kwargs):
     self._players[playerID] = kwargs
     self._dirty = 1
     packed = struct.pack('<qiIBBHH', playerID, kwargs.get('accountID', 0), kwargs.get('timeJoin', 0), kwargs.get('role', 0), kwargs.get('igrType', 0), kwargs.get('rating', 0), kwargs.get('peripheryID', 0))
     packed += packPascalString(kwargs.get('nickName', ''))
     packed += packPascalString(kwargs.get('clanAbbrev', ''))
     self._appendOp(UNIT_OP.ADD_PLAYER, packed)
Example #2
0
    def pack(self):
        packed = struct.pack(self._IDS, self._rosterTypeID, self._extrasHandlerID, self._prebattleTypeID)
        packed += self._roster.getPacked()
        members = self._members
        players = self._players
        vehs = self._vehicles
        extras = self._extras
        extrasStr = self._extrasHandler.pack(extras)
        args = (len(members),
         len(vehs),
         len(players),
         len(extrasStr),
         self._readyMask,
         self._flags,
         self._closedSlotMask,
         self._modalTimestamp,
         self._gameplaysMask)
        packed += struct.pack(self._HEADER, *args)
        for accountDBID, veh in vehs.iteritems():
            packed += struct.pack(self._PLAYER_VEHICLES, accountDBID, veh['vehInvID'], veh['vehTypeCompDescr'])

        for slotIdx, member in members.iteritems():
            packed += struct.pack(self._SLOT_PLAYERS, slotIdx, member['accountDBID'])

        for accountDBID, playerData in players.iteritems():
            packed += struct.pack(self._PLAYER_DATA, accountDBID, playerData.get('accountID', 0), playerData.get('timeJoin', 0), playerData.get('role', 0), playerData.get('igrType', 0), playerData.get('rating', 0), playerData.get('peripheryID', 0))
            packed += packPascalString(playerData.get('nickName', ''))
            packed += packPascalString(playerData.get('clanAbbrev', ''))

        packed += extrasStr
        packed += packPascalString(self._strComment)
        self._packed = packed
        self._dirty = 0
        return packed
Example #3
0
 def _addPlayer(self, accountDBID, **kwargs):
     self._players[accountDBID] = kwargs
     self._dirty = 1
     packed = struct.pack(self._PLAYER_DATA, accountDBID, kwargs.get('accountID', 0), kwargs.get('timeJoin', 0), kwargs.get('role', 0), kwargs.get('igrType', 0), kwargs.get('rating', 0), kwargs.get('peripheryID', 0))
     packed += packPascalString(kwargs.get('nickName', ''))
     packed += packPascalString(kwargs.get('clanAbbrev', ''))
     self._appendOp(UNIT_OP.ADD_PLAYER, packed)
Example #4
0
 def __packPlayerData(self, accountDBID, **kwargs):
     packed = struct.pack(self._PLAYER_DATA, accountDBID, kwargs.get('accountID', 0), kwargs.get('timeJoin', 0), kwargs.get('role', 0), kwargs.get('igrType', 0), kwargs.get('rating', 0), kwargs.get('peripheryID', 0), kwargs.get('clanDBID', 0))
     packed += packPascalString(kwargs.get('nickName', ''))
     packed += packPascalString(kwargs.get('clanAbbrev', ''))
     badges = kwargs.get('badges', [])
     packed += struct.pack('<B', len(badges))
     if badges:
         packed += struct.pack(('<%dI' % len(badges)), *badges)
     return packed
Example #5
0
 def __packPlayerData(self, accountDBID, **kwargs):
     packed = struct.pack(self._PLAYER_DATA, accountDBID,
                          kwargs.get('accountID', 0),
                          kwargs.get('timeJoin', 0), kwargs.get('role', 0),
                          kwargs.get('igrType', 0), kwargs.get('rating', 0),
                          kwargs.get('peripheryID', 0),
                          kwargs.get('clanDBID', 0),
                          kwargs.get('isPremium', False))
     packed += packPascalString(kwargs.get('nickName', ''))
     packed += packPascalString(kwargs.get('clanAbbrev', ''))
     badges = kwargs.get('badges', BadgesCommon.selectedBadgesEmpty())
     packed += BadgesCommon.packPlayerBadges(badges)
     return packed
    def pack(self, isForced = False):
        if not self._dirty and not isForced:
            return self._packed
        self._dirty = False
        if self.battles:
            packed = struct.pack(self.FORMAT_HEADER, len(self.battles), len(self.battleUnits))
            fmt = self.FORMAT_ADD_BATTLE_HEADER
            for battleID, data in self.battles.iteritems():
                peripheryID = data['peripheryID']
                createTime = data['createTime']
                startTime = data['startTime']
                isFinished = data['isFinished']
                localizedData = packPascalString(cPickle.dumps(data['localizedData'], -1))
                packed += struct.pack(fmt, battleID, peripheryID, createTime, startTime, isFinished)
                packed += localizedData

            fmt = self.FORMAT_ADD_BATTLE_UNIT_HEADER
            for battleID, unitStr in self.battleUnits.iteritems():
                packed += struct.pack(fmt, battleID, len(unitStr))
                packed += unitStr

            self._packed = packed
        else:
            self._empty()
        self._persist()
        return self._packed
Example #7
0
    def pack(self):
        packed = struct.pack(self._IDS, self._rosterTypeID,
                             self._extrasHandlerID, self._prebattleTypeID)
        packed += self._roster.getPacked()
        members = self._members
        players = self._players
        vehs = self._vehicles
        extras = self._extras
        extrasStr = self._extrasHandler.pack(extras)
        args = (len(members), len(vehs), len(players), len(extrasStr),
                self._readyMask, self._flags, self._closedSlotMask,
                self._modalTimestamp, self._gameplaysMask, self._arenaType)
        packed += struct.pack(self._HEADER, *args)
        for accountDBID, vehList in vehs.iteritems():
            packed += struct.pack(self._PLAYER_VEHICLES_LIST, accountDBID,
                                  len(vehList))
            for vehTuple in vehList:
                packed += struct.pack(self._PLAYER_VEHICLE_TUPLE,
                                      vehTuple.vehInvID,
                                      vehTuple.vehTypeCompDescr)

        for slotIdx, member in members.iteritems():
            packed += struct.pack(self._SLOT_PLAYERS, slotIdx,
                                  member['accountDBID'])

        for accountDBID, playerData in players.iteritems():
            packed += self.__packPlayerData(accountDBID, **playerData)

        packed += extrasStr
        packed += packPascalString(self._strComment)
        self._packed = packed
        self._dirty = 0
        return packed
Example #8
0
    def pack(self, isForced = False):
        if not self._dirty and not isForced:
            return self._packed
        self._dirty = False
        if self.battles:
            packed = struct.pack(self.FORMAT_HEADER, len(self.battles), len(self.battleUnits))
            fmt = self.FORMAT_ADD_BATTLE_HEADER
            for battleID, data in self.battles.iteritems():
                peripheryID = data['peripheryID']
                createTime = data['createTime']
                startTime = data['startTime']
                isFinished = data['isFinished']
                localizedData = packPascalString(cPickle.dumps(data['localizedData'], -1))
                packed += struct.pack(fmt, battleID, peripheryID, createTime, startTime, isFinished)
                packed += localizedData

            fmt = self.FORMAT_ADD_BATTLE_UNIT_HEADER
            for battleID, unitStr in self.battleUnits.iteritems():
                packed += struct.pack(fmt, battleID, len(unitStr))
                packed += unitStr

            self._packed = packed
        else:
            self._empty()
        self._persist()
        return self._packed
Example #9
0
 def _addPlayer(self, accountDBID, **kwargs):
     self._players[accountDBID] = kwargs
     self._dirty = 1
     packed = struct.pack(
         self._PLAYER_DATA,
         accountDBID,
         kwargs.get("accountID", 0),
         kwargs.get("timeJoin", 0),
         kwargs.get("role", 0),
         kwargs.get("igrType", 0),
         kwargs.get("rating", 0),
         kwargs.get("peripheryID", 0),
     )
     packed += packPascalString(kwargs.get("nickName", ""))
     packed += packPascalString(kwargs.get("clanAbbrev", ""))
     self._appendOp(UNIT_OP.ADD_PLAYER, packed)
Example #10
0
 def _addBattle(self, battleID, peripheryID, createTime, startTime, localizedData):
     self.battles[battleID] = {'peripheryID': peripheryID,
      'createTime': createTime,
      'startTime': startTime,
      'isFinished': False,
      'localizedData': localizedData}
     packedData = struct.pack(self.FORMAT_ADD_BATTLE_HEADER, battleID, peripheryID, createTime, startTime, False)
     packedData += packPascalString(cPickle.dumps(localizedData, -1))
     self._appendOp(GM_OP.UNPACK_BATTLE, packedData)
Example #11
0
 def _addBattle(self, battleID, peripheryID, createTime, startTime, localizedData):
     self.battles[battleID] = {'peripheryID': peripheryID,
      'createTime': createTime,
      'startTime': startTime,
      'isFinished': False,
      'localizedData': localizedData}
     packedData = struct.pack(self.FORMAT_ADD_BATTLE_HEADER, battleID, peripheryID, createTime, startTime, False)
     packedData += packPascalString(cPickle.dumps(localizedData, -1))
     self._appendOp(GM_OP.UNPACK_BATTLE, packedData)
Example #12
0
    def pack(self):
        packed = struct.pack(self._IDS, self._rosterTypeID,
                             self._extrasHandlerID, self._prebattleTypeID)
        packed += self._roster.getPacked()
        members = self._members
        players = self._players
        vehs = self._vehicles
        extras = self._extras
        extrasStr = self._extrasHandler.pack(extras)
        args = (len(members), len(vehs), len(players), len(extrasStr),
                self._readyMask, self._flags, self._closedSlotMask,
                self._modalTimestamp, self._gameplaysMask)
        packed += struct.pack(self._HEADER, *args)
        for accountDBID, vehList in vehs.iteritems():
            packed += struct.pack(self._PLAYER_VEHICLES_LIST, accountDBID,
                                  len(vehList))
            for vehTuple in vehList:
                packed += struct.pack(self._PLAYER_VEHICLE_TUPLE,
                                      vehTuple.vehInvID,
                                      vehTuple.vehTypeCompDescr)

        for slotIdx, member in members.iteritems():
            packed += struct.pack(self._SLOT_PLAYERS, slotIdx,
                                  member['accountDBID'])

        for accountDBID, playerData in players.iteritems():
            packed += struct.pack(self._PLAYER_DATA, accountDBID,
                                  playerData.get('accountID', 0),
                                  playerData.get('timeJoin', 0),
                                  playerData.get('role', 0),
                                  playerData.get('igrType', 0),
                                  playerData.get('rating', 0),
                                  playerData.get('peripheryID', 0))
            packed += packPascalString(playerData.get('nickName', ''))
            packed += packPascalString(playerData.get('clanAbbrev', ''))

        packed += extrasStr
        packed += packPascalString(self._strComment)
        self._packed = packed
        self._dirty = 0
        return packed
Example #13
0
    def pack(self):
        packed = struct.pack('<B', self._rosterTypeID)
        packed += self._roster.getPacked()
        members = self._members
        players = self._players
        vehs = self._vehicles
        packed += struct.pack('<HHHHBBi', len(members), len(vehs), len(players), self._readyMask, self._state, self._closedSlotMask, self._modalTimestamp)
        for (playerID, veh,) in vehs.iteritems():
            packed += struct.pack('<qiH', playerID, veh['vehInvID'], veh['vehTypeCompDescr'])

        for (slotIdx, member,) in members.iteritems():
            packed += struct.pack('<Bq', slotIdx, member['playerID'])

        for (playerID, playerData,) in players.iteritems():
            packed += struct.pack('<qiIBBHH', playerID, playerData.get('accountID', 0), playerData.get('timeJoin', 0), playerData.get('role', 0), playerData.get('igrType', 0), playerData.get('rating', 0), playerData.get('peripheryID', 0))
            packed += packPascalString(playerData.get('nickName', ''))
            packed += packPascalString(playerData.get('clanAbbrev', ''))

        packed += packPascalString(self._strComment)
        self._packed = packed
        self._dirty = 0
        return packed