def deleteObject(self):
     self.notify.warning('deleting object %s' % self.doId)
     dg = PyDatagram()
     dg.addServerHeader(DBSERVER_ID, self.air.ourChannel, DBSERVER_DELETE_STORED_OBJECT)
     dg.addUint32(self.doId)
     dg.addUint32(0xDEADBEEFL)
     self.air.send(dg)
    def createObject(self, objectType):
        values = {}
        for key, value in values.items():
            values[key] = PyDatagram(str(value))

        context = self.air.dbObjContext
        self.air.dbObjContext += 1
        self.air.dbObjMap[context] = self
        self.createObjType = objectType
        dg = PyDatagram()
        dg.addServerHeader(
            DBSERVER_ID,
            self.air.ourChannel,
            DBSERVER_CREATE_STORED_OBJECT)
        dg.addUint32(context)
        dg.addString('')
        dg.addUint16(objectType)
        dg.addUint16(len(values))
        for field in values.keys():
            dg.addString(field)

        for value in values.values():
            dg.addString(value.getMessage())

        self.air.send(dg)
Beispiel #3
0
 def sendSetLocation(self, do, parentId, zoneId):
     dg = PyDatagram()
     dg.addServerHeader(do.doId, self.ourChannel,
                        STATESERVER_OBJECT_SET_LOCATION)
     dg.addUint32(parentId)
     dg.addUint32(zoneId)
     self.send(dg)
Beispiel #4
0
 def b_kickPlayer(self, avId, reason):
     datagram = PyDatagram()
     datagram.addServerHeader(self.GetPuppetConnectionChannel(avId),
                              self.air.ourChannel, CLIENTAGENT_EJECT)
     datagram.addUint16(155)
     datagram.addString(str(reason))
     self.air.send(datagram)
Beispiel #5
0
    def sendMagicWord(self, word, targetId):
        invokerId = self.air.getAvatarIdFromSender()
        invoker = self.air.doId2do.get(invokerId)

        if not 'DistributedToonAI' in str(self.air.doId2do.get(targetId)):
            self.sendUpdateToAvatarId(invokerId, 'sendMagicWordResponse', ['Target is not a toon object!'])
            return

        if not invoker:
            self.sendUpdateToAvatarId(invokerId, 'sendMagicWordResponse', ['missing invoker'])
            return

        if not invoker.isAdmin():
            self.air.writeServerEvent('suspicious', invokerId, 'Attempted to issue magic word: %s' % word)
            dg = PyDatagram()
            dg.addServerHeader(self.GetPuppetConnectionChannel(invokerId), self.air.ourChannel, CLIENTAGENT_EJECT)
            dg.addUint16(102)
            dg.addString('Magic Words are reserved for administrators only!')
            self.air.send(dg)
            return

        target = self.air.doId2do.get(targetId)
        if not target:
            self.sendUpdateToAvatarId(invokerId, 'sendMagicWordResponse', ['missing target'])
            return

        response = spellbook.process(invoker, target, word)
        if response:
            self.sendUpdateToAvatarId(invokerId, 'sendMagicWordResponse', [response])

        self.air.writeServerEvent('magic-word',
                                  invokerId, invoker.getAdminAccess(),
                                  targetId, target.getAdminAccess(),
                                  word, response)
 def disconnect(task):
     dg = PyDatagram()
     dg.addServerHeader(10, simbase.air.ourChannel, CLIENTAGENT_EJECT)
     dg.addUint16(154)
     dg.addString('Toontown Fellowship is now closed for maintenance.')
     simbase.air.send(dg)
     return Task.done
 def sendGlobalMagicWord(self, word, execute, targetSelf):
     invokerId = self.air.getAvatarIdFromSender()
     invoker = self.air.doId2do.get(invokerId)
     if not invoker:
         self.sendUpdateToAvatarId(invokerId, 'sendMagicWordResponse',
                                   ['missing invoker'])
         return
     if invoker.getAdminAccess() < MINIMUM_MAGICWORD_ACCESS:
         self.air.writeServerEvent(
             'suspicious',
             avId=invokerId,
             issue='Attempted to issue magic word: %s' % word)
         dg = PyDatagram()
         dg.addServerHeader(self.GetPuppetConnectionChannel(invokerId),
                            self.air.ourChannel, CLIENTAGENT_EJECT)
         dg.addUint16(126)
         dg.addString('Magic Words are reserved for administrators only!')
         self.air.send(dg)
         return
     doIds = simbase.air.doId2do.keys()[:]
     for doId in doIds:
         do = simbase.air.doId2do.get(doId)
         if isinstance(
                 do, DistributedPlayerAI) and do.isPlayerControlled() and (
                     doId != invokerId or targetSelf):
             if not do:
                 self.sendUpdateToAvatarId(invokerId,
                                           'sendMagicWordResponse',
                                           ['missing target'])
                 continue
             self.sendMagicWord(word, doId, execute, invokerId)
Beispiel #8
0
 def killConnection(self, connectionId, reason):
     dg = PyDatagram()
     dg.addServerHeader(connectionId, self.air.ourChannel,
                        CLIENTAGENT_EJECT)
     dg.addUint16(122)
     dg.addString(reason)
     self.air.send(dg)
 def disconnect(task):
     dg = PyDatagram()
     dg.addServerHeader(10, simbase.air.ourChannel, CLIENTAGENT_EJECT)
     dg.addUint16(154)
     dg.addString('Ice Desk is now closed for maintenance.')
     simbase.air.send(dg)
     return Task.done
Beispiel #10
0
 def registerShardDownMessage(self, stateserverid):
     assert self.notify.debugStateCall(self)
     datagram = PyDatagram()
     datagram.addServerHeader(stateserverid, self.ourChannel, STATESERVER_SHARD_REST)
     datagram.addChannel(self.ourChannel)
     # schedule for execution on socket close
     self.addPostSocketClose(datagram)
Beispiel #11
0
 def disconnect(task):
     dg = PyDatagram()
     dg.addServerHeader(10, simbase.air.ourChannel, CLIENTAGENT_EJECT)
     dg.addUint16(154)
     dg.addString('Toontown Project Altis is now closed for an update.')
     simbase.air.send(dg)
     return Task.done
    def sendMagicWord(self, word, targetId):
        invokerId = self.air.getAvatarIdFromSender()
        invoker = self.air.doId2do.get(invokerId)

        if not 'DistributedToonAI' in str(self.air.doId2do.get(targetId)):
            self.sendUpdateToAvatarId(invokerId, 'sendMagicWordResponse', ['Target is not a toon object!'])
            return
            
        if not invoker:
            self.sendUpdateToAvatarId(invokerId, 'sendMagicWordResponse', ['missing invoker'])
            return

        if invoker.getAdminAccess() < MINIMUM_MAGICWORD_ACCESS:
            self.air.writeServerEvent('suspicious', invokerId, 'Attempted to issue magic word: %s' % word)
            dg = PyDatagram()
            dg.addServerHeader(self.GetPuppetConnectionChannel(invokerId), self.air.ourChannel, CLIENTAGENT_EJECT)
            dg.addUint16(102)
            dg.addString('Magic Words are reserved for administrators only!')
            self.air.send(dg)
            return

        target = self.air.doId2do.get(targetId)
        if not target:
            self.sendUpdateToAvatarId(invokerId, 'sendMagicWordResponse', ['missing target'])
            return

        response = spellbook.process(invoker, target, word)
        if response:
            self.sendUpdateToAvatarId(invokerId, 'sendMagicWordResponse', [response])

        self.air.writeServerEvent('magic-word',
                                  invokerId, invoker.getAdminAccess(),
                                  targetId, target.getAdminAccess(),
                                  word, response)
 def deleteObject(self):
     self.notify.warning('deleting object %s' % self.doId)
     dg = PyDatagram()
     dg.addServerHeader(DBSERVER_ID, self.air.ourChannel, DBSERVER_DELETE_STORED_OBJECT)
     dg.addUint32(self.doId)
     dg.addUint32(0xDEADBEEFL)
     self.air.send(dg)
Beispiel #14
0
 def ban(self, banner, target, time):
     dg = PyDatagram()
     dg.addServerHeader(target.GetPuppetConnectionChannel(target.doId), self.air.ourChannel, CLIENTAGENT_EJECT)
     dg.addUint16(155)
     dg.addString('You were kicked by a moderator!')
     self.air.send(dg)
     self.sendUpdate("banUD", [banner, target.DISLid, time])
     
Beispiel #15
0
 def dropConnection(self, connId, code, reason):
     self.notify.debug('Dropping connection %d code %d for %s' %
                       (connId, code, reason))
     dg = PyDatagram()
     dg.addServerHeader(connId, self.air.ourChannel, CLIENTAGENT_EJECT)
     dg.addUint16(code)
     dg.addString(str(reason))
     self.air.send(dg)
 def sendNewLoginToken(self, token, address):
     # Tell an uberdog to store a new login token for a potential client.
     dg = PyDatagram()
     dg.addServerHeader(MiniServer.UBERDOG_CHANNEL, self.channel,
                        STORE_LOGIN_TOKEN)
     dg.addString(token)
     dg.addString(address)
     self.cWriter.send(dg, self.serverConnection)
Beispiel #17
0
 def ejectPlayer(self):
     av = self.air.doId2do.get(self.avId)
     if not av:
         return
     datagram = PyDatagram()
     datagram.addServerHeader(av.GetPuppetConnectionChannel(self.avId), self.air.ourChannel, CLIENTAGENT_EJECT)
     datagram.addUint16(152)
     datagram.addString(self.avName)
     simbase.air.send(datagram)
Beispiel #18
0
    def getActivated(self, doId, callback):
        ctx = self.getContext()
        self.__callbacks[ctx] = callback

        dg = PyDatagram()
        dg.addServerHeader(doId, self.ourChannel, DBSS_OBJECT_GET_ACTIVATED)
        dg.addUint32(ctx)
        dg.addUint32(doId)
        self.send(dg)
Beispiel #19
0
 def kickChannel(self,
                 channel,
                 reason=1,
                 message='An unexpected problem has occured.'):
     dg = PyDatagram()
     dg.addServerHeader(channel, self.ourChannel, CLIENTAGENT_EJECT)
     dg.addUint16(reason)
     dg.addString(message)
     self.send(dg)
Beispiel #20
0
 def subscribe(self, avId, access):
     self.subscribed[avId] = access
     self.notify.info('Subscribed avatar %s with access %s' % (avId, access))
     
     dgcleanup = self.dclass.aiFormatUpdate("unsubscribe", self.doId, self.air.ourChannel, self.air.ourChannel, [avId])
     
     dg = PyDatagram()
     dg.addServerHeader(self.GetAccountConnectionChannel(self.avId), self.air.ourChannel, CLIENTAGENT_ADD_POST_REMOVE)
     dg.addString(dgcleanup.getMessage())
     self.air.send(dg)
Beispiel #21
0
def kick(reason = 'No reason specified'):
    target = spellbook.getTarget()
    if target == spellbook.getInvoker():
        return "You can't kick yourself!"
    datagram = PyDatagram()
    datagram.addServerHeader(target.GetPuppetConnectionChannel(target.doId), simbase.air.ourChannel, CLIENTAGENT_EJECT)
    datagram.addUint16(155)
    datagram.addString('You were kicked by a moderator for the following reason: %s' % reason)
    simbase.air.send(datagram)
    return 'Kicked %s from the game server!' % target.getName()
Beispiel #22
0
    def eject(self, clientChannel, reasonCode, reason):
        """
        Kicks the client residing at the specified clientChannel, using the specifed reasoning.
        """

        dg = PyDatagram()
        dg.addServerHeader(clientChannel, self.ourChannel, CLIENTAGENT_EJECT)
        dg.add_uint16(reasonCode)
        dg.addString(reason)
        self.send(dg)
Beispiel #23
0
    def setAI(self, doId, aiChannel):
        """
        Sets the AI of the specified DistributedObjectAI to be the specified channel.
        Generally, you should not call this method, and instead call DistributedObjectAI.setAI.
        """

        dg = PyDatagram()
        dg.addServerHeader(doId, aiChannel, STATESERVER_OBJECT_SET_AI)
        dg.add_uint64(aiChannel)
        self.send(dg)
Beispiel #24
0
    def setOwner(self, doId, newOwner):
        """
        Sets the owner of a DistributedObject. This will enable the new owner to send "ownsend" fields,
        and will generate an OwnerView.
        """

        dg = PyDatagram()
        dg.addServerHeader(doId, self.ourChannel, STATESERVER_OBJECT_SET_OWNER)
        dg.add_uint64(newOwner)
        self.send(dg)
Beispiel #25
0
 def deleteDistrict(self, districtId):
     assert self.notify.debugStateCall(self)
     # Create a message
     datagram = PyDatagram()
     datagram.addServerHeader(self.serverId, self.ourChannel, STATESERVER_OBJECT_DELETE_RAM)
     # The Id of the object in question
     datagram.addUint32(districtId)
     # Send the message
     self.send(datagram)
     # Make sure the message gets there.
     self.flush()
    def requestAccess(self):
        clientId = self.air.getMsgSender()
        
        self.air.setClientState(clientId, 2)

        dg = PyDatagram()
        dg.addServerHeader(clientId, self.air.ourChannel, CLIENTAGENT_OPEN_CHANNEL)
        dg.addChannel(self.GetPuppetConnectionChannel(clientId))
        self.air.send(dg)

        self.sendUpdateToChannel(clientId, 'accessResponse', [True])
    def sendMagicWord(self, word, targetId, execute):
        invokerId = self.air.getAvatarIdFromSender()

        invoker = self.air.doId2do.get(invokerId)
        now = time.strftime("%c")
        if not invoker:
            self.sendUpdateToAvatarId(invokerId, 'sendMagicWordResponse',
                                      ['missing invoker'])
            return

        if invoker.getAdminAccess() < MINIMUM_MAGICWORD_ACCESS:
            self.air.writeServerEvent(
                'suspicious',
                avId=invokerId,
                issue='Attempted to issue magic word: %s' % word)
            dg = PyDatagram()
            dg.addServerHeader(self.GetPuppetConnectionChannel(invokerId),
                               self.air.ourChannel, CLIENTAGENT_EJECT)
            dg.addUint16(126)
            dg.addString('Magic Words are reserved for administrators only!')
            self.air.send(dg)
            return

        target = self.air.doId2do.get(targetId)
        if not target:
            self.sendUpdateToAvatarId(invokerId, 'sendMagicWordResponse',
                                      ['missing target'])
            return

        if execute:
            response = spellbook.process(invoker, target, word)
            if response[0]:
                self.sendUpdateToAvatarId(invokerId, 'sendMagicWordResponse',
                                          [response[0]])
        else:
            response = ('Client MW executed.', )

        from otp.avatar.DistributedPlayerAI import DistributedPlayerAI
        targetAccess = 0 if not isinstance(
            target, DistributedPlayerAI) else target.getAdminAccess()

        self.air.writeServerEvent('magic-word',
                                  invokerId=invokerId,
                                  invokerAccess=invoker.getAdminAccess(),
                                  targetId=targetId,
                                  targetAccess=targetAccess,
                                  word=word,
                                  response=response[0])

        if not os.path.exists('backups/tools'):
            os.makedirs('backups/tools')

        with open("backups/tools/magic-words.altis", "a") as text_file:
            text_file.write("%s | %s : %s\n" % (now, invokerId, word))
    def _makeAvMsg(self, values, recipient):
        msg = "%s banned %s for %s hours: %s" % values
        
        msgDg = PyDatagram()
        msgDg.addUint16(6)
        msgDg.addString(msg)

        dg = PyDatagram()
        dg.addServerHeader(recipient, self.air.ourChannel, CLIENTAGENT_SEND_DATAGRAM)
        dg.addString(msgDg.getMessage())
        return dg
    def requestAccess(self):
        clientId = self.air.getMsgSender()
        
        self.air.setClientState(clientId, 2)

        dg = PyDatagram()
        dg.addServerHeader(clientId, self.air.ourChannel, CLIENTAGENT_OPEN_CHANNEL)
        dg.addChannel(self.GetPuppetConnectionChannel(clientId))
        self.air.send(dg)

        self.sendUpdateToChannel(clientId, 'accessResponse', [True])
Beispiel #30
0
    def setClientState(self, clientChannel, state):
        """
        Sets the state of the client on the CA.
        Useful for logging in and logging out, and for little else.
        """

        dg = PyDatagram()
        dg.addServerHeader(clientChannel, self.ourChannel,
                           CLIENTAGENT_SET_STATE)
        dg.add_uint16(state)
        self.send(dg)
Beispiel #31
0
 def addNewBan(self, avId, accountId, reason):
     datagram = PyDatagram()
     datagram.addServerHeader(self.GetPuppetConnectionChannel(avId), self.air.ourChannel, CLIENTAGENT_EJECT)
     datagram.addUint16(152)
     datagram.addString(str(reason))
     self.air.send(datagram)
     hwId = self.hwIdByAccountId[accountId]
     self.data = self.openFile(self.fileName)
     self.data['bans'][0][hwId] = {'accId': accountId, 'reason': reason}
     with open(self.fileName, 'w') as (file):
         json.dump(self.data, file, indent=4)
         file.close()
    def _makeAvMsg(self, values, recipient):
        msg = "%s banned %s for %s hours: %s" % values

        msgDg = PyDatagram()
        msgDg.addUint16(6)
        msgDg.addString(msg)

        dg = PyDatagram()
        dg.addServerHeader(recipient, self.air.ourChannel,
                           CLIENTAGENT_SEND_DATAGRAM)
        dg.addString(msgDg.getMessage())
        return dg
Beispiel #33
0
    def clientAddSessionObject(self, clientChannel, doId):
        """
        Declares the specified DistributedObject to be a "session object",
        meaning that it is destroyed when the client disconnects.
        Generally used for avatars owned by the client.
        """

        dg = PyDatagram()
        dg.addServerHeader(clientChannel, self.ourChannel,
                           CLIENTAGENT_ADD_SESSION_OBJECT)
        dg.add_uint32(doId)
        self.send(dg)
 def setFields(self, values):
     dg = PyDatagram()
     dg.addServerHeader(DBSERVER_ID, self.air.ourChannel, DBSERVER_SET_STORED_VALUES)
     dg.addUint32(self.doId)
     dg.addUint16(len(values))
     items = values.items()
     for (field, value) in items:
         dg.addString(field)
     
     for (field, value) in items:
         dg.addString(value.getMessage())
     
     self.air.send(dg)
 def setFields(self, values):
     dg = PyDatagram()
     dg.addServerHeader(DBSERVER_ID, self.air.ourChannel, DBSERVER_SET_STORED_VALUES)
     dg.addUint32(self.doId)
     dg.addUint16(len(values))
     items = values.items()
     for (field, value) in items:
         dg.addString(field)
     
     for (field, value) in items:
         dg.addString(value.getMessage())
     
     self.air.send(dg)
 def getFields(self, fields):
     context = self.air.dbObjContext
     self.air.dbObjContext += 1
     self.air.dbObjMap[context] = self
     dg = PyDatagram()
     dg.addServerHeader(DBSERVER_ID, self.air.ourChannel, DBSERVER_GET_STORED_VALUES)
     dg.addUint32(context)
     dg.addUint32(self.doId)
     dg.addUint16(len(fields))
     for f in fields:
         dg.addString(f)
     
     self.air.send(dg)
 def getFields(self, fields):
     context = self.air.dbObjContext
     self.air.dbObjContext += 1
     self.air.dbObjMap[context] = self
     dg = PyDatagram()
     dg.addServerHeader(DBSERVER_ID, self.air.ourChannel, DBSERVER_GET_STORED_VALUES)
     dg.addUint32(context)
     dg.addUint32(self.doId)
     dg.addUint16(len(fields))
     for f in fields:
         dg.addString(f)
     
     self.air.send(dg)
def kick(reason='No reason specified'):
    """
    Kick the target from the game server.
    """
    target = spellbook.getTarget()
    datagram = PyDatagram()
    datagram.addServerHeader(
        target.GetPuppetConnectionChannel(target.doId),
        simbase.air.ourChannel, CLIENTAGENT_EJECT)
    datagram.addUint16(155)
    datagram.addString('You were kicked by a moderator for the following reason: %s' % reason)
    simbase.air.send(datagram)
    return "Kicked %s from the game server!" % target.getName()
 def setAllowClientSend(self, avId, dObj, fieldNameList=[]):
     dg = PyDatagram()
     dg.addServerHeader(dObj.GetPuppetConnectionChannel(avId), self.ourChannel, CLIENTAGENT_SET_FIELDS_SENDABLE)
     fieldIds = []
     for fieldName in fieldNameList:
         field = dObj.dclass.getFieldByName(fieldName)
         if field:
             fieldIds.append(field.getNumber())
     dg.addUint32(dObj.getDoId())
     dg.addUint16(len(fieldIds))
     for fieldId in fieldIds:
         dg.addUint16(fieldId)
     self.send(dg)
Beispiel #40
0
    def ejectPlayer(self):
        av = self.air.doId2do.get(self.avId)
        if not av:
            return

        # Send the client a 'CLIENTAGENT_EJECT' with the players name.
        datagram = PyDatagram()
        datagram.addServerHeader(
                av.GetPuppetConnectionChannel(self.avId),
                self.air.ourChannel, CLIENTAGENT_EJECT)
        datagram.addUint16(152)
        datagram.addString(self.avName)
        simbase.air.send(datagram)
Beispiel #41
0
def kick(reason):
    """
    Kick the target from the game server.
    """
    target = spellbook.getTarget()
    if target == spellbook.getInvoker():
        return "You can't kick yourself!"
    datagram = PyDatagram()
    datagram.addServerHeader(
        target.GetPuppetConnectionChannel(target.doId),
        simbase.air.ourChannel, CLIENTAGENT_EJECT)
    datagram.addUint16(155)
    datagram.addString('You were kicked by a moderator for the following reason: "%s"\n\nBehave next time!' % reason)
    simbase.air.send(datagram)
    return "Kicked %s from the game server!" % target.getName()
    def rpc_kickChannel(self, channel, code, reason):
        """
        Summary:
            Kicks any client whose Client Agent is subscribed to the provided
            [channel].

        Parameters:
            [int channel] = The channel to kick.
            [int code] = The code for the kick.
            [str reason] = The reason for the kick.
        """
        datagram = PyDatagram()
        datagram.addServerHeader(channel, self.air.ourChannel, CLIENTAGENT_EJECT)
        datagram.addUint16(code)
        datagram.addString(reason)
        self.air.send(datagram)
Beispiel #43
0
    def requestPlayer(self, name, color):
        clientId = self.air.getAvatarIdFromSender()

        player = TagPlayerAI(self.air)
        player.setName(name)
        player.setColor(color)
        player.setGameId(self.doId)
        player.generateWithRequired(self.objZone)

        self.air.setOwner(player.doId, clientId)

        self.air.clientAddSessionObject(clientId, player.doId)

        dg = PyDatagram()
        dg.addServerHeader(clientId, self.air.ourChannel, CLIENTAGENT_SET_CLIENT_ID)
        dg.addChannel(self.GetPuppetConnectionChannel(player.doId))
        self.air.send(dg)

        self.newPlayer(player)
Beispiel #44
0
    def requestJoin(self, name):
        sender = self.air.getMsgSender()
        for avatar in self.air.avatars:
            if avatar.name == name:
                # The name is taken, so let's tell
                # the client that.
                self.sendUpdateToChannel(sender, 'nameOccupied', [])
                return
        ralph = RalphAI(self.air)
        ralph.setName(name)
        ralph.generateWithRequired(0)
        self.air.setOwner(ralph.doId, sender)
        self.air.clientAddSessionObject(sender, ralph.doId)

        dg = PyDatagram()
        dg.addServerHeader(sender, self.air.ourChannel, CLIENTAGENT_SET_CLIENT_ID)
        dg.addChannel(self.GetPuppetConnectionChannel(ralph.doId))
        self.air.send(dg)

        self.air.avatars.append(ralph)
 def setAvatar(self, fields, avId, sender):
     accId = self.GetAccountConnectionChannel(sender)
     dgc = PyDatagram()
     dgc.addServerHeader(avId, accId, STATESERVER_OBJECT_DELETE_RAM)
     dgc.addUint32(avId)
     dg = PyDatagram()
     dg.addServerHeader(accId, self.air.ourChannel, CLIENTAGENT_ADD_POST_REMOVE)
     dg.addString(dgc.getMessage())
     self.air.send(dg)
     self.air.sendActivate(avId, 0, 0, self.air.dclassesByName['DistributedToonUD'])
     dg = PyDatagram()
     dg.addServerHeader(accId, self.air.ourChannel, CLIENTAGENT_OPEN_CHANNEL)
     dg.addChannel(self.GetPuppetConnectionChannel(avId))
     self.air.send(dg)
     dg = PyDatagram()
     dg.addServerHeader(accId, self.air.ourChannel, CLIENTAGENT_SET_CLIENT_ID)
     dg.addChannel(sender << 32 | avId)
     self.air.send(dg)
     dg = PyDatagram()
     dg.addServerHeader(avId, self.air.ourChannel, STATESERVER_OBJECT_SET_OWNER)
     dg.addChannel(sender << 32 | avId)
     self.air.send(dg)
    def sendMagicWord(self, word, targetId, execute):
        invokerId = self.air.getAvatarIdFromSender()

        invoker = self.air.doId2do.get(invokerId)
        if not invoker:
            self.sendUpdateToAvatarId(invokerId, 'sendMagicWordResponse', ['missing invoker'])
            return

        if invoker.getAdminAccess() < MINIMUM_MAGICWORD_ACCESS:
            self.air.writeServerEvent('suspicious', avId=invokerId, issue='Attempted to issue magic word: %s' % word)
            dg = PyDatagram()
            dg.addServerHeader(self.GetPuppetConnectionChannel(invokerId), self.air.ourChannel, CLIENTAGENT_EJECT)
            dg.addUint16(126)
            dg.addString('Magic Words are reserved for administrators only!')
            self.air.send(dg)
            return

        target = self.air.doId2do.get(targetId)
        if not target:
            self.sendUpdateToAvatarId(invokerId, 'sendMagicWordResponse', ['missing target'])
            return
        
        if execute:
            response = spellbook.process(invoker, target, word)
            if response[0]:
                self.sendUpdateToAvatarId(invokerId, 'sendMagicWordResponse', [response[0]])
        else:
            response = ('Client MW executed.',)
            
        from otp.avatar.DistributedPlayerAI import DistributedPlayerAI
        targetAccess = 0 if not isinstance(target, DistributedPlayerAI) else target.getAdminAccess()

        self.air.writeServerEvent('magic-word',
                                  invokerId=invokerId, invokerAccess=invoker.getAdminAccess(),
                                  targetId=targetId, targetAccess=targetAccess,
                                  word=word, response=response[0])
 def unloadAvatar(self, target, doId):
     channel = self.GetAccountConnectionChannel(target)
     dg = PyDatagram()
     dg.addServerHeader(channel, self.air.ourChannel, CLIENTAGENT_CLEAR_POST_REMOVES)
     self.air.send(dg)
     dg = PyDatagram()
     dg.addServerHeader(channel, self.air.ourChannel, CLIENTAGENT_CLOSE_CHANNEL)
     dg.addChannel(self.GetPuppetConnectionChannel(doId))
     self.air.send(dg)
     dg = PyDatagram()
     dg.addServerHeader(channel, self.air.ourChannel, CLIENTAGENT_SET_CLIENT_ID)
     dg.addChannel(doId << 32)
     self.air.send(dg)
     dg = PyDatagram()
     dg.addServerHeader(doId, channel, STATESERVER_OBJECT_DELETE_RAM)
     dg.addUint32(doId)
     self.air.send(dg)
 def setAccount(self, sender, accountId):
     print 'setAccount: accountId = %s' % accountId
     dg = PyDatagram()
     dg.addServerHeader(self.GetAccountConnectionChannel(accountId), self.air.ourChannel, CLIENTAGENT_EJECT)
     dg.addUint16(EC_MULTIPLE_LOGINS)
     dg.addString('This account is already logged in.')
     self.air.send(dg)
     dg = PyDatagram()
     dg.addServerHeader(sender, self.air.ourChannel, CLIENTAGENT_OPEN_CHANNEL)
     dg.addChannel(self.GetAccountConnectionChannel(accountId))
     self.air.send(dg)
     dg = PyDatagram()
     dg.addServerHeader(sender, self.air.ourChannel, CLIENTAGENT_SET_CLIENT_ID)
     dg.addChannel(accountId << 32)
     self.air.send(dg)
     self.unsandboxClient(sender)
     self.d_loginAccepted(sender)
     self.notify.info('Successfully created a new account object.')
 def prepare(self, message, sentArgs=[]):
     dg = PyDatagram()
     dg.addServerHeader(self.msgChannel, self.air.ourChannel, self.msgType)
     dg.addString(message)
     dg.addString(zlib.compress(cPickle.dumps(sentArgs)))
     return dg
 def claimOwnership(self, channel):
     dg = PyDatagram()
     dg.addServerHeader(channel, self.ourChannel, STATESERVER_OBJECT_SET_AI)
     dg.addChannel(self.ourChannel)
     self.send(dg)
Beispiel #51
0
 def unregister_for_channel(self, channel):
     datagram = PyDatagram()
     datagram.addServerHeader(channel, channel, CONTROL_REMOVE_CHANNEL)
     self.cw.send(datagram, self.tcp_conn)
 def unsandboxClient(self, sender):
     dg = PyDatagram()
     dg.addServerHeader(sender, self.air.ourChannel, CLIENTAGENT_SET_STATE)
     dg.addUint16(2)
     self.air.send(dg)