def enterSetAvatar(self):
        channel = self.csm.GetAccountConnectionChannel(self.target)

        # First, give them a POSTREMOVE to unload the avatar, just in case they
        # disconnect while we're working.
        dgcleanup = PyDatagram()
        dgcleanup.addServerHeader(self.avId, channel, STATESERVER_OBJECT_DELETE_RAM)
        dgcleanup.addUint32(self.avId)
        dg = PyDatagram()
        dg.addServerHeader(channel, self.csm.air.ourChannel, CLIENTAGENT_ADD_POST_REMOVE)
        dg.addString(dgcleanup.getMessage())
        self.csm.air.send(dg)

        # Get the avatar's "true" access. (without "server" bit)
        adminAccess = self.account.get('ADMIN_ACCESS', 0)
        adminAccess = adminAccess - adminAccess % 100

        # Activate the avatar on the DBSS:
        self.csm.air.sendActivate(self.avId, 0, 0,
                                  self.csm.air.dclassesByName['DistributedToonUD'],
                                  {'setAdminAccess': [self.account.get('ADMIN_ACCESS', 0)]})


        # Next, add them to the avatar channel:
        dg = PyDatagram()
        dg.addServerHeader(channel, self.csm.air.ourChannel, CLIENTAGENT_OPEN_CHANNEL)
        dg.addChannel(self.csm.GetPuppetConnectionChannel(self.avId))
        self.csm.air.send(dg)

        # Now set their sender channel to represent their account affiliation:
        dg = PyDatagram()
        dg.addServerHeader(channel, self.csm.air.ourChannel, CLIENTAGENT_SET_CLIENT_ID)
        dg.addChannel(self.target<<32 | self.avId) # accountId in high 32 bits, avatar in low
        self.csm.air.send(dg)

        # Finally, grant ownership and shut down.
        dg = PyDatagram()
        dg.addServerHeader(self.avId, self.csm.air.ourChannel, STATESERVER_OBJECT_SET_OWNER)
        dg.addChannel(self.csm.GetAccountConnectionChannel(self.target)) # Set ownership channel to the connection's account channel.
        self.csm.air.send(dg)

        # Tell the GlobalPartyManager as well:
        self.csm.air.globalPartyMgr.avatarJoined(self.avId)

        # Tell everything that an avatar is coming online!
        friendsList = [x for x, y in self.avatar['setFriendsList'][0]]
        self.csm.air.netMessenger.send('avatarOnline', [self.avId, friendsList])

        # Post-remove for an avatar that disconnects unexpectedly.
        dgcleanup = self.csm.air.netMessenger.prepare('avatarOffline', [self.avId])
        dg = PyDatagram()
        dg.addServerHeader(channel, self.csm.air.ourChannel, CLIENTAGENT_ADD_POST_REMOVE)
        dg.addString(dgcleanup.getMessage())
        self.csm.air.send(dg)

        self.csm.air.writeServerEvent('avatar-chosen', avId=self.avId, accId=self.target)
        self.demand('Off')
Exemplo n.º 2
0
 def enterSetAvatar(self):
     channel = self.csm.GetAccountConnectionChannel(self.target)
     datagramCleanup = PyDatagram()
     datagramCleanup.addServerHeader(self.avId, channel,
                                     STATESERVER_OBJECT_DELETE_RAM)
     datagramCleanup.addUint32(self.avId)
     datagram = PyDatagram()
     datagram.addServerHeader(channel, self.csm.air.ourChannel,
                              CLIENTAGENT_ADD_POST_REMOVE)
     datagram.addString(datagramCleanup.getMessage())
     self.csm.air.send(datagram)
     self.csm.air.sendActivate(
         self.avId, 0, 0, self.csm.air.dclassesByName['DistributedToonUD'],
         {'setAdminAccess': [self.account.get('ACCESS_LEVEL', 100)]})
     datagram = PyDatagram()
     datagram.addServerHeader(channel, self.csm.air.ourChannel,
                              CLIENTAGENT_OPEN_CHANNEL)
     datagram.addChannel(self.csm.GetPuppetConnectionChannel(self.avId))
     self.csm.air.send(datagram)
     datagram = PyDatagram()
     datagram.addServerHeader(channel, self.csm.air.ourChannel,
                              CLIENTAGENT_SET_CLIENT_ID)
     datagram.addChannel(self.target << 32 | self.avId)
     self.csm.air.send(datagram)
     taskMgr.doMethodLater(0.2,
                           self.enterSetAvatarTask,
                           'avatarTask-%s' % self.avId,
                           extraArgs=[channel],
                           appendTask=True)
    def enterSetAvatar(self):
        channel = self.csm.GetAccountConnectionChannel(self.target)

        # First, give them a POSTREMOVE to unload the avatar, just in case they
        # disconnect while we're working.
        datagramCleanup = PyDatagram()
        datagramCleanup.addServerHeader(self.avId, channel, STATESERVER_OBJECT_DELETE_RAM)
        datagramCleanup.addUint32(self.avId)
        datagram = PyDatagram()
        datagram.addServerHeader( channel, self.csm.air.ourChannel, CLIENTAGENT_ADD_POST_REMOVE)
        datagram.addString(datagramCleanup.getMessage())
        self.csm.air.send(datagram)

        # Activate the avatar on the DBSS:
        self.csm.air.sendActivate(self.avId, 0, 0, self.csm.air.dclassesByName['DistributedToonUD'], {'setAdminAccess': \
            [self.account.get('ACCESS_LEVEL', 100)]})

        # Next, add them to the avatar channel:
        datagram = PyDatagram()
        datagram.addServerHeader(channel, self.csm.air.ourChannel, CLIENTAGENT_OPEN_CHANNEL)
        datagram.addChannel(self.csm.GetPuppetConnectionChannel(self.avId))
        self.csm.air.send(datagram)

        # Now set their sender channel to represent their account affiliation:
        datagram = PyDatagram()
        datagram.addServerHeader( channel, self.csm.air.ourChannel, CLIENTAGENT_SET_CLIENT_ID)
        datagram.addChannel(self.target<<32 | self.avId)
        self.csm.air.send(datagram)

        # Eliminate race conditions.
        taskMgr.doMethodLater(0.2, self.enterSetAvatarTask, 'avatarTask-%s' % (self.avId), extraArgs=[channel],
            appendTask=True)
Exemplo n.º 4
0
    def __handleSetAvatar(self):
        channel = self.loginManager.GetAccountConnectionChannel(self.sender)

        cleanupDatagram = PyDatagram()
        cleanupDatagram.addServerHeader(self.avId, channel, STATESERVER_OBJECT_DELETE_RAM)
        cleanupDatagram.addUint32(self.avId)
        datagram = PyDatagram()
        datagram.addServerHeader(channel, self.loginManager.air.ourChannel, CLIENTAGENT_ADD_POST_REMOVE)
        datagram.addString(cleanupDatagram.getMessage())
        self.loginManager.air.send(datagram)

        self.loginManager.air.sendActivate(self.avId, 0, 0, self.loginManager.air.dclassesByName['DistributedToonUD'])

        datagram = PyDatagram()
        datagram.addServerHeader(channel, self.loginManager.air.ourChannel, CLIENTAGENT_OPEN_CHANNEL)
        datagram.addChannel(self.loginManager.GetPuppetConnectionChannel(self.avId))
        self.loginManager.air.send(datagram)

        self.loginManager.air.clientAddSessionObject(channel, self.avId)

        datagram = PyDatagram()
        datagram.addServerHeader(channel, self.loginManager.air.ourChannel, CLIENTAGENT_SET_CLIENT_ID)
        datagram.addChannel(self.sender << 32 | self.avId)  # accountId in high 32 bits, avatar in low.
        self.loginManager.air.send(datagram)

        self.loginManager.air.setOwner(self.avId, channel)

        self._handleDone()
    def enterSetAvatar(self):
        channel = self.csm.GetAccountConnectionChannel(self.target)

        # First, give them a POSTREMOVE to unload the avatar, just in case they
        # disconnect while we're working.
        datagramCleanup = PyDatagram()
        datagramCleanup.addServerHeader(
            self.avId,
            channel,
            STATESERVER_OBJECT_DELETE_RAM)
        datagramCleanup.addUint32(self.avId)
        datagram = PyDatagram()
        datagram.addServerHeader(
            channel,
            self.csm.air.ourChannel,
            CLIENTAGENT_ADD_POST_REMOVE)
        datagram.addString(datagramCleanup.getMessage())
        self.csm.air.send(datagram)

        # Activate the avatar on the DBSS:
        self.csm.air.sendActivate(
            self.avId, 0, 0, self.csm.air.dclassesByName['DistributedToonUD'],
            {'setAdminAccess': [self.account.get('ACCESS_LEVEL', 100)]})

        # Next, add them to the avatar channel:
        datagram = PyDatagram()
        datagram.addServerHeader(
            channel,
            self.csm.air.ourChannel,
            CLIENTAGENT_OPEN_CHANNEL)
        datagram.addChannel(self.csm.GetPuppetConnectionChannel(self.avId))
        self.csm.air.send(datagram)

        # Now set their sender channel to represent their account affiliation:
        datagram = PyDatagram()
        datagram.addServerHeader(
            channel,
            self.csm.air.ourChannel,
            CLIENTAGENT_SET_CLIENT_ID)
        datagram.addChannel(self.target<<32 | self.avId)
        self.csm.air.send(datagram)

        # Finally, grant ownership and shut down.
        datagram = PyDatagram()
        datagram.addServerHeader(
            self.avId,
            self.csm.air.ourChannel,
            STATESERVER_OBJECT_SET_OWNER)
        datagram.addChannel(self.target<<32 | self.avId)
        self.csm.air.send(datagram)

        # Tell TTRFriendsManager somebody is logging in:
        self.csm.air.friendsManager.toonOnline(self.avId, self.avatar)

        # Tell the GlobalPartyManager as well:
        self.csm.air.globalPartyMgr.avatarJoined(self.avId)

        self.csm.air.writeServerEvent('avatarChosen', self.avId, self.target)
        self.demand('Off')
    def doUpdate(self, updateType, data):
        self.heartbeat()

        if updateType == "inv":
            return  # rip crash

        dg = PyDatagram()
        dg.addUint8(0)
        dg.addString(updateType)
        dg.appendData(data)
        self.setShardData(dg.getMessage())
    def doUpdate(self, updateType, data):
        self.heartbeat()

        if updateType == "inv":
            return  # rip crash

        dg = PyDatagram()
        dg.addUint8(0)
        dg.addString(updateType)
        dg.appendData(data)
        self.setShardData(dg.getMessage())
Exemplo n.º 8
0
def packGardenData(plants, statuary, started=True):
    dg = PyDatagram()
    for plant in plants:
        a, b, c, d, e = plant
        dg.addUint32(a)
        dg.addInt8(b)
        dg.addUint32(c)
        dg.addInt8(d)
        dg.addUint16(e)

    dg.addUint8(statuary)
    dg.addBool(started)
    return dg.getMessage()
def packGardenData(plants, statuary, started = True):
    dg = PyDatagram()
    for plant in plants:
        a, b, c, d, e = plant
        dg.addUint32(a)
        dg.addInt8(b)
        dg.addUint32(c)
        dg.addInt8(d)
        dg.addUint16(e)

    dg.addUint8(statuary)
    dg.addBool(started)
    return dg.getMessage()
Exemplo n.º 10
0
    def enterSetAvatar(self):
        channel = self.csm.GetAccountConnectionChannel(self.target)

        # First, give them a POSTREMOVE to unload the avatar, just in case they
        # disconnect while we're working.
        dgcleanup = PyDatagram()
        dgcleanup.addServerHeader(self.avId, channel,
                                  STATESERVER_OBJECT_DELETE_RAM)
        dgcleanup.addUint32(self.avId)
        dg = PyDatagram()
        dg.addServerHeader(channel, self.csm.air.ourChannel,
                           CLIENTAGENT_ADD_POST_REMOVE)
        dg.addString(dgcleanup.getMessage())
        self.csm.air.send(dg)

        # Activate the avatar on the DBSS:
        self.csm.air.sendActivate(
            self.avId, 0, 0, self.csm.air.dclassesByName['DistributedToonUD'],
            {'setAdminAccess': [self.account.get('ADMIN_ACCESS', 0)]})

        # Next, add them to the avatar channel:
        dg = PyDatagram()
        dg.addServerHeader(channel, self.csm.air.ourChannel,
                           CLIENTAGENT_OPEN_CHANNEL)
        dg.addChannel(self.csm.GetPuppetConnectionChannel(self.avId))
        self.csm.air.send(dg)

        # Now set their sender channel to represent their account affiliation:
        dg = PyDatagram()
        dg.addServerHeader(channel, self.csm.air.ourChannel,
                           CLIENTAGENT_SET_CLIENT_ID)
        dg.addChannel(self.target << 32
                      | self.avId)  # accountId in high 32 bits, avatar in low
        self.csm.air.send(dg)

        # Finally, grant ownership and shut down.
        dg = PyDatagram()
        dg.addServerHeader(self.avId, self.csm.air.ourChannel,
                           STATESERVER_OBJECT_SET_OWNER)
        dg.addChannel(self.target << 32
                      | self.avId)  # accountId in high 32 bits, avatar in low
        self.csm.air.send(dg)

        # Tell TTRFriendsManager somebody is logging in:
        self.csm.air.friendsManager.toonOnline(self.avId, self.avatar)

        # Tell the GlobalPartyManager as well
        self.csm.air.globalPartyMgr.avatarJoined(self.avId)

        self.csm.air.writeServerEvent('avatarChosen', self.avId, self.target)
        self.demand('Off')
    def enterSetAvatar(self):
        channel = self.csm.GetAccountConnectionChannel(self.target)

        # First, give them a POSTREMOVE to unload the avatar, just in case they
        # disconnect while we're working.
        datagramCleanup = PyDatagram()
        datagramCleanup.addServerHeader(
            self.avId,
            channel,
            STATESERVER_OBJECT_DELETE_RAM)
        datagramCleanup.addUint32(self.avId)
        datagram = PyDatagram()
        datagram.addServerHeader(
            channel,
            self.csm.air.ourChannel,
            CLIENTAGENT_ADD_POST_REMOVE)
        datagram.addString(datagramCleanup.getMessage())
        self.csm.air.send(datagram)

        # Activate the avatar on the DBSS:
        self.csm.air.sendActivate(
            self.avId, 0, 0, self.csm.air.dclassesByName['DistributedToonUD'],
            {'setAdminAccess': [self.account.get('ACCESS_LEVEL', 100)],
             'setBankMoney': [self.account.get('MONEY', 0)]})

        # Next, add them to the avatar channel:
        datagram = PyDatagram()
        datagram.addServerHeader(
            channel,
            self.csm.air.ourChannel,
            CLIENTAGENT_OPEN_CHANNEL)
        datagram.addChannel(self.csm.GetPuppetConnectionChannel(self.avId))
        self.csm.air.send(datagram)

        # Now set their sender channel to represent their account affiliation:
        datagram = PyDatagram()
        datagram.addServerHeader(
            channel,
            self.csm.air.ourChannel,
            CLIENTAGENT_SET_CLIENT_ID)
        datagram.addChannel(self.target<<32 | self.avId)
        self.csm.air.send(datagram)

        # Eliminate race conditions.
        taskMgr.doMethodLater(0.2, self.enterSetAvatarTask,
                              'avatarTask-%s' % self.avId, extraArgs=[channel],
                              appendTask=True)
Exemplo n.º 12
0
 def enterSetAvatar(self):
     channel = self.csm.GetAccountConnectionChannel(self.target)
     dgcleanup = PyDatagram()
     dgcleanup.addServerHeader(self.avId, channel,
                               STATESERVER_OBJECT_DELETE_RAM)
     dgcleanup.addUint32(self.avId)
     dg = PyDatagram()
     dg.addServerHeader(channel, self.csm.air.ourChannel,
                        CLIENTAGENT_ADD_POST_REMOVE)
     dg.addString(dgcleanup.getMessage())
     self.csm.air.send(dg)
     adminAccess = self.account.get('ADMIN_ACCESS', 0)
     adminAccess = adminAccess - adminAccess % 100
     self.csm.air.sendActivate(
         self.avId, 0, 0, self.csm.air.dclassesByName['DistributedToonUD'],
         {'setAdminAccess': [self.account.get('ADMIN_ACCESS', 0)]})
     dg = PyDatagram()
     dg.addServerHeader(channel, self.csm.air.ourChannel,
                        CLIENTAGENT_OPEN_CHANNEL)
     dg.addChannel(self.csm.GetPuppetConnectionChannel(self.avId))
     self.csm.air.send(dg)
     dg = PyDatagram()
     dg.addServerHeader(channel, self.csm.air.ourChannel,
                        CLIENTAGENT_ADD_SESSION_OBJECT)
     dg.addUint32(self.avId)
     self.csm.air.send(dg)
     dg = PyDatagram()
     dg.addServerHeader(channel, self.csm.air.ourChannel,
                        CLIENTAGENT_SET_CLIENT_ID)
     dg.addChannel(self.target << 32 | self.avId)
     self.csm.air.send(dg)
     dg = PyDatagram()
     dg.addServerHeader(self.avId, self.csm.air.ourChannel,
                        STATESERVER_OBJECT_SET_OWNER)
     dg.addChannel(self.csm.GetAccountConnectionChannel(self.target))
     self.csm.air.send(dg)
     fields = self.avatar
     fields.update(
         {'setAdminAccess': [self.account.get('ADMIN_ACCESS', 0)]})
     self.csm.air.friendsManager.toonOnline(self.avId, fields)
     self.csm.air.globalPartyMgr.avatarJoined(self.avId)
     self.csm.air.writeServerEvent('avatar-chosen',
                                   avId=self.avId,
                                   accId=self.target)
     self.demand('Off')
Exemplo n.º 13
0
    def enterSetAvatar(self):
        channel = self.csm.GetAccountConnectionChannel(self.target)

        # First, give them a POSTREMOVE to unload the avatar, just in case they
        # disconnect while we're working.
        datagramCleanup = PyDatagram()
        datagramCleanup.addServerHeader(
            self.avId,
            channel,
            STATESERVER_OBJECT_DELETE_RAM)

        datagramCleanup.addUint32(self.avId)
        datagram = PyDatagram()
        datagram.addServerHeader(
            channel,
            self.csm.air.ourChannel,
            CLIENTAGENT_ADD_POST_REMOVE)
        datagram.addString(datagramCleanup.getMessage())
        self.csm.air.send(datagram)

        # setup the avatar's inventory.
        self.csm.air.inventoryManager.initiateInventory(self.avId, self.inventorySetup)
Exemplo n.º 14
0
    def d_setShardData(self):
        dg = PyDatagram()

        self.context += 1
        self.context %= 200
        dg.addUint8(self.context)

        buildings = self.air.doFindAllInstances(
            DistributedBuildingAI.DistributedBuildingAI)
        for bldg in buildings:
            if bldg.__class__ in (
                    DistributedBuildingAI.DistributedBuildingAI,
                    DistributedAnimBuildingAI.DistributedAnimBuildingAI):
                if not bldg.zoneId % 1000:
                    # sz bldg, ignore
                    continue

                if bldg.zoneId // 1000 == 7:
                    # ff bldg, ignore now
                    continue

                data = bldg.getPickleData()

                dg.addString("block")
                dg.addUint16(bldg.zoneId - (bldg.zoneId % 1000))
                dg.addUint16(bldg.zoneId)
                dg.addUint8(int(data['block']))
                dg.addString(data['state'].lower())
                dg.addUint8(ord(data['track']))
                dg.addUint8(int(data['difficulty']))
                dg.addInt8(int(data['numFloors']))

                self.bldgs.add(bldg)

        self.writeInvasion(dg)
        self.sendUpdate("setShardData", [dg.getMessage()])

        self.air.notify.info("Sent shard data to UD")
        taskMgr.doMethodLater(60, self.__timeout, 'UD-sync-timeout')
Exemplo n.º 15
0
    def d_updateBlock(self, bldg):
        if not bldg in self.bldgs:
            return

        data = bldg.getPickleData()

        dg = PyDatagram()
        dg.addUint16(bldg.zoneId - (bldg.zoneId % 1000))
        dg.addUint16(bldg.zoneId)
        dg.addUint8(int(data['block']))

        state = data['state'].lower()

        if state.startswith('clear'):
            state = 'cogdo' if state.endswith('cogdo') else 'suit'

        dg.addString(state)

        dg.addUint8(ord(data['track']))
        dg.addUint8(int(data['difficulty']))
        dg.addInt8(int(data['numFloors']))

        self.sendUpdate("doUpdate", ["block", dg.getMessage()])
 def d_updateBlock(self, bldg):
     if not bldg in self.bldgs:
         return
         
     data = bldg.getPickleData()
     
     dg = PyDatagram()
     dg.addUint16(bldg.zoneId - (bldg.zoneId % 1000))
     dg.addUint16(bldg.zoneId)
     dg.addUint8(int(data['block']))
     
     state = data['state'].lower()
     
     if state.startswith('clear'):
         state = 'cogdo' if state.endswith('cogdo') else 'suit'
         
     dg.addString(state)
     
     dg.addUint8(ord(data['track']))
     dg.addUint8(int(data['difficulty']))
     dg.addInt8(int(data['numFloors']))
     
     self.sendUpdate("doUpdate", ["block", dg.getMessage()])
    def d_setShardData(self):
        dg = PyDatagram()
        
        self.context += 1
        self.context %= 200
        dg.addUint8(self.context)
        
        buildings = self.air.doFindAllInstances(DistributedBuildingAI.DistributedBuildingAI)
        for bldg in buildings:
            if bldg.__class__ in (DistributedBuildingAI.DistributedBuildingAI, DistributedAnimBuildingAI.DistributedAnimBuildingAI):
                if not bldg.zoneId % 1000:
                    # sz bldg, ignore
                    continue
                    
                if bldg.zoneId // 1000 == 7:
                    # ff bldg, ignore now
                    continue
                    
                data = bldg.getPickleData()

                dg.addString("block")
                dg.addUint16(bldg.zoneId - (bldg.zoneId % 1000))
                dg.addUint16(bldg.zoneId)
                dg.addUint8(int(data['block']))
                dg.addString(data['state'].lower())
                dg.addUint8(ord(data['track']))
                dg.addUint8(int(data['difficulty']))
                dg.addInt8(int(data['numFloors']))
                
                self.bldgs.add(bldg)
                    
        self.writeInvasion(dg)                    
        self.sendUpdate("setShardData", [dg.getMessage()])
                            
        self.air.notify.info("Sent shard data to UD")
        taskMgr.doMethodLater(60, self.__timeout, 'UD-sync-timeout')
Exemplo n.º 18
0
 def enterSetAvatar(self):
     channel = self.gameServicesManager.GetAccountConnectionChannel(
         self.target)
     cleanupDatagram = PyDatagram()
     cleanupDatagram.addServerHeader(self.avId, channel,
                                     STATESERVER_OBJECT_DELETE_RAM)
     cleanupDatagram.addUint32(self.avId)
     datagram = PyDatagram()
     datagram.addServerHeader(channel,
                              self.gameServicesManager.air.ourChannel,
                              CLIENTAGENT_ADD_POST_REMOVE)
     datagram.addString(cleanupDatagram.getMessage())
     self.gameServicesManager.air.send(datagram)
     creationDate = self.getCreationDate()
     accountDays = -1
     if creationDate:
         now = datetime.fromtimestamp(
             time.mktime(time.strptime(time.ctime())))
         accountDays = abs((now - creationDate).days)
     if accountDays < 0 or accountDays > 4294967295L:
         accountDays = 100000
     self.gameServicesManager.sendUpdateToAccountId(self.target,
                                                    'receiveAccountDays',
                                                    [accountDays])
     accessLevel = self.account.get('ACCESS_LEVEL', 'NO_ACCESS')
     accessLevel = OTPGlobals.AccessLevelName2Int.get(accessLevel, 0)
     self.gameServicesManager.air.sendActivate(
         self.avId, 0, 0, self.gameServicesManager.air.dclassesByName[
             self.gameServicesManager.avatarDclass],
         {'setAccessLevel': [accessLevel]})
     datagram = PyDatagram()
     datagram.addServerHeader(channel,
                              self.gameServicesManager.air.ourChannel,
                              CLIENTAGENT_OPEN_CHANNEL)
     datagram.addChannel(
         self.gameServicesManager.GetPuppetConnectionChannel(self.avId))
     self.gameServicesManager.air.send(datagram)
     self.gameServicesManager.air.clientAddSessionObject(channel, self.avId)
     datagram = PyDatagram()
     datagram.addServerHeader(channel,
                              self.gameServicesManager.air.ourChannel,
                              CLIENTAGENT_SET_CLIENT_ID)
     datagram.addChannel(self.target << 32 | self.avId)
     self.gameServicesManager.air.send(datagram)
     self.gameServicesManager.air.setOwner(self.avId, channel)
     friendsList = [x for x, y in self.avatar['setFriendsList'][0]]
     self.gameServicesManager.air.ttoffFriendsManager.comingOnline(
         self.avId, friendsList)
     if self.gameServicesManager.air.ttoffFriendsManager:
         friendsManagerDclass = self.gameServicesManager.air.ttoffFriendsManager.dclass
         cleanupDatagram = friendsManagerDclass.aiFormatUpdate(
             'goingOffline',
             self.gameServicesManager.air.ttoffFriendsManager.doId,
             self.gameServicesManager.air.ttoffFriendsManager.doId,
             self.gameServicesManager.air.ourChannel, [self.avId])
     else:
         friendsManagerDoId = OtpDoGlobals.OTP_DO_ID_TTOFF_FRIENDS_MANAGER
         friendsManagerDclass = self.gameServicesManager.air.dclassesByName[
             'TTOffFriendsManagerUD']
         cleanupDatagram = friendsManagerDclass.aiFormatUpdate(
             'goingOffline', friendsManagerDoId, friendsManagerDoId,
             self.gameServicesManager.air.ourChannel, [self.avId])
     datagram = PyDatagram()
     datagram.addServerHeader(channel,
                              self.gameServicesManager.air.ourChannel,
                              CLIENTAGENT_ADD_POST_REMOVE)
     datagram.addString(cleanupDatagram.getMessage())
     self.gameServicesManager.air.send(datagram)
     simbase.air.banManager.addClient(self.target, self.hwId)
     self.gameServicesManager.air.writeServerEvent('avatar-chosen',
                                                   avId=self.avId,
                                                   accId=self.target)
     self.demand('Off')
Exemplo n.º 19
0
    def enterSetAvatar(self):
        # Get the client channel.
        channel = self.gameServicesManager.GetAccountConnectionChannel(
            self.target)

        # We will first assign a POST_REMOVE that will unload the
        # avatar in the event of them disconnecting while we are working.
        cleanupDatagram = PyDatagram()
        cleanupDatagram.addServerHeader(self.avId, channel,
                                        STATESERVER_OBJECT_DELETE_RAM)
        cleanupDatagram.addUint32(self.avId)
        datagram = PyDatagram()
        datagram.addServerHeader(channel,
                                 self.gameServicesManager.air.ourChannel,
                                 CLIENTAGENT_ADD_POST_REMOVE)
        datagram.addString(cleanupDatagram.getMessage())
        self.gameServicesManager.air.send(datagram)

        # We will now set the account's days since creation on the client.
        creationDate = self.getCreationDate()
        accountDays = -1
        if creationDate:
            now = datetime.fromtimestamp(
                time.mktime(time.strptime(time.ctime())))
            accountDays = abs((now - creationDate).days)

        if accountDays < 0 or accountDays > 4294967295:
            accountDays = 100000

        self.gameServicesManager.sendUpdateToAccountId(self.target,
                                                       'receiveAccountDays',
                                                       [accountDays])

        # Get the avatar's "true" access (that is, the integer value that corresponds to the assigned string value).
        accessLevel = self.account.get('ACCESS_LEVEL', 'NO_ACCESS')
        accessLevel = OTPGlobals.accessLevelValues.get(accessLevel, 0)

        # We will now activate the avatar on the DBSS.
        self.gameServicesManager.air.sendActivate(
            self.avId, 0, 0, self.gameServicesManager.air.dclassesByName[
                self.gameServicesManager.avatarDclass],
            {'setAccessLevel': [accessLevel]})

        # Next, we will add them to the avatar channel.
        datagram = PyDatagram()
        datagram.addServerHeader(channel,
                                 self.gameServicesManager.air.ourChannel,
                                 CLIENTAGENT_OPEN_CHANNEL)
        datagram.addChannel(
            self.gameServicesManager.GetPuppetConnectionChannel(self.avId))
        self.gameServicesManager.air.send(datagram)

        # We will now set the avatar as the client's session object.
        self.gameServicesManager.air.clientAddSessionObject(channel, self.avId)

        # Now we need to set their sender channel to represent their account affiliation.
        datagram = PyDatagram()
        datagram.addServerHeader(channel,
                                 self.gameServicesManager.air.ourChannel,
                                 CLIENTAGENT_SET_CLIENT_ID)
        datagram.addChannel(
            self.target << 32
            | self.avId)  # accountId in high 32 bits, avatar in low.
        self.gameServicesManager.air.send(datagram)

        # We will now grant ownership.
        self.gameServicesManager.air.setOwner(self.avId, channel)

        # Tell the friends manager that an avatar is coming online.
        friendsList = [x for x, y in self.avatar['setFriendsList'][0]]
        self.gameServicesManager.air.ttoffFriendsManager.comingOnline(
            self.avId, friendsList)

        # Now we'll assign a POST_REMOVE that will tell the friends manager
        # that an avatar has gone offline, in the event that they disconnect
        # unexpectedly.
        if self.gameServicesManager.air.ttoffFriendsManager:
            friendsManagerDclass = self.gameServicesManager.air.ttoffFriendsManager.dclass
            cleanupDatagram = friendsManagerDclass.aiFormatUpdate(
                'goingOffline',
                self.gameServicesManager.air.ttoffFriendsManager.doId,
                self.gameServicesManager.air.ttoffFriendsManager.doId,
                self.gameServicesManager.air.ourChannel, [self.avId])
        else:
            friendsManagerDoId = OtpDoGlobals.OTP_DO_ID_TTOFF_FRIENDS_MANAGER
            friendsManagerDclass = self.gameServicesManager.air.dclassesByName[
                'TTOffFriendsManagerUD']
            cleanupDatagram = friendsManagerDclass.aiFormatUpdate(
                'goingOffline', friendsManagerDoId, friendsManagerDoId,
                self.gameServicesManager.air.ourChannel, [self.avId])

        datagram = PyDatagram()
        datagram.addServerHeader(channel,
                                 self.gameServicesManager.air.ourChannel,
                                 CLIENTAGENT_ADD_POST_REMOVE)
        datagram.addString(cleanupDatagram.getMessage())
        self.gameServicesManager.air.send(datagram)

        # We can now finally shut down this operation.
        self.gameServicesManager.air.writeServerEvent('avatar-chosen',
                                                      avId=self.avId,
                                                      accId=self.target)
        self.demand('Off')
 def d_updateInvasion(self):
     dg = PyDatagram()
     self.writeInvasion(dg)
     self.sendUpdate("doUpdate", ["inv", dg.getMessage()])
    def enterSetAvatar(self):
        channel = self.csm.GetAccountConnectionChannel(self.target)

        # First, give them a POSTREMOVE to unload the avatar, just in case they
        # disconnect while we're working.
        dgcleanup = PyDatagram()
        dgcleanup.addServerHeader(self.avId, channel,
                                  STATESERVER_OBJECT_DELETE_RAM)
        dgcleanup.addUint32(self.avId)
        dg = PyDatagram()
        dg.addServerHeader(channel, self.csm.air.ourChannel,
                           CLIENTAGENT_ADD_POST_REMOVE)
        dg.addString(dgcleanup.getMessage())
        self.csm.air.send(dg)

        # Get the avatar's "true" access. (without "server" bit)
        adminAccess = self.account.get('ADMIN_ACCESS', 0)
        adminAccess = adminAccess - adminAccess % 100

        # Activate the avatar on the DBSS:
        self.csm.air.sendActivate(
            self.avId, 0, 0, self.csm.air.dclassesByName['DistributedToonUD'],
            {'setAdminAccess': [self.account.get('ADMIN_ACCESS', 0)]})

        # Next, add them to the avatar channel:
        dg = PyDatagram()
        dg.addServerHeader(channel, self.csm.air.ourChannel,
                           CLIENTAGENT_OPEN_CHANNEL)
        dg.addChannel(self.csm.GetPuppetConnectionChannel(self.avId))
        self.csm.air.send(dg)

        # Now set their sender channel to represent their account affiliation:
        dg = PyDatagram()
        dg.addServerHeader(channel, self.csm.air.ourChannel,
                           CLIENTAGENT_SET_CLIENT_ID)
        dg.addChannel(self.target << 32
                      | self.avId)  # accountId in high 32 bits, avatar in low
        self.csm.air.send(dg)

        # Finally, grant ownership and shut down.
        dg = PyDatagram()
        dg.addServerHeader(self.avId, self.csm.air.ourChannel,
                           STATESERVER_OBJECT_SET_OWNER)
        dg.addChannel(
            self.csm.GetAccountConnectionChannel(self.target)
        )  # Set ownership channel to the connection's account channel.
        self.csm.air.send(dg)

        # Tell the GlobalPartyManager as well:
        self.csm.air.globalPartyMgr.avatarJoined(self.avId)

        # Tell everything that an avatar is coming online!
        friendsList = [x for x, y in self.avatar['setFriendsList'][0]]
        self.csm.air.netMessenger.send('avatarOnline',
                                       [self.avId, friendsList])

        # Post-remove for an avatar that disconnects unexpectedly.
        dgcleanup = self.csm.air.netMessenger.prepare('avatarOffline',
                                                      [self.avId])
        dg = PyDatagram()
        dg.addServerHeader(channel, self.csm.air.ourChannel,
                           CLIENTAGENT_ADD_POST_REMOVE)
        dg.addString(dgcleanup.getMessage())
        self.csm.air.send(dg)

        self.csm.air.writeServerEvent('avatar-chosen',
                                      avId=self.avId,
                                      accId=self.target)
        self.demand('Off')
Exemplo n.º 22
0
 def d_updateInvasion(self):
     dg = PyDatagram()
     self.writeInvasion(dg)
     self.sendUpdate("doUpdate", ["inv", dg.getMessage()])