Exemplo n.º 1
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 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 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')
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 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.º 6
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.')
    def enterUnloadAvatar(self):
        channel = self.csm.GetAccountConnectionChannel(self.target)
        
        # Tell FriendsManager somebody is logging off:
        self.csm.air.friendsManager.toonOffline(self.avId)

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

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

        # Reset sender channel:
        dg = PyDatagram()
        dg.addServerHeader(channel, self.csm.air.ourChannel, CLIENTAGENT_SET_CLIENT_ID)
        dg.addChannel(self.target<<32) # accountId in high 32 bits, no avatar in low
        self.csm.air.send(dg)

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

        # Done!
        self.csm.air.writeServerEvent('avatarUnload', self.avId)
        self.demand('Off')
    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.º 9
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.º 10
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!')
Exemplo n.º 11
0
    def enterUnloadAvatar(self):
        channel = self.csm.GetAccountConnectionChannel(self.target)

        # Fire off the avatarOffline message.
        self.csm.air.netMessenger.send("avatarOffline", [self.avId])

        # Get lost, POST_REMOVES!:
        dg = PyDatagram()
        dg.addServerHeader(channel, self.csm.air.ourChannel, CLIENTAGENT_CLEAR_POST_REMOVES)
        self.csm.air.send(dg)

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

        # Reset sender channel:
        dg = PyDatagram()
        dg.addServerHeader(channel, self.csm.air.ourChannel, CLIENTAGENT_SET_CLIENT_ID)
        dg.addChannel(self.target << 32)  # accountId in high 32 bits, no avatar in low
        self.csm.air.send(dg)

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

        # Done!
        self.csm.air.writeServerEvent("avatar-unload", avId=self.avId)
        self.demand("Off")
Exemplo n.º 12
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')
    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)
    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')
Exemplo n.º 15
0
 def enterSetAccount(self):
     if self.accessLevel:
         self.csm.air.dbInterface.updateObject(
             self.csm.air.dbId, self.accountId,
             self.csm.air.dclassesByName['AccountUD'],
             {'ACCESS_LEVEL': self.accessLevel})
     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)
     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)
     access = self.account.get('ACCESS_LEVEL', 0)
     if access >= 200:
         dg = PyDatagram()
         dg.addServerHeader(self.target, self.csm.air.ourChannel,
                            CLIENTAGENT_OPEN_CHANNEL)
         dg.addChannel(OtpDoGlobals.OTP_MOD_CHANNEL)
         self.csm.air.send(dg)
     if access >= 400:
         dg = PyDatagram()
         dg.addServerHeader(self.target, self.csm.air.ourChannel,
                            CLIENTAGENT_OPEN_CHANNEL)
         dg.addChannel(OtpDoGlobals.OTP_ADMIN_CHANNEL)
         self.csm.air.send(dg)
     if access >= 500:
         dg = PyDatagram()
         dg.addServerHeader(self.target, self.csm.air.ourChannel,
                            CLIENTAGENT_OPEN_CHANNEL)
         dg.addChannel(OtpDoGlobals.OTP_SYSADMIN_CHANNEL)
         self.csm.air.send(dg)
     datagram = PyDatagram()
     datagram.addServerHeader(self.target, self.csm.air.ourChannel,
                              CLIENTAGENT_SET_CLIENT_ID)
     datagram.addChannel(self.accountId << 32)
     self.csm.air.send(datagram)
     datagram = PyDatagram()
     datagram.addServerHeader(self.target, self.csm.air.ourChannel,
                              CLIENTAGENT_SET_STATE)
     datagram.addUint16(2)
     self.csm.air.send(datagram)
     self.csm.air.dbInterface.updateObject(
         self.csm.air.dbId, self.accountId,
         self.csm.air.dclassesByName['AccountUD'], {
             'LAST_LOGIN': time.ctime(),
             'ACCOUNT_ID': str(self.userId)
         })
     self.csm.air.writeServerEvent('accountLogin', self.target,
                                   self.accountId, self.userId)
     self.csm.sendUpdateToChannel(self.target, 'acceptLogin',
                                  [int(time.time())])
     self.demand('Off')
Exemplo n.º 16
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
Exemplo n.º 17
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.º 18
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.º 19
0
    def enterSetAvatarTask(self, channel, task):
        # 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)

        self.csm.air.writeServerEvent('avatarChosen', self.avId, self.target)
        self.demand('Off')
        return task.done
    def handleConnected(self):
        self.districtId = self.allocateChannel()
        self.distributedDistrict = ToontownDistrictAI(self)
        self.distributedDistrict.setName(self.districtName)
        self.distributedDistrict.generateWithRequiredAndId(simbase.air.districtId, self.getGameDoId(), 2)

        dg = PyDatagram()
        dg.addServerHeader(simbase.air.districtId, simbase.air.ourChannel, STATESERVER_OBJECT_SET_AI)
        dg.addChannel(simbase.air.ourChannel)
        simbase.air.send(dg)

        self.createGlobals()
        self.createZones()
    def enterSetAvatarTask(self, channel, task):
        # 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 the GlobalPartyManager as well:
        self.csm.air.globalPartyMgr.avatarJoined(self.avId)

        self.csm.air.writeServerEvent('avatarChosen', self.avId, self.target)
        self.demand('Off')
        return task.done
    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')
    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')
    def handleConnected(self):
        self.districtId = self.allocateChannel()
        self.distributedDistrict = ToontownDistrictAI(self)
        self.distributedDistrict.setName(self.districtName)
        self.distributedDistrict.generateWithRequiredAndId(
            simbase.air.districtId, self.getGameDoId(), 2)

        dg = PyDatagram()
        dg.addServerHeader(simbase.air.districtId, simbase.air.ourChannel,
                           STATESERVER_OBJECT_SET_AI)
        dg.addChannel(simbase.air.ourChannel)
        simbase.air.send(dg)

        self.createGlobals()
        self.createZones()
Exemplo n.º 25
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()
    def enterSetAvatarTask(self, channel, task):
        # 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 the GlobalPartyManager as well:
        self.csm.air.globalPartyMgr.avatarJoined(self.avId)

        self.csm.air.writeServerEventMessage('avatarChosen', self.avId, self.target)
        self.demand('Off')
        return task.done
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')
    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)
    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.º 30
0
    def enterSetAvatarTask(self, channel, task):
        # 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 the GlobalPartyManager as well:
        self.csm.air.globalPartyMgr.avatarJoined(self.avId)

        fields = self.avatar
        fields.update(
            {'setAdminAccess': [self.account.get('ACCESS_LEVEL', 100)]})
        self.csm.air.friendsManager.addToonData(self.avId, fields)

        self.csm.air.writeServerEvent('avatarChosen', self.avId, self.target)
        self.demand('Off')
        return task.done
    def enterSetAvatarTask(self, channel, task):
        # 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 the GlobalPartyManager as well:
        self.csm.air.globalPartyMgr.avatarJoined(self.avId)
        
        fields = self.avatar
        fields.update({'setAdminAccess': [self.account.get('ACCESS_LEVEL', 100)]})
        self.csm.air.friendsManager.addToonData(self.avId, fields)        

        self.csm.air.writeServerEvent('avatarChosen', self.avId, self.target)
        self.demand('Off')
        return task.done
Exemplo n.º 32
0
    def enterUnloadAvatar(self):
        channel = self.csm.GetAccountConnectionChannel(self.target)

        # 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')
Exemplo n.º 33
0
 def enterSetAccount(self):
     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)
     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)
     access = self.account.get('ADMIN_ACCESS', 0)
     if access >= 400:
         dg = PyDatagram()
         dg.addServerHeader(self.target, self.csm.air.ourChannel,
                            CLIENTAGENT_OPEN_CHANNEL)
         dg.addChannel(OtpDoGlobals.OTP_MOD_CHANNEL)
         self.csm.air.send(dg)
     if access >= 500:
         dg = PyDatagram()
         dg.addServerHeader(self.target, self.csm.air.ourChannel,
                            CLIENTAGENT_OPEN_CHANNEL)
         dg.addChannel(OtpDoGlobals.OTP_ADMIN_CHANNEL)
         self.csm.air.send(dg)
     dg = PyDatagram()
     dg.addServerHeader(self.target, self.csm.air.ourChannel,
                        CLIENTAGENT_SET_CLIENT_ID)
     dg.addChannel(self.accountId << 32)
     self.csm.air.send(dg)
     dg = PyDatagram()
     dg.addServerHeader(self.target, self.csm.air.ourChannel,
                        CLIENTAGENT_SET_STATE)
     dg.addUint16(2)
     self.csm.air.send(dg)
     self.csm.air.dbInterface.updateObject(
         self.csm.air.dbId, self.accountId,
         self.csm.air.dclassesByName['AccountUD'], {
             'LAST_LOGIN': time.ctime(),
             'ACCOUNT_ID': str(self.databaseId),
             'ADMIN_ACCESS': self.adminAccess
         })
     self.csm.air.writeServerEvent('account-login',
                                   clientId=self.target,
                                   accId=self.accountId,
                                   webAccId=self.databaseId,
                                   cookie=self.cookie)
     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)

        # 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')
Exemplo n.º 35
0
    def handleConnected(self):
        ToontownInternalRepository.handleConnected(self)

        # Generate our district...
        self.districtId = self.allocateChannel()
        self.notify.info('Creating district (%d)...' % self.districtId)
        self.district = ToontownDistrictAI(self)
        self.district.setName(self.districtName)
        self.district.generateWithRequiredAndId(self.districtId,
                                                self.getGameDoId(),
                                                OTP_ZONE_ID_MANAGEMENT)

        # Claim ownership of that district...
        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)

        # Create our local objects.
        self.notify.info('Creating local objects...')
        self.createLocals()

        # Create our global objects.
        self.notify.info('Creating global objects...')
        self.createGlobals()

        # Create our zones.
        self.notify.info('Creating zones (Playgrounds and Cog HQs)...')
        self.createZones()

        # Make our district available, and we're done.
        self.notify.info('Get your districts in, and...')
        self.district.b_setAvailable(1)
        self.notify.info(
            'Districts are now complete. NOW PLAY TOONTOWN MYSTERY OR ELSE!!!!!!'
        )
Exemplo n.º 36
0
 def enterSetAccount(self):
     datagram = PyDatagram()
     datagram.addServerHeader(
         self.gameServicesManager.GetAccountConnectionChannel(
             self.accountId), self.gameServicesManager.air.ourChannel,
         CLIENTAGENT_EJECT)
     datagram.addUint16(OTPGlobals.BootedLoggedInElsewhere)
     datagram.addString('This account has been logged into elsewhere.')
     self.gameServicesManager.air.send(datagram)
     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)
     datagram = PyDatagram()
     datagram.addServerHeader(self.target,
                              self.gameServicesManager.air.ourChannel,
                              CLIENTAGENT_SET_CLIENT_ID)
     datagram.addChannel(self.accountId << 32)
     self.gameServicesManager.air.send(datagram)
     self.gameServicesManager.air.setClientState(self.target, 2)
     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
         })
     self.gameServicesManager.air.writeServerEvent('account-login',
                                                   clientId=self.target,
                                                   accId=self.accountId,
                                                   dbId=self.databaseId,
                                                   playToken=self.playToken)
     self.gameServicesManager.sendUpdateToChannel(self.target,
                                                  'acceptLogin', [])
     self.demand('Off')
Exemplo n.º 37
0
 def enterUnloadAvatar(self):
     channel = self.gameServicesManager.GetAccountConnectionChannel(
         self.target)
     self.gameServicesManager.air.ttoffFriendsManager.goingOffline(
         self.avId)
     datagram = PyDatagram()
     datagram.addServerHeader(channel,
                              self.gameServicesManager.air.ourChannel,
                              CLIENTAGENT_CLEAR_POST_REMOVES)
     self.gameServicesManager.air.send(datagram)
     datagram = PyDatagram()
     datagram.addServerHeader(channel,
                              self.gameServicesManager.air.ourChannel,
                              CLIENTAGENT_CLOSE_CHANNEL)
     datagram.addChannel(
         self.gameServicesManager.GetPuppetConnectionChannel(self.avId))
     self.gameServicesManager.air.send(datagram)
     datagram = PyDatagram()
     datagram.addServerHeader(channel,
                              self.gameServicesManager.air.ourChannel,
                              CLIENTAGENT_SET_CLIENT_ID)
     datagram.addChannel(self.target << 32)
     self.gameServicesManager.air.send(datagram)
     datagram = PyDatagram()
     datagram.addServerHeader(channel,
                              self.gameServicesManager.air.ourChannel,
                              CLIENTAGENT_REMOVE_SESSION_OBJECT)
     datagram.addUint32(self.avId)
     self.gameServicesManager.air.send(datagram)
     datagram = PyDatagram()
     datagram.addServerHeader(self.avId, channel,
                              STATESERVER_OBJECT_DELETE_RAM)
     datagram.addUint32(self.avId)
     self.gameServicesManager.air.send(datagram)
     simbase.air.banManager.removeClient(self.target)
     self.gameServicesManager.air.writeServerEvent('avatar-unloaded',
                                                   avId=self.avId)
     self.demand('Off')
Exemplo n.º 38
0
 def handleConnected(self):
     ToontownInternalRepository.handleConnected(self)
     if self.holidayPasscode != '':
         self.initServerHoliday()
     self.districtId = self.allocateChannel()
     self.notify.info('Creating district (%d)...' % self.districtId)
     self.distributedDistrict = ToontownDistrictAI(self)
     self.distributedDistrict.setName(self.districtName)
     self.distributedDistrict.setDescription(self.serverDescription)
     self.distributedDistrict.setHolidayPasscode(self.holidayValue)
     self.distributedDistrict.generateWithRequiredAndId(
         self.districtId, self.getGameDoId(), OTP_ZONE_ID_MANAGEMENT)
     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()
    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')
    def enterUnloadAvatar(self):
        channel = self.csm.GetAccountConnectionChannel(self.target)

        # Fire off the avatarOffline message.
        self.csm.air.netMessenger.send('avatarOffline', [self.avId])

        # Get lost, POST_REMOVES!:
        dg = PyDatagram()
        dg.addServerHeader(channel, self.csm.air.ourChannel,
                           CLIENTAGENT_CLEAR_POST_REMOVES)
        self.csm.air.send(dg)

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

        # Reset sender channel:
        dg = PyDatagram()
        dg.addServerHeader(channel, self.csm.air.ourChannel,
                           CLIENTAGENT_SET_CLIENT_ID)
        dg.addChannel(
            self.target << 32)  # accountId in high 32 bits, no avatar in low
        self.csm.air.send(dg)

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

        # Done!
        self.csm.air.writeServerEvent('avatar-unload', avId=self.avId)
        self.demand('Off')
    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.º 42
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')
Exemplo n.º 43
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.º 44
0
    def inventorySetup(self, inventoryId):
        channel = self.csm.GetAccountConnectionChannel(self.target)

        # Activate the avatar on the DBSS:
        self.csm.air.sendActivate(
            self.avId, 0, 0, self.csm.air.dclassesByName['DistributedPlayerPirateUD'], {
                'setInventoryId': (inventoryId,)})

        # 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)

        # Claim ownership of the avatar's inventory
        datagram = PyDatagram()
        datagram.addServerHeader(
            self.avId,
            self.csm.air.ourChannel,
            STATESERVER_OBJECT_SET_OWNER)
        datagram.addChannel(inventoryId)
        self.csm.air.send(datagram)

        # Eliminate race conditions.
        taskMgr.doMethodLater(0.2, self.enterSetAvatarTask,
                              'avatarTask-%s' % self.avId, extraArgs=[channel],
                              appendTask=True)
Exemplo n.º 45
0
    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)

        # Subscribe to any "staff" channels that the account has access to.
        access = self.account.get("ADMIN_ACCESS", 0)
        if access >= 200:
            # Subscribe to the moderator channel.
            dg = PyDatagram()
            dg.addServerHeader(self.target, self.csm.air.ourChannel, CLIENTAGENT_OPEN_CHANNEL)
            dg.addChannel(OtpDoGlobals.OTP_MOD_CHANNEL)
            self.csm.air.send(dg)
        if access >= 400:
            # Subscribe to the administrator channel.
            dg = PyDatagram()
            dg.addServerHeader(self.target, self.csm.air.ourChannel, CLIENTAGENT_OPEN_CHANNEL)
            dg.addChannel(OtpDoGlobals.OTP_ADMIN_CHANNEL)
            self.csm.air.send(dg)
        if access >= 500:
            # Subscribe to the system administrator channel.
            dg = PyDatagram()
            dg.addServerHeader(self.target, self.csm.air.ourChannel, CLIENTAGENT_OPEN_CHANNEL)
            dg.addChannel(OtpDoGlobals.OTP_SYSADMIN_CHANNEL)
            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. BIG FAT SECURITY RISK!!!
        self.csm.air.send(dg)

        # 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(),
                "ACCOUNT_ID": self.databaseId,
                "ADMIN_ACCESS": self.adminAccess,
                "BETA_KEY_QUEST": self.betaKeyQuest,
            },
        )

        # Add a POST_REMOVE to the connection channel to execute the NetMessenger
        # message when the account connection goes RIP on the Client Agent.
        dgcleanup = self.csm.air.netMessenger.prepare("accountDisconnected", [self.accountId])
        dg = PyDatagram()
        dg.addServerHeader(self.target, self.csm.air.ourChannel, CLIENTAGENT_ADD_POST_REMOVE)
        dg.addString(dgcleanup.getMessage())
        self.csm.air.send(dg)

        # We're done.
        self.csm.air.writeServerEvent(
            "account-login", clientId=self.target, accId=self.accountId, webAccId=self.databaseId, cookie=self.cookie
        )
        self.csm.sendUpdateToChannel(self.target, "acceptLogin", [])
        self.demand("Off")
 def claimOwnership(self, channelId):
     datagram = PyDatagram()
     datagram.addServerHeader(channelId, self.ourChannel, STATESERVER_OBJECT_SET_AI)
     datagram.addChannel(self.ourChannel)
     self.send(datagram)
    def enterSetAccount(self):
        # If necessary, update their account information:
        if self.accessLevel:
            self.csm.air.dbInterface.updateObject(
                self.csm.air.dbId,
                self.accountId,
                self.csm.air.dclassesByName['AccountUD'],
                {'ACCESS_LEVEL': self.accessLevel})

        # 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)

        # Subscribe to any "staff" channels that the account has access to.
        access = self.account.get('ADMIN_ACCESS', 0)
        if access >= 200:
            # Subscribe to the moderator channel.
            dg = PyDatagram()
            dg.addServerHeader(self.target, self.csm.air.ourChannel, CLIENTAGENT_OPEN_CHANNEL)
            dg.addChannel(OtpDoGlobals.OTP_MOD_CHANNEL)
            self.csm.air.send(dg)
        if access >= 400:
            # Subscribe to the administrator channel.
            dg = PyDatagram()
            dg.addServerHeader(self.target, self.csm.air.ourChannel, CLIENTAGENT_OPEN_CHANNEL)
            dg.addChannel(OtpDoGlobals.OTP_ADMIN_CHANNEL)
            self.csm.air.send(dg)
        if access >= 500:
            # Subscribe to the system administrator channel.
            dg = PyDatagram()
            dg.addServerHeader(self.target, self.csm.air.ourChannel, CLIENTAGENT_OPEN_CHANNEL)
            dg.addChannel(OtpDoGlobals.OTP_SYSADMIN_CHANNEL)
            self.csm.air.send(dg)

        # 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(),
             'LAST_LOGIN_TS': time.time(),
             '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.time())])
        self.demand('Off')