Exemplo n.º 1
0
        public void BlacklistOperation(BlacklistOp operation, string param, string param2)
        {
            if (blacklistRunning)
            {
                return;
            }

            // In cases where both are supported, if targetName is empty, targetID is used.
            string targetName = param;
            UUID   targetID   = UUID.Zero;

            try
            {
                blacklistRunning = true;
                bool nukeObjects;

                // BlacklistTarget.User is like BlacklistTarget.Owner except that it also prevents the user from entering the region.
                switch (operation)
                {
                case BlacklistOp.User:
                case BlacklistOp.Owner:
                    // accepts either UUID or First Last
                    if (param2 == string.Empty)
                    {
                        if (!UUID.TryParse(param, out targetID))
                        {
                            m_log.Warn("You must specify either a UUID or name (First Last).");
                            return;
                        }
                    }
                    else
                    {
                        // name was specified
                        UserProfileData profile = m_localScenes[0].CommsManager.UserService.GetUserProfile(param, param2);
                        if (profile == null)
                        {
                            m_log.WarnFormat("Could not find a user named '{0} {1}'.", param, param2);
                            return;
                        }
                        targetID = profile.ID;
                    }
                    nukeObjects = true;
                    break;

                case BlacklistOp.Creator:
                    if (!UUID.TryParse(param, out targetID))
                    {
                        m_log.Warn("That command requires a UUID.");
                        return;
                    }
                    nukeObjects = true;
                    break;

                case BlacklistOp.Name:
                    targetName  = param.Trim();
                    nukeObjects = true;
                    break;

                case BlacklistOp.Remove:
                    if (UUID.TryParse(param, out targetID))
                    {
                        targetName = string.Empty;
                    }
                    else
                    {
                        targetID = UUID.Zero;
                    }
                    nukeObjects = false;
                    break;

                case BlacklistOp.Clear:
                case BlacklistOp.Show:
                    // nothing to parse
                    nukeObjects = false;
                    break;

                default:
                    return;
                }

                foreach (Scene scene in m_localScenes)
                {
                    if (operation == BlacklistOp.Show)
                    {
                        scene.BlacklistShow();
                        return;
                    }

                    switch (operation)
                    {
                    case BlacklistOp.Creator:
                        scene.AddBlacklistedCreator(targetID);
                        break;

                    case BlacklistOp.Owner:
                        scene.AddBlacklistedOwner(targetID);
                        // also temporarily stop further rezzing including attaches.
                        scene.AddBadUser(targetID);
                        break;

                    case BlacklistOp.Name:
                        scene.AddBlacklistedName(targetName);
                        break;

                    case BlacklistOp.User:
                        scene.AddBlacklistedUser(targetID);
                        break;

                    case BlacklistOp.Remove:
                        if (targetName != string.Empty)
                        {
                            scene.BlacklistRemove(targetName);
                        }
                        else
                        {
                            scene.BlacklistRemove(targetID);
                        }
                        break;

                    case BlacklistOp.Clear:
                        scene.BlacklistClear();
                        break;
                    }

                    if (nukeObjects)
                    {
                        // first disable physics to ensure CPU is available
                        bool usePhysics = scene.PhysicsScene.Simulating;
                        scene.PhysicsScene.Simulating = false;

                        try
                        {
                            List <EntityBase> EntityList = scene.GetEntities();
                            foreach (EntityBase ent in EntityList)
                            {
                                if (ent is SceneObjectGroup)
                                {
                                    SceneObjectGroup SOG   = (SceneObjectGroup)ent;
                                    bool             match = false;
                                    switch (operation)
                                    {
                                    case BlacklistOp.Creator:
                                        SOG.ForEachPart(delegate(SceneObjectPart part)
                                        {
                                            match |= (part.CreatorID == targetID);
                                        });
                                        break;

                                    case BlacklistOp.Owner:
                                    case BlacklistOp.User:
                                        match = (SOG.OwnerID == targetID);
                                        break;

                                    case BlacklistOp.Name:
                                        match = SOG.Name.Trim().StartsWith(targetName, StringComparison.InvariantCultureIgnoreCase);
                                        break;
                                    }
                                    if (match)
                                    {
                                        scene.DeleteSceneObject(SOG, false, false, true);
                                    }
                                }
                            }
                        }
                        finally
                        {
                            // don't force a region restart to reenable... and restore physics
                            scene.PhysicsScene.Simulating = usePhysics;
                        }
                    }
                }
            }
            finally
            {
                blacklistRunning = false;
            }
        }
Exemplo n.º 2
0
        public void BlacklistOperation(BlacklistOp operation, string param, string param2)
        {
            if (blacklistRunning) return;

            // In cases where both are supported, if targetName is empty, targetID is used.
            string targetName = param;
            UUID targetID = UUID.Zero;

            try
            {
                blacklistRunning = true;
                bool nukeObjects;

                // BlacklistTarget.User is like BlacklistTarget.Owner except that it also prevents the user from entering the region.
                switch (operation)
                {
                    case BlacklistOp.User:
                    case BlacklistOp.Owner:
                        // accepts either UUID or First Last
                        if (param2 == string.Empty)
                        {
                            if (!UUID.TryParse(param, out targetID))
                            {
                                m_log.Warn("You must specify either a UUID or name (First Last).");
                                return;
                            }
                        }
                        else
                        {
                            // name was specified
                            UserProfileData profile = m_localScenes[0].CommsManager.UserService.GetUserProfile(param, param2);
                            if (profile == null)
                            {
                                m_log.WarnFormat("Could not find a user named '{0} {1}'.", param, param2);
                                return;
                            }
                            targetID = profile.ID;
                        }
                        nukeObjects = true;
                        break;
                    case BlacklistOp.Creator:
                        if (!UUID.TryParse(param, out targetID))
                        {
                            m_log.Warn("That command requires a UUID.");
                            return;
                        }
                        nukeObjects = true;
                        break;
                    case BlacklistOp.Name:
                        targetName = param.Trim();
                        nukeObjects = true;
                        break;
                    case BlacklistOp.Remove:
                        if (UUID.TryParse(param, out targetID))
                        {
                            targetName = string.Empty;
                        }
                        else
                        {
                            targetID = UUID.Zero;
                        }
                        nukeObjects = false;
                        break;
                    case BlacklistOp.Clear:
                    case BlacklistOp.Show:
                        // nothing to parse
                        nukeObjects = false;
                        break;
                    default:
                        return;
                }

                foreach (Scene scene in m_localScenes)
                {
                    if (operation == BlacklistOp.Show)
                    {
                        scene.BlacklistShow();
                        return;
                    }

                    switch (operation) 
                    {
                        case BlacklistOp.Creator:
                            scene.AddBlacklistedCreator(targetID);
                            break;
                        case BlacklistOp.Owner:
                            scene.AddBlacklistedOwner(targetID);
                            // also temporarily stop further rezzing including attaches.
                            scene.AddBadUser(targetID);
                            break;
                        case BlacklistOp.Name:
                            scene.AddBlacklistedName(targetName);
                            break;
                        case BlacklistOp.User:
                            scene.AddBlacklistedUser(targetID);
                            break;
                        case BlacklistOp.Remove:
                            if (targetName != string.Empty)
                                scene.BlacklistRemove(targetName);
                            else
                                scene.BlacklistRemove(targetID);
                            break;
                        case BlacklistOp.Clear:
                            scene.BlacklistClear();
                            break;
                    }

                    if (nukeObjects)
                    {
                        // first disable physics to ensure CPU is available
                        bool usePhysics = scene.PhysicsScene.Simulating;
                        scene.PhysicsScene.Simulating = false;

                        try
                        {
                            List<EntityBase> EntityList = scene.GetEntities();
                            foreach (EntityBase ent in EntityList)
                            {
                                if (ent is SceneObjectGroup)
                                {
                                    SceneObjectGroup SOG = (SceneObjectGroup)ent;
                                    bool match = false;
                                    switch (operation)
                                    {
                                        case BlacklistOp.Creator:
                                            SOG.ForEachPart(delegate(SceneObjectPart part)
                                                {
                                                    match |= (part.CreatorID == targetID);
                                                });
                                            break;
                                        case BlacklistOp.Owner:
                                        case BlacklistOp.User:
                                            match = (SOG.OwnerID == targetID);
                                            break;
                                        case BlacklistOp.Name:
                                            match = SOG.Name.Trim().StartsWith(targetName, StringComparison.InvariantCultureIgnoreCase);
                                            break;
                                    }
                                    if (match)
                                        scene.DeleteSceneObject(SOG, false, false, true);
                                }
                            }
                        }
                        finally
                        {
                            // don't force a region restart to reenable... and restore physics
                            scene.PhysicsScene.Simulating = usePhysics;
                        }
                    }
                }
            }
            finally
            {
                blacklistRunning = false;
            }
        }