Exemplo n.º 1
0
    def __handleUnloadAvatar(self):
        channel = self.loginManager.GetAccountConnectionChannel(self.sender)

        datagram = PyDatagram()
        datagram.addServerHeader(channel, self.loginManager.air.ourChannel,
                                 CLIENTAGENT_CLEAR_POST_REMOVES)
        self.loginManager.air.send(datagram)

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

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

        datagram = PyDatagram()
        datagram.addServerHeader(channel, self.loginManager.air.ourChannel,
                                 CLIENTAGENT_REMOVE_SESSION_OBJECT)
        datagram.addUint32(self.avId)
        self.loginManager.air.send(datagram)

        datagram = PyDatagram()
        datagram.addServerHeader(self.avId, channel,
                                 STATESERVER_OBJECT_DELETE_RAM)
        datagram.addUint32(self.avId)
        self.loginManager.air.send(datagram)

        self._handleDone()
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 enterSetAccount(self):
        # First, if there's anybody on the account, kill 'em for redundant login:
        dg = PyDatagram()
        dg.addServerHeader(self.csm.GetAccountConnectionChannel(int(self.databaseId)),
                           self.csm.air.ourChannel, CLIENTAGENT_EJECT)
        dg.addUint16(100)
        dg.addString('This account has been logged in elsewhere.')
        self.csm.air.send(dg)

        # Next, add this connection to the account channel.
        dg = PyDatagram()
        dg.addServerHeader(self.target, self.csm.air.ourChannel, CLIENTAGENT_OPEN_CHANNEL)
        dg.addChannel(self.csm.GetAccountConnectionChannel(self.databaseId))
        self.csm.air.send(dg)

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

        # Un-sandbox them!
        dg = PyDatagram()
        dg.addServerHeader(self.target, self.csm.air.ourChannel, CLIENTAGENT_SET_STATE)
        dg.addUint16(2) # ESTABLISHED state. BIG FAT SECURITY RISK!!!
        self.csm.air.send(dg)

        # We're done.
        self.csm.sendUpdateToChannel(self.target, 'acceptLogin', [])
        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)]})

        # 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.º 5
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 enterUnloadAvatar(self):
        channel = self.csm.GetAccountConnectionChannel(self.target)

        self.csm.air.friendsManager.toonOffline(self.avId)

        # Clear off POSTREMOVE:
        datagram = PyDatagram()
        datagram.addServerHeader(channel, self.csm.air.ourChannel, CLIENTAGENT_CLEAR_POST_REMOVES)
        self.csm.air.send(datagram)

        # Remove avatar channel:
        datagram = PyDatagram()
        datagram.addServerHeader(channel, self.csm.air.ourChannel, CLIENTAGENT_CLOSE_CHANNEL)
        datagram.addChannel(self.csm.GetPuppetConnectionChannel(self.avId))
        self.csm.air.send(datagram)

        # Reset sender channel:
        datagram = PyDatagram()
        datagram.addServerHeader(channel, self.csm.air.ourChannel, CLIENTAGENT_SET_CLIENT_ID)
        datagram.addChannel(self.target<<32)
        self.csm.air.send(datagram)

        # Unload avatar object:
        datagram = PyDatagram()
        datagram.addServerHeader(self.avId, channel, STATESERVER_OBJECT_DELETE_RAM)
        datagram.addUint32(self.avId)
        self.csm.air.send(datagram)

        # Done!
        self.csm.air.writeServerEvent('avatarUnload', self.avId)
        self.demand('Off')
    def handleConnected(self):
        self.districtId = self.allocateChannel()

        # register the AI on the state server...
        dg = PyDatagram()
        dg.addServerHeader(self.serverId, self.ourChannel, STATESERVER_ADD_SHARD)
        dg.addUint32(self.districtId)
        dg.addString(self.districtName)
        dg.addUint32(self.districtPopulation)
        self.send(dg)

        # add a post remove to remove the shard from the state server
        # when we disconnect from the message director...
        dg = PyDatagram()
        dg.addServerHeader(self.serverId, self.ourChannel, STATESERVER_REMOVE_SHARD)
        self.addPostRemove(dg)

        self.rootObj = DistributedObjectAI(self)
        self.rootObj.generateWithRequiredAndId(self.districtId, 0, 0)

        self.notify.info('Creating managers...')
        self.createManagers()

        if self.config.GetBool('want-safe-zones', True):
            self.notify.info('Creating safe zones...')
            self.createSafeZones()

        if self.config.GetBool('want-cog-headquarters', True):
            self.notify.info('Creating Cog headquarters...')
            self.createCogHeadquarters()

        self.notify.info('Done.')
Exemplo n.º 8
0
 def enterUnloadAvatar(self):
     channel = self.csm.GetAccountConnectionChannel(self.target)
     self.csm.air.friendsManager.toonOffline(self.avId)
     dg = PyDatagram()
     dg.addServerHeader(channel, self.csm.air.ourChannel,
                        CLIENTAGENT_CLEAR_POST_REMOVES)
     self.csm.air.send(dg)
     dg = PyDatagram()
     dg.addServerHeader(channel, self.csm.air.ourChannel,
                        CLIENTAGENT_CLOSE_CHANNEL)
     dg.addChannel(self.csm.GetPuppetConnectionChannel(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.csm.air.send(dg)
     dg = PyDatagram()
     dg.addServerHeader(channel, self.csm.air.ourChannel,
                        CLIENTAGENT_REMOVE_SESSION_OBJECT)
     dg.addUint32(self.avId)
     self.csm.air.send(dg)
     dg = PyDatagram()
     dg.addServerHeader(self.avId, channel, STATESERVER_OBJECT_DELETE_RAM)
     dg.addUint32(self.avId)
     self.csm.air.send(dg)
     self.csm.air.writeServerEvent('avatar-unload', avId=self.avId)
     self.demand('Off')
Exemplo n.º 9
0
    def inviteeFriendResponse(self, response, context):
        avId = self.air.getAvatarIdFromSender()
        if not context in self.requests:
            self.air.writeServerEvent(
                'suspicious',
                avId=avId,
                issue=
                'Player tried to respond to a friend request that doesn\'t exist!'
            )
            return
        if avId != self.requests[context][0][1]:
            self.air.writeServerEvent(
                'suspicious',
                avId=avId,
                issue='Player tried to respond to someone else\'s request!')
            return
        if self.requests[context][1] == 'cancelled':
            self.air.writeServerEvent(
                'suspicious',
                avId=avId,
                issue='Player tried to respond to non-active friend request!')
            return
        self.sendUpdateToAvatarId(self.requests[context][0][0],
                                  'friendResponse', [response, context])
        if response == 1:
            requested = self.air.doId2do.get(self.requests[context][0][1])
            requester = self.air.doId2do.get(self.requests[context][0][0])

            if not (requested and requester):
                # Likely they logged off just before a response was sent. RIP.
                return

            # Allow both toons to teleport to each other.
            dg = PyDatagram()
            dg.addServerHeader(
                self.GetPuppetConnectionChannel(requested.getDoId()),
                self.air.ourChannel, CLIENTAGENT_DECLARE_OBJECT)
            dg.addUint32(requester.getDoId())
            dg.addUint16(
                self.air.dclassesByName['DistributedToonAI'].getNumber())
            self.air.send(dg)

            dg = PyDatagram()
            dg.addServerHeader(
                self.GetPuppetConnectionChannel(requester.getDoId()),
                self.air.ourChannel, CLIENTAGENT_DECLARE_OBJECT)
            dg.addUint32(requested.getDoId())
            dg.addUint16(
                self.air.dclassesByName['DistributedToonAI'].getNumber())
            self.air.send(dg)

            requested.extendFriendsList(requester.getDoId(), 0)
            requester.extendFriendsList(requested.getDoId(), 0)

            requested.d_setFriendsList(requested.getFriendsList())
            requester.d_setFriendsList(requester.getFriendsList())
        del self.requests[context]
Exemplo n.º 10
0
    def enterSetAccount(self):
        # If somebody's already logged into this account, disconnect them.
        datagram = PyDatagram()
        datagram.addServerHeader(
            self.gameServicesManager.GetAccountConnectionChannel(
                self.accountId), self.gameServicesManager.air.ourChannel,
            CLIENTAGENT_EJECT)
        datagram.addUint16(OTPGlobals.BootedReason["loggedInElsewhere"])
        datagram.addString('This account has been logged into elsewhere.')
        self.gameServicesManager.air.send(datagram)

        # Now we'll add this connection to the account channel.
        datagram = PyDatagram()
        datagram.addServerHeader(self.target,
                                 self.gameServicesManager.air.ourChannel,
                                 CLIENTAGENT_OPEN_CHANNEL)
        datagram.addChannel(
            self.gameServicesManager.GetAccountConnectionChannel(
                self.accountId))
        self.gameServicesManager.air.send(datagram)

        # Set their sender channel to represent their account affiliation.
        datagram = PyDatagram()
        datagram.addServerHeader(self.target,
                                 self.gameServicesManager.air.ourChannel,
                                 CLIENTAGENT_SET_CLIENT_ID)
        datagram.addChannel(
            self.accountId <<
            32)  # accountId in high 32 bits, 0 in low (no avatar).
        self.gameServicesManager.air.send(datagram)

        # We can now un-sandbox the sender.
        self.gameServicesManager.air.setClientState(self.target,
                                                    2)  # ESTABLISHED state.

        # Update the last login timestamp.
        self.gameServicesManager.air.dbInterface.updateObject(
            self.gameServicesManager.air.dbId, self.accountId,
            self.gameServicesManager.air.dclassesByName['AccountUD'], {
                'LAST_LOGIN': time.ctime(),
                'ACCOUNT_ID': str(self.databaseId),
                'ACCESS_LEVEL': self.accessLevel
            })

        # We're done.
        self.gameServicesManager.air.writeServerEvent('account-login',
                                                      clientId=self.target,
                                                      accId=self.accountId,
                                                      dbId=self.databaseId,
                                                      playToken=self.playToken)

        # Send the acceptLogin update through the GameServicesManager & set this operation's state to Off.
        self.gameServicesManager.sendUpdateToChannel(self.target,
                                                     'acceptLogin', [])
        self.demand('Off')
Exemplo n.º 11
0
    def enterUnloadAvatar(self):
        # Get the client channel.
        channel = self.gameServicesManager.GetAccountConnectionChannel(
            self.target)

        # Tell the friends manager that we're logging off.
        self.gameServicesManager.air.ttoffFriendsManager.goingOffline(
            self.avId)

        # First, remove our POST_REMOVES.
        datagram = PyDatagram()
        datagram.addServerHeader(channel,
                                 self.gameServicesManager.air.ourChannel,
                                 CLIENTAGENT_CLEAR_POST_REMOVES)
        self.gameServicesManager.air.send(datagram)

        # Next, remove the avatar channel.
        datagram = PyDatagram()
        datagram.addServerHeader(channel,
                                 self.gameServicesManager.air.ourChannel,
                                 CLIENTAGENT_CLOSE_CHANNEL)
        datagram.addChannel(
            self.gameServicesManager.GetPuppetConnectionChannel(self.avId))
        self.gameServicesManager.air.send(datagram)

        # Next, reset the sender channel.
        datagram = PyDatagram()
        datagram.addServerHeader(channel,
                                 self.gameServicesManager.air.ourChannel,
                                 CLIENTAGENT_SET_CLIENT_ID)
        datagram.addChannel(
            self.target << 32)  # accountId in high 32 bits, no avatar in low.
        self.gameServicesManager.air.send(datagram)

        # Reset the session object.
        datagram = PyDatagram()
        datagram.addServerHeader(channel,
                                 self.gameServicesManager.air.ourChannel,
                                 CLIENTAGENT_REMOVE_SESSION_OBJECT)
        datagram.addUint32(self.avId)
        self.gameServicesManager.air.send(datagram)

        # Unload the avatar object.
        datagram = PyDatagram()
        datagram.addServerHeader(self.avId, channel,
                                 STATESERVER_OBJECT_DELETE_RAM)
        datagram.addUint32(self.avId)
        self.gameServicesManager.air.send(datagram)

        # We're done! We can now shut down this operation.
        self.gameServicesManager.air.writeServerEvent('avatar-unloaded',
                                                      avId=self.avId)
        self.demand('Off')
Exemplo n.º 12
0
 def inviteeFriendResponse(self, response, context):
     avId = self.air.getAvatarIdFromSender()
     if not avId:
         return
     if context not in self.requests:
         self.air.writeServerEvent(
             'suspicious', avId,
             "Player tried to respond to a friend request that doesn't exist!"
         )
         return
     if avId != self.requests[context][0][1]:
         self.air.writeServerEvent(
             'suspicious', avId,
             "Player tried to respond to someone else's request!")
         return
     if self.requests[context][1] == 'cancelled':
         self.air.writeServerEvent(
             'suspicious', avId,
             'Player tried to respond to a non-active friend request!')
         return
     self.sendUpdateToAvatarId(self.requests[context][0][0],
                               'friendResponse', [response, context])
     if response == 1:
         requestedAv = self.air.doId2do.get(self.requests[context][0][1])
         if not requestedAv:
             del self.requests[context]
             return
         requesterAv = self.air.doId2do.get(self.requests[context][0][0])
         if not requesterAv:
             del self.requests[context]
             return
         dg = PyDatagram()
         dg.addServerHeader(
             self.GetPuppetConnectionChannel(requestedAv.getDoId()),
             self.air.ourChannel, CLIENTAGENT_DECLARE_OBJECT)
         dg.addUint32(requesterAv.getDoId())
         dg.addUint16(
             self.air.dclassesByName['DistributedToonAI'].getNumber())
         self.air.send(dg)
         dg = PyDatagram()
         dg.addServerHeader(
             self.GetPuppetConnectionChannel(requesterAv.getDoId()),
             self.air.ourChannel, CLIENTAGENT_DECLARE_OBJECT)
         dg.addUint32(requestedAv.getDoId())
         dg.addUint16(
             self.air.dclassesByName['DistributedToonAI'].getNumber())
         self.air.send(dg)
         requestedAv.extendFriendsList(requesterAv.getDoId(), 0)
         requesterAv.extendFriendsList(requestedAv.getDoId(), 0)
         requestedAv.d_setFriendsList(requestedAv.getFriendsList())
         requesterAv.d_setFriendsList(requesterAv.getFriendsList())
     del self.requests[context]
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.
        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 enterSetAccount(self):
        # First, if there's anybody on the account, kill 'em for redundant login:
        dg = PyDatagram()
        dg.addServerHeader(
            self.csm.GetAccountConnectionChannel(self.accountId),
            self.csm.air.ourChannel, CLIENTAGENT_EJECT)
        dg.addUint16(100)
        dg.addString('This account has been logged in elsewhere.')
        self.csm.air.send(dg)

        # Next, add this connection to the account channel.
        dg = PyDatagram()
        dg.addServerHeader(self.target, self.csm.air.ourChannel,
                           CLIENTAGENT_OPEN_CHANNEL)
        dg.addChannel(self.csm.GetAccountConnectionChannel(self.accountId))
        self.csm.air.send(dg)

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

        # Un-sandbox them!
        dg = PyDatagram()
        dg.addServerHeader(self.target, self.csm.air.ourChannel,
                           CLIENTAGENT_SET_STATE)
        dg.addUint16(2)  # ESTABLISHED state.
        self.csm.air.send(dg)

        fields = {
            'LAST_LOGIN': time.ctime(),
            'ACCOUNT_ID': str(self.databaseId)
        }

        if self.adminAccess != -1:
            fields.update({'ADMIN_ACCESS': self.adminAccess})

        # Update the last login timestamp:
        self.csm.air.dbInterface.updateObject(
            self.csm.air.dbId, self.accountId,
            self.csm.air.dclassesByName['AccountUD'], fields)

        # We're done.
        self.csm.air.writeServerEvent('accountLogin', self.target,
                                      self.accountId, self.databaseId)
        self.csm.sendUpdateToChannel(self.target, 'acceptLogin', [])
        self.csm.account2username[self.target] = self.username
        self.demand('Off')
Exemplo n.º 15
0
 def __handleGoneOffline(self, avId, activated, otherId=None, accId=None):
     if not (otherId and activated and accId):
         return
     dg = PyDatagram()
     dg.addServerHeader(self.GetPuppetConnectionChannel(avId),
                        self.air.ourChannel, CLIENTAGENT_UNDECLARE_OBJECT)
     dg.addUint32(otherId)
     self.air.send(dg)
     dg = PyDatagram()
     dg.addServerHeader(self.GetAccountConnectionChannel(accId),
                        self.air.ourChannel, CLIENTAGENT_UNDECLARE_OBJECT)
     dg.addUint32(avId)
     self.air.send(dg)
     self.sendUpdateToAvatarId(avId, 'friendOffline', [otherId])
Exemplo n.º 16
0
    def __handleSetAccount(self):
        # if somebody's already logged into this account, disconnect them
        datagram = PyDatagram()
        datagram.addServerHeader(
            self.loginManager.GetAccountConnectionChannel(self.accountId),
            self.loginManager.air.ourChannel, CLIENTAGENT_EJECT)
        datagram.addUint16(100)
        datagram.addString('This account has been logged in elsewhere.')
        self.loginManager.air.send(datagram)

        # add connection to account channel
        datagram = PyDatagram()
        datagram.addServerHeader(self.sender, self.loginManager.air.ourChannel,
                                 CLIENTAGENT_OPEN_CHANNEL)
        datagram.addChannel(
            self.loginManager.GetAccountConnectionChannel(self.accountId))
        self.loginManager.air.send(datagram)

        # set sender channel to represent account affiliation
        datagram = PyDatagram()
        datagram.addServerHeader(self.sender, self.loginManager.air.ourChannel,
                                 CLIENTAGENT_SET_CLIENT_ID)
        datagram.addChannel(
            self.accountId <<
            32)  # accountId is in high 32 bits, 0 in low (no avatar).
        self.loginManager.air.send(datagram)

        # set client state to established, thus un-sandboxing the sender
        self.loginManager.air.setClientState(self.sender, 2)

        responseData = {
            'returnCode': 0,
            'respString': '',
            'accountNumber': self.sender,
            'createFriendsWithChat': 'YES',
            'chatCodeCreationRule': 'YES',
            'access': 'FULL',
            'WhiteListResponse': 'YES',
            'lastLoggedInStr': self.getLastLoggedInStr(),
            'accountDays': self.getAccountDays(),
            'serverTime': int(time.time()),
            'toonAccountType': 'NO_PARENT_ACCOUNT',
            'userName': str(self.databaseId)
        }
        responseBlob = json.dumps(responseData)
        self.loginManager.sendUpdateToChannel(self.sender, 'loginResponse',
                                              [responseBlob])
        self._handleDone()
Exemplo n.º 17
0
 def sendShardInfo(self):
     dg = PyDatagram()
     dg.addServerHeader(self.serverId, self.ourChannel,
                        STATESERVER_UPDATE_SHARD)
     dg.addString(self.districtName)
     dg.addUint32(self.districtPopulation)
     self.send(dg)
Exemplo n.º 18
0
 def bootClient(self, reason, av):
     dg = PyDatagram()
     dg.addServerHeader(self.GetPuppetConnectionChannel(av),
                        self.air.ourChannel, CLIENTAGENT_EJECT)
     dg.addUint16(106)
     dg.addString(reason)
     self.air.send(dg)
 def enterControlled(self, avId, accId):
     self.driverId = avId
     fieldList = ['setComponentL',
      'setComponentX',
      'setComponentY',
      'setComponentZ',
      'setComponentH',
      'setComponentP',
      'setComponentR',
      'setComponentT',
      'setSmStop',
      'setSmH',
      'setSmZ',
      'setSmXY',
      'setSmXZ',
      'setSmPos',
      'setSmHpr',
      'setSmXYH',
      'setSmXYZH',
      'setSmPosHpr',
      'setSmPosHprL',
      'clearSmoothing',
      'suggestResync',
      'returnResync']
     #self.air.setAllowClientSend(avId, self, fieldList, accId)
     #hack until CLIENTAGENT_SET_FIELDS_SENDABLE works
     #probably should not be kept for any longer than it needs to
     dg = PyDatagram()
     dg.addServerHeader(self.doId, self.air.ourChannel, STATESERVER_OBJECT_SET_OWNER)
     dg.addUint64(accId << 32 | avId)
     self.air.send(dg)
     self.d_setState('C', self.driverId)
    def enterJudgeName(self):
        dg = PyDatagram(self.name)
        dgi = PyDatagramIterator(dg)
        isPattern, name = isNamePattern(dgi, self.csm.namePattern, self.dna.gender)
        
        if not name:
            self.demand('Kill', 'There\'s an issue with your name request!')
            return
        
        toonFields = {'WishNameState': ('PENDING',), 'WishName': (name,)}
        
        if isPattern:
            toonFields['WishNameState'] = ('',)
            toonFields['WishName'] = ('',)
            toonFields['setName'] = (name,)

        if self.avId:
            self.csm.air.dbInterface.updateObject(
                self.csm.air.dbId,
                self.avId,
                self.csm.air.dclassesByName['DistributedToonUD'],
                toonFields)

            self.csm.air.writeServerEvent('avatarWishname', self.avId, name)
            self.csm.accountDB.handlePostNameRequest(self.avId, name)

        self.csm.sendUpdateToAccountId(self.target, 'updateNameResp', [])
        self.demand('Off')
Exemplo n.º 21
0
    def handleConnected(self):
        self.notify.info('Yarn. Waking up (This may take a while!).')
        ToontownInternalRepository.handleConnected(self)
        self.districtId = self.allocateChannel()
        self.distributedDistrict = ToontownDistrictAI(self)
        self.distributedDistrict.setName(self.districtName)
        self.distributedDistrict.generateWithRequiredAndId(
            self.districtId, self.getGameDoId(), 2)

        # Claim ownership of that district...
        dg = PyDatagram()
        dg.addServerHeader(self.districtId, self.ourChannel,
                           STATESERVER_OBJECT_SET_AI)
        dg.addChannel(self.ourChannel)
        self.send(dg)

        self.notify.info('Creating Global Managers')
        self.createGlobals()
        self.notify.info('Creating Toontown')
        self.createZones()

        self.statusSender.start()

        self.distributedDistrict.b_setAvailable(1)
        self.notify.info('District is now ready.')
Exemplo n.º 22
0
 def handleConnected(self):
     ToontownInternalRepository.handleConnected(self)
     self.districtId = self.allocateChannel()
     self.notify.info('Creating district (%d)...' % self.districtId)
     self.district = ToontownDistrictAI(self)
     self.district.setName(self.districtName)
     self.district.setDescription(self.districtDescription)
     self.district.generateWithRequiredAndId(self.districtId,
                                             self.getGameDoId(),
                                             OTP_ZONE_ID_MANAGEMENT)
     self.notify.info('Claiming ownership of district (%d)...' %
                      self.districtId)
     datagram = PyDatagram()
     datagram.addServerHeader(self.districtId, self.ourChannel,
                              STATESERVER_OBJECT_SET_AI)
     datagram.addChannel(self.ourChannel)
     self.send(datagram)
     self.notify.info('Creating local objects...')
     self.createLocals()
     self.notify.info('Creating global objects...')
     self.createGlobals()
     self.notify.info('Creating zones (Playgrounds and Cog HQs)...')
     self.createZones()
     self.notify.info('Making district available...')
     self.district.b_setAvailable(1)
     self.notify.info(
         'District is now ready. Have fun in Toontown Offline!')
    def handleConnected(self):
        ToontownInternalRepository.handleConnected(self)
        self.districtId = self.allocateChannel()
        self.notify.info('Creating new district (%d)...' % self.districtId)
        self.distributedDistrict = ToontownDistrictAI(self)
        self.distributedDistrict.setName(self.districtName)
        self.distributedDistrict.generateWithRequiredAndId(
            self.districtId, self.getGameDoId(), 2)

        # Claim ownership of that district...
        self.notify.info('Claiming ownership of district (%d)...' %
                         self.districtId)
        dg = PyDatagram()
        dg.addServerHeader(self.districtId, self.ourChannel,
                           STATESERVER_OBJECT_SET_AI)
        dg.addChannel(self.ourChannel)
        self.send(dg)
        self.notify.info('Creating global objects...')
        self.createGlobals()
        self.notify.info('Creating zones (Playgrounds and Cog HQs)...')
        self.createZones()

        self.statusSender.start()
        self.notify.info('Making district available to enter...')
        self.distributedDistrict.b_setAvailable(1)
        self.notify.info('District is now ready. Have fun in Toontown!')
 def killConnection(self, connId, reason):
     datagram = PyDatagram()
     datagram.addServerHeader(connId, self.air.ourChannel,
                              CLIENTAGENT_EJECT)
     datagram.addUint16(122)
     datagram.addString(reason)
     self.air.send(datagram)
    def createGlobals(self):
        self.csm = simbase.air.generateGlobalObject(
            OTP_DO_ID_CLIENT_SERVICES_MANAGER, 'ClientServicesManager')

        self.chatAgent = simbase.air.generateGlobalObject(
            OTP_DO_ID_CHAT_MANAGER, 'ChatAgent')

        self.friendsManager = simbase.air.generateGlobalObject(
            OTP_DO_ID_TT_FRIENDS_MANAGER, 'TTFriendsManager')

        self.globalPartyMgr = simbase.air.generateGlobalObject(
            OTP_DO_ID_GLOBAL_PARTY_MANAGER, 'GlobalPartyManager')

        if config.GetBool('want-top-toons', True):
            if OTP_DO_ID_TOONTOWN_TOP_TOONS_MGR == 100003:
                self.topToonsMgr = DistributedTopToonsManagerUD(self)
                self.topToonsMgr.generateWithRequiredAndId(
                    100003, self.getGameDoId(), 2)

                dg = PyDatagram()
                dg.addServerHeader(100003, self.ourChannel,
                                   STATESERVER_OBJECT_SET_AI)
                dg.addChannel(self.ourChannel)
                self.send(dg)

            else:
                self.topToonsMgr = self.generateGlobalObject(
                    OTP_DO_ID_TOONTOWN_TOP_TOONS_MGR,
                    'DistributedTopToonsManager')
Exemplo n.º 26
0
 def __comingOnlineFriendOnline(self, avId, activated, otherId=None):
     if not (otherId and activated):
         return
     dg = PyDatagram()
     dg.addServerHeader(self.GetPuppetConnectionChannel(avId),
                        self.air.ourChannel, CLIENTAGENT_DECLARE_OBJECT)
     dg.addUint32(otherId)
     dg.addUint16(self.air.dclassesByName['DistributedToonUD'].getNumber())
     self.air.send(dg)
     dg = PyDatagram()
     dg.addServerHeader(self.GetPuppetConnectionChannel(otherId),
                        self.air.ourChannel, CLIENTAGENT_DECLARE_OBJECT)
     dg.addUint32(avId)
     dg.addUint16(self.air.dclassesByName['DistributedToonUD'].getNumber())
     self.air.send(dg)
     self.sendUpdateToAvatarId(avId, 'friendOnline', [otherId, 0, 0])
Exemplo n.º 27
0
    def enterSetAccount(self):
        # First, if there's anybody on the account, kill them for redundant login:
        datagram = PyDatagram()
        datagram.addServerHeader(
            self.csm.GetAccountConnectionChannel(self.accountId),
            self.csm.air.ourChannel, CLIENTAGENT_EJECT)
        datagram.addUint16(100)
        datagram.addString('This account has been logged in from elsewhere.')
        self.csm.air.send(datagram)

        # Next, add this connection to the account channel.
        datagram = PyDatagram()
        datagram.addServerHeader(self.target, self.csm.air.ourChannel,
                                 CLIENTAGENT_OPEN_CHANNEL)
        datagram.addChannel(
            self.csm.GetAccountConnectionChannel(self.accountId))
        self.csm.air.send(datagram)

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

        # Un-sandbox them!
        datagram = PyDatagram()
        datagram.addServerHeader(self.target, self.csm.air.ourChannel,
                                 CLIENTAGENT_SET_STATE)
        datagram.addUint16(2)  # ESTABLISHED
        self.csm.air.send(datagram)

        # Update the last login timestamp:
        self.csm.air.dbInterface.updateObject(
            self.csm.air.dbId, self.accountId,
            self.csm.air.dclassesByName['AccountUD'], {
                'LAST_LOGIN': time.ctime(time.mktime(time.gmtime())),
                'ACCOUNT_ID': str(self.userId)
            })

        # We're done.
        self.csm.air.writeServerEvent('accountLogin', self.target,
                                      self.accountId, self.userId)
        self.csm.sendUpdateToChannel(self.target, 'acceptLogin',
                                     [int(time.mktime(time.gmtime()))])
        self.demand('Off')
Exemplo n.º 28
0
 def killConnection(self, connId, code=122, reason=''):
     self.notify.info('Booting client: %d out for reason(%d): %s' %
                      (int(connId), int(code), str(reason)))
     dg = PyDatagram()
     dg.addServerHeader(connId, self.air.ourChannel, CLIENTAGENT_EJECT)
     dg.addUint16(int(code))
     dg.addString(str(reason))
     self.air.send(dg)
Exemplo n.º 29
0
 def killConnection(self, connectionId, reason):
     # Sends CLIENTAGENT_EJECT to the given connectionId with the given reason.
     datagram = PyDatagram()
     datagram.addServerHeader(connectionId, self.air.ourChannel,
                              CLIENTAGENT_EJECT)
     datagram.addUint16(OTPGlobals.BootedReason["connectionKilled"])
     datagram.addString(reason)
     self.air.send(datagram)
Exemplo n.º 30
0
 def enterSetAvatarTask(self, channel, task):
     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)
     self.csm.air.writeServerEvent('avatarChosen', self.avId, self.target)
     self.demand('Off')
     return task.done