Пример #1
0
        protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
        {
            string fromName = c.From;
            string fromNamePrefix = "";
            UUID fromID = UUID.Zero;
            UUID ownerID = UUID.Zero;
            string message = c.Message;
            Scene scene = c.Scene as Scene;
            UUID destination = c.Destination;
            Vector3 fromPos = c.Position;
            Vector3 regionPos = new Vector3(scene.RegionInfo.WorldLocX, scene.RegionInfo.WorldLocY, 0);

            bool checkParcelHide = false;
            UUID sourceParcelID = UUID.Zero;
            Vector3 hidePos = fromPos;

            if (c.Channel == DEBUG_CHANNEL) c.Type = ChatTypeEnum.DebugChannel;

            if(!m_scenes.Contains(scene))
            {
                m_log.WarnFormat("[CHAT]: message from unkown scene {0} ignored",
                                     scene.RegionInfo.RegionName);
                return;
            }

            switch (sourceType)
            {
                case ChatSourceType.Agent:
                    ScenePresence avatar = (scene as Scene).GetScenePresence(c.Sender.AgentId);
                    fromPos = avatar.AbsolutePosition;
                    fromName = avatar.Name;
                    fromID = c.Sender.AgentId;
                    if (avatar.IsViewerUIGod)
                    { // let gods speak to outside or things may get confusing
                        fromNamePrefix = m_adminPrefix;
                        checkParcelHide = false;
                    }
                    else
                    {
                        checkParcelHide = true;
                    }
                    destination = UUID.Zero; // Avatars cant "SayTo"
                    ownerID = c.Sender.AgentId;

                    hidePos = fromPos;
                    break;

                case ChatSourceType.Object:
                    fromID = c.SenderUUID;

                    if (c.SenderObject != null && c.SenderObject is SceneObjectPart)
                    {
                        ownerID = ((SceneObjectPart)c.SenderObject).OwnerID;
                        if (((SceneObjectPart)c.SenderObject).ParentGroup.IsAttachment)
                        {
                            checkParcelHide = true;
                            hidePos = ((SceneObjectPart)c.SenderObject).ParentGroup.AbsolutePosition;
                        }
                    }
                    break;
            }

            // TODO: iterate over message
            if (message.Length >= 1000) // libomv limit
                message = message.Substring(0, 1000);

//            m_log.DebugFormat(
//                "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}",
//                fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType);

            HashSet<UUID> receiverIDs = new HashSet<UUID>();

            if (checkParcelHide)
            {
                checkParcelHide = false;
                if (c.Type < ChatTypeEnum.DebugChannel && destination == UUID.Zero)
                {
                    ILandObject srcland = scene.LandChannel.GetLandObject(hidePos.X, hidePos.Y);
                    if (srcland != null && !srcland.LandData.SeeAVs)
                    {
                        sourceParcelID = srcland.LandData.GlobalID;
                        checkParcelHide = true;
                    }
                }
            }

            scene.ForEachScenePresence(
                delegate(ScenePresence presence)
                {
                    if (destination != UUID.Zero && presence.UUID != destination)
                        return;

                    if(presence.IsChildAgent)
                        {
                            if(checkParcelHide)
                                return;
                            if (TrySendChatMessage(presence, fromPos, regionPos, fromID,
                                        ownerID, fromNamePrefix + fromName, c.Type,
                                        message, sourceType, (destination != UUID.Zero)))
                                receiverIDs.Add(presence.UUID);
                            return;
                        }

                    ILandObject Presencecheck = scene.LandChannel.GetLandObject(presence.AbsolutePosition.X,            presence.AbsolutePosition.Y);
                    if (Presencecheck != null)
                    {
                        if (checkParcelHide)
                        {
                            if (sourceParcelID != Presencecheck.LandData.GlobalID && !presence.IsViewerUIGod)
                                return;
                        }
                        if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true)
                        {
                            if (TrySendChatMessage(presence, fromPos, regionPos, fromID,
                                        ownerID, fromNamePrefix + fromName, c.Type,
                                        message, sourceType, (destination != UUID.Zero)))
                                receiverIDs.Add(presence.UUID);
                        }
                    }
                });

            scene.EventManager.TriggerOnChatToClients(
                fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully);
        }
Пример #2
0
        public void EnforceBans(ILandObject land, ScenePresence avatar)
        {
            if (avatar.AbsolutePosition.Z > LandChannel.BAN_LINE_SAFETY_HIEGHT)
                return;

            if (land.IsEitherBannedOrRestricted(avatar.UUID))
            {
                if (land.ContainsPoint(Convert.ToInt32(avatar.lastKnownAllowedPosition.X), Convert.ToInt32(avatar.lastKnownAllowedPosition.Y)))
                {
                    Vector3? pos = m_scene.GetNearestAllowedPosition(avatar);
                    if (pos == null)
                        m_scene.TeleportClientHome(avatar.UUID, avatar.ControllingClient);
                    else
                        ForceAvatarToPosition(avatar, (Vector3)pos);
                }
                else
                {
                    ForceAvatarToPosition(avatar, avatar.lastKnownAllowedPosition);
                }
            }
        } 
        public void UpdateLandObject(ILandObject lo)
        {
            AddLandObjectToSearch(lo);
            m_scene.EventManager.TriggerLandObjectAdded(lo.LandData);

            foreach (IScenePresence sp in m_scene.GetScenePresences())
            {
                if (sp.CurrentParcelUUID == lo.LandData.GlobalID)
                {
                    if (lo.IsEitherBannedOrRestricted(sp.UUID))
                    {
                        SendYouAreRestrictedNotice(sp);
                        Vector3 pos = GetNearestAllowedPosition(sp);
                        pos.Z -= sp.PhysicsActor.Size.Z;
                        sp.Teleport(pos);
                    }
                }
            }
        }
Пример #4
0
        protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
        {
            string  fromName       = c.From;
            string  fromNamePrefix = "";
            UUID    fromID         = UUID.Zero;
            UUID    ownerID        = UUID.Zero;
            string  message        = c.Message;
            IScene  scene          = c.Scene;
            UUID    destination    = c.Destination;
            Vector3 fromPos        = c.Position;
            Vector3 regionPos      = new Vector3(scene.RegionInfo.WorldLocX, scene.RegionInfo.WorldLocY, 0);

            bool    checkParcelHide = false;
            UUID    sourceParcelID  = UUID.Zero;
            Vector3 hidePos         = fromPos;

            if (c.Channel == DEBUG_CHANNEL)
            {
                c.Type = ChatTypeEnum.DebugChannel;
            }

            switch (sourceType)
            {
            case ChatSourceType.Agent:
                if (!(scene is Scene))
                {
                    m_log.WarnFormat("[CHAT]: scene {0} is not a Scene object, cannot obtain scene presence for {1}",
                                     scene.RegionInfo.RegionName, c.Sender.AgentId);
                    return;
                }
                ScenePresence avatar = (scene as Scene).GetScenePresence(c.Sender.AgentId);
                fromPos  = avatar.AbsolutePosition;
                fromName = avatar.Name;
                fromID   = c.Sender.AgentId;
                if (avatar.GodLevel >= 200)
                { // let gods speak to outside or things may get confusing
                    fromNamePrefix  = m_adminPrefix;
                    checkParcelHide = false;
                }
                else
                {
                    checkParcelHide = true;
                }
                destination = UUID.Zero; // Avatars cant "SayTo"
                ownerID     = c.Sender.AgentId;

                hidePos = fromPos;
                break;

            case ChatSourceType.Object:
                fromID = c.SenderUUID;

                if (c.SenderObject != null && c.SenderObject is SceneObjectPart)
                {
                    ownerID = ((SceneObjectPart)c.SenderObject).OwnerID;
                    if (((SceneObjectPart)c.SenderObject).ParentGroup.IsAttachment)
                    {
                        checkParcelHide = true;
                        hidePos         = ((SceneObjectPart)c.SenderObject).ParentGroup.AbsolutePosition;
                    }
                }
                break;
            }

            // TODO: iterate over message
            if (message.Length >= 1000) // libomv limit
            {
                message = message.Substring(0, 1000);
            }

//            m_log.DebugFormat(
//                "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}",
//                fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType);

            HashSet <UUID> receiverIDs = new HashSet <UUID>();

            if (checkParcelHide)
            {
                checkParcelHide = false;
                if (c.Type < ChatTypeEnum.DebugChannel && destination == UUID.Zero)
                {
                    ILandObject srcland = (scene as Scene).LandChannel.GetLandObject(hidePos.X, hidePos.Y);
                    if (srcland != null && !srcland.LandData.SeeAVs)
                    {
                        sourceParcelID  = srcland.LandData.GlobalID;
                        checkParcelHide = true;
                    }
                }
            }

            foreach (Scene s in m_scenes)
            {
                // This should use ForEachClient, but clients don't have a position.
                // If camera is moved into client, then camera position can be used
                // MT: No, it can't, as chat is heard from the avatar position, not
                // the camera position.

                s.ForEachScenePresence(
                    delegate(ScenePresence presence)
                {
                    if (destination != UUID.Zero && presence.UUID != destination)
                    {
                        return;
                    }
                    ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y);
                    if (Presencecheck != null)
                    {
                        // This will pass all chat from objects. Not
                        // perfect, but it will do. For now. Better
                        // than the prior behavior of muting all
                        // objects on a parcel with access restrictions
                        if (checkParcelHide)
                        {
                            if (sourceParcelID != Presencecheck.LandData.GlobalID && presence.GodLevel < 200)
                            {
                                return;
                            }
                        }
                        if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true)
                        {
                            if (TrySendChatMessage(presence, fromPos, regionPos, fromID,
                                                   ownerID, fromNamePrefix + fromName, c.Type,
                                                   message, sourceType, (destination != UUID.Zero)))
                            {
                                receiverIDs.Add(presence.UUID);
                            }
                        }
                    }
                    else if (!checkParcelHide && (presence.IsChildAgent))
                    {
                        if (TrySendChatMessage(presence, fromPos, regionPos, fromID,
                                               ownerID, fromNamePrefix + fromName, c.Type,
                                               message, sourceType, (destination != UUID.Zero)))
                        {
                            receiverIDs.Add(presence.UUID);
                        }
                    }
                }
                    );
            }

            (scene as Scene).EventManager.TriggerOnChatToClients(
                fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully);
        }