From a1a22a2f1034a1feb67b141abf4b138248cdb356 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 28 Jun 2012 22:02:20 +0100 Subject: [PATCH] Revert "Mantis 5977 Corrections to llRegionSayTo" This reverts commit 679da63da617d031e5e7ae3f2d2a29db1a23ace3. Conflicts: OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs --- OpenSim/Framework/OSChatMessage.cs | 20 ----- .../CoreModules/Avatar/Chat/ChatModule.cs | 50 ++++-------- .../Scripting/WorldComm/WorldCommModule.cs | 78 +++++++++---------- .../Region/Framework/Interfaces/IWorldComm.cs | 2 +- .../Framework/Scenes/Scene.PacketHandlers.cs | 26 +------ .../Shared/Api/Implementation/LSL_Api.cs | 10 +-- 6 files changed, 63 insertions(+), 123 deletions(-) diff --git a/OpenSim/Framework/OSChatMessage.cs b/OpenSim/Framework/OSChatMessage.cs index 455756db71..54fa2756d2 100644 --- a/OpenSim/Framework/OSChatMessage.cs +++ b/OpenSim/Framework/OSChatMessage.cs @@ -51,12 +51,10 @@ namespace OpenSim.Framework protected object m_senderObject; protected ChatTypeEnum m_type; protected UUID m_fromID; - protected UUID m_toID; public OSChatMessage() { m_position = new Vector3(); - m_toID = UUID.Zero; } /// @@ -104,15 +102,6 @@ namespace OpenSim.Framework set { m_from = value; } } - /// - /// The name of the sender (needed for scripts) - /// - public string To - { - get { return m_from; } - set { m_from = value; } - } - #region IEventArgs Members /// TODO: Sender and SenderObject should just be Sender and of @@ -142,15 +131,6 @@ namespace OpenSim.Framework set { m_fromID = value; } } - /// - /// The single recipient or all if not set. - /// - public UUID TargetUUID - { - get { return m_toID; } - set { m_toID = value; } - } - /// /// /// diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index 6ffc7e61ff..56498551c1 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs @@ -197,7 +197,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat string fromName = c.From; string fromNamePrefix = ""; UUID fromID = UUID.Zero; - UUID targetID = c.TargetUUID; string message = c.Message; IScene scene = c.Scene; Vector3 fromPos = c.Position; @@ -236,31 +235,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat message = message.Substring(0, 1000); // m_log.DebugFormat( -// "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}, targetID {5}", -// fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType, targetID); +// "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}", +// fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType); HashSet receiverIDs = new HashSet(); - + foreach (Scene s in m_scenes) { - if (targetID == UUID.Zero) - { - // This should use ForEachClient, but clients don't have a position. - // If camera is moved into client, then camera position can be used - s.ForEachRootScenePresence( - delegate(ScenePresence presence) - { - if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType, false)) - receiverIDs.Add(presence.UUID); - } - ); - } - else - { - // This is a send to a specific client eg from llRegionSayTo - // no need to check distance etc, jand send is as say - ScenePresence presence = s.GetScenePresence(targetID); - if (presence != null && !presence.IsChildAgent) + // This should use ForEachClient, but clients don't have a position. + // If camera is moved into client, then camera position can be used + s.ForEachRootScenePresence( + delegate(ScenePresence presence) { ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y); if (Presencecheck != null) @@ -271,14 +256,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat // objects on a parcel with access restrictions if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true) { - if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromNamePrefix + fromName, c.Type, message, sourceType, false)) + if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromNamePrefix + fromName, c.Type, message, sourceType)) receiverIDs.Add(presence.UUID); } } } - } + ); } - + (scene as Scene).EventManager.TriggerOnChatToClients( fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); } @@ -358,7 +343,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat /// precondition protected virtual bool TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos, UUID fromAgentID, string fromName, ChatTypeEnum type, - string message, ChatSourceType src, bool ignoreDistance) + string message, ChatSourceType src) { // don't send stuff to child agents if (presence.IsChildAgent) return false; @@ -369,15 +354,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos); - - if (!ignoreDistance) + + if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance || + type == ChatTypeEnum.Say && dis > m_saydistance || + type == ChatTypeEnum.Shout && dis > m_shoutdistance) { - if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance || - type == ChatTypeEnum.Say && dis > m_saydistance || - type == ChatTypeEnum.Shout && dis > m_shoutdistance) - { - return false; - } + return false; } // TODO: should change so the message is sent through the avatar rather than direct to the ClientView diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index 8358bc0c64..176c86de12 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs @@ -308,56 +308,56 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm /// /// Message. /// - public void DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg) + public bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error) { + error = null; // Is id an avatar? ScenePresence sp = m_scene.GetScenePresence(target); if (sp != null) { - // ignore if a child agent this is restricted to inside one region - if (sp.IsChildAgent) - return; - - // Send message to the avatar. - // Channel zero only goes to the avatar - // non zero channel messages only go to the attachments + // Send message to avatar if (channel == 0) { - m_scene.SimChatToAgent(target, Utils.StringToBytes(msg), pos, name, id, false); - } - else - { - List attachments = sp.GetAttachments(); - if (attachments.Count == 0) - return; - - // Get uuid of attachments - List targets = new List(); - foreach (SceneObjectGroup sog in attachments) - { - if (!sog.IsDeleted) - targets.Add(sog.UUID); - } - - // Need to check each attachment - foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) - { - if (li.GetHostID().Equals(id)) - continue; - - if (m_scene.GetSceneObjectPart(li.GetHostID()) == null) - continue; - - if (targets.Contains(li.GetHostID())) - QueueMessage(new ListenerInfo(li, name, id, msg)); - } + m_scene.SimChatBroadcast(Utils.StringToBytes(msg), ChatTypeEnum.Broadcast, 0, pos, name, id, false); } - return; + List attachments = sp.GetAttachments(); + + if (attachments.Count == 0) + return true; + + // Get uuid of attachments + List targets = new List(); + foreach (SceneObjectGroup sog in attachments) + { + if (!sog.IsDeleted) + targets.Add(sog.UUID); + } + + // Need to check each attachment + foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) + { + if (li.GetHostID().Equals(id)) + continue; + + if (m_scene.GetSceneObjectPart(li.GetHostID()) == null) + continue; + + if (targets.Contains(li.GetHostID())) + QueueMessage(new ListenerInfo(li, name, id, msg)); + } + + return true; + } + + // Need to toss an error here + if (channel == 0) + { + error = "Cannot use llRegionSayTo to message objects on channel 0"; + return false; } - // No avatar found so look for an object foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) { // Dont process if this message is from yourself! @@ -375,7 +375,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm } } - return; + return true; } protected void QueueMessage(ListenerInfo li) diff --git a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs index 4e74781b9b..e8e375e037 100644 --- a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs +++ b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs @@ -103,7 +103,7 @@ namespace OpenSim.Region.Framework.Interfaces /// /// Message. /// - void DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg); + bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error); /// /// Are there any listen events ready to be dispatched? diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index cf68ff4273..3ef1e29782 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -38,9 +38,8 @@ namespace OpenSim.Region.Framework.Scenes { public partial class Scene { - protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, - UUID fromID, UUID targetID, bool fromAgent, bool broadcast) + UUID fromID, bool fromAgent, bool broadcast) { OSChatMessage args = new OSChatMessage(); @@ -64,20 +63,14 @@ namespace OpenSim.Region.Framework.Scenes } args.From = fromName; - args.TargetUUID = targetID; + //args. if (broadcast) EventManager.TriggerOnChatBroadcast(this, args); else EventManager.TriggerOnChatFromWorld(this, args); } - - protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, - UUID fromID, bool fromAgent, bool broadcast) - { - SimChat(message, type, channel, fromPos, fromName, fromID, UUID.Zero, fromAgent, broadcast); - } - + /// /// /// @@ -115,19 +108,6 @@ namespace OpenSim.Region.Framework.Scenes { SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true); } - /// - /// - /// - /// - /// - /// - /// - /// - /// - public void SimChatToAgent(UUID targetID, byte[] message, Vector3 fromPos, string fromName, UUID fromID, bool fromAgent) - { - SimChat(message, ChatTypeEnum.Say, 0, fromPos, fromName, fromID, targetID, fromAgent, false); - } /// /// Invoked when the client requests a prim. diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 41de257b32..ffa19d9fb6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -921,22 +921,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llRegionSayTo(string target, int channel, string msg) { + string error = String.Empty; + if (msg.Length > 1023) msg = msg.Substring(0, 1023); m_host.AddScriptLPS(1); - if (channel == ScriptBaseClass.DEBUG_CHANNEL) - { - return; - } - UUID TargetID; UUID.TryParse(target, out TargetID); IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); if (wComm != null) - wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg); + if (!wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg, out error)) + LSLError(error); } public LSL_Integer llListen(int channelID, string name, string ID, string msg)