aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorTalun2012-04-22 23:07:50 +0100
committerBlueWall2012-04-23 07:16:33 -0400
commit679da63da617d031e5e7ae3f2d2a29db1a23ace3 (patch)
tree3feb83235a10b67ed068fb69de74d3c005b7a717
parentrefactor: simply some properties code in BasicPhysicsPlugin (diff)
downloadopensim-SC_OLD-679da63da617d031e5e7ae3f2d2a29db1a23ace3.zip
opensim-SC_OLD-679da63da617d031e5e7ae3f2d2a29db1a23ace3.tar.gz
opensim-SC_OLD-679da63da617d031e5e7ae3f2d2a29db1a23ace3.tar.bz2
opensim-SC_OLD-679da63da617d031e5e7ae3f2d2a29db1a23ace3.tar.xz
Mantis 5977 Corrections to llRegionSayTo
Signed-off-by: BlueWall <jamesh@bluewallgroup.com>
-rw-r--r--OpenSim/Framework/OSChatMessage.cs20
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs52
-rw-r--r--OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs70
-rw-r--r--OpenSim/Region/Framework/Interfaces/IWorldComm.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs26
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs8
6 files changed, 120 insertions, 58 deletions
diff --git a/OpenSim/Framework/OSChatMessage.cs b/OpenSim/Framework/OSChatMessage.cs
index 54fa275..455756d 100644
--- a/OpenSim/Framework/OSChatMessage.cs
+++ b/OpenSim/Framework/OSChatMessage.cs
@@ -51,10 +51,12 @@ namespace OpenSim.Framework
51 protected object m_senderObject; 51 protected object m_senderObject;
52 protected ChatTypeEnum m_type; 52 protected ChatTypeEnum m_type;
53 protected UUID m_fromID; 53 protected UUID m_fromID;
54 protected UUID m_toID;
54 55
55 public OSChatMessage() 56 public OSChatMessage()
56 { 57 {
57 m_position = new Vector3(); 58 m_position = new Vector3();
59 m_toID = UUID.Zero;
58 } 60 }
59 61
60 /// <summary> 62 /// <summary>
@@ -102,6 +104,15 @@ namespace OpenSim.Framework
102 set { m_from = value; } 104 set { m_from = value; }
103 } 105 }
104 106
107 /// <summary>
108 /// The name of the sender (needed for scripts)
109 /// </summary>
110 public string To
111 {
112 get { return m_from; }
113 set { m_from = value; }
114 }
115
105 #region IEventArgs Members 116 #region IEventArgs Members
106 117
107 /// TODO: Sender and SenderObject should just be Sender and of 118 /// TODO: Sender and SenderObject should just be Sender and of
@@ -132,6 +143,15 @@ namespace OpenSim.Framework
132 } 143 }
133 144
134 /// <summary> 145 /// <summary>
146 /// The single recipient or all if not set.
147 /// </summary>
148 public UUID TargetUUID
149 {
150 get { return m_toID; }
151 set { m_toID = value; }
152 }
153
154 /// <summary>
135 /// 155 ///
136 /// </summary> 156 /// </summary>
137 public IScene Scene 157 public IScene Scene
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
index 10b4c37..e4452fb 100644
--- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
@@ -186,6 +186,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
186 { 186 {
187 string fromName = c.From; 187 string fromName = c.From;
188 UUID fromID = UUID.Zero; 188 UUID fromID = UUID.Zero;
189 UUID targetID = c.TargetUUID;
189 string message = c.Message; 190 string message = c.Message;
190 IScene scene = c.Scene; 191 IScene scene = c.Scene;
191 Vector3 fromPos = c.Position; 192 Vector3 fromPos = c.Position;
@@ -221,24 +222,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
221 message = message.Substring(0, 1000); 222 message = message.Substring(0, 1000);
222 223
223// m_log.DebugFormat( 224// m_log.DebugFormat(
224// "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}", 225// "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}, targetID {5}",
225// fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType); 226// fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType, targetID);
226 227
227 HashSet<UUID> receiverIDs = new HashSet<UUID>(); 228 HashSet<UUID> receiverIDs = new HashSet<UUID>();
228 229
229 foreach (Scene s in m_scenes) 230 foreach (Scene s in m_scenes)
230 { 231 {
231 // This should use ForEachClient, but clients don't have a position. 232 if (targetID == UUID.Zero)
232 // If camera is moved into client, then camera position can be used 233 {
233 s.ForEachRootScenePresence( 234 // This should use ForEachClient, but clients don't have a position.
234 delegate(ScenePresence presence) 235 // If camera is moved into client, then camera position can be used
236 s.ForEachRootScenePresence(
237 delegate(ScenePresence presence)
238 {
239 if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType, false))
240 receiverIDs.Add(presence.UUID);
241 }
242 );
243 }
244 else
245 {
246 // This is a send to a specific client eg from llRegionSayTo
247 // no need to check distance etc, jand send is as say
248 ScenePresence presence = s.GetScenePresence(targetID);
249 if (presence != null && !presence.IsChildAgent)
235 { 250 {
236 if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType)) 251 if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, ChatTypeEnum.Say, message, sourceType, true))
237 receiverIDs.Add(presence.UUID); 252 receiverIDs.Add(presence.UUID);
238 } 253 }
239 ); 254 }
240 } 255 }
241 256
242 (scene as Scene).EventManager.TriggerOnChatToClients( 257 (scene as Scene).EventManager.TriggerOnChatToClients(
243 fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); 258 fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully);
244 } 259 }
@@ -315,7 +330,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
315 /// precondition</returns> 330 /// precondition</returns>
316 protected virtual bool TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos, 331 protected virtual bool TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos,
317 UUID fromAgentID, string fromName, ChatTypeEnum type, 332 UUID fromAgentID, string fromName, ChatTypeEnum type,
318 string message, ChatSourceType src) 333 string message, ChatSourceType src, bool ignoreDistance)
319 { 334 {
320 // don't send stuff to child agents 335 // don't send stuff to child agents
321 if (presence.IsChildAgent) return false; 336 if (presence.IsChildAgent) return false;
@@ -326,12 +341,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
326 presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); 341 presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);
327 342
328 int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos); 343 int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos);
329 344
330 if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance || 345 if (!ignoreDistance)
331 type == ChatTypeEnum.Say && dis > m_saydistance ||
332 type == ChatTypeEnum.Shout && dis > m_shoutdistance)
333 { 346 {
334 return false; 347 if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance ||
348 type == ChatTypeEnum.Say && dis > m_saydistance ||
349 type == ChatTypeEnum.Shout && dis > m_shoutdistance)
350 {
351 return false;
352 }
335 } 353 }
336 354
337 // TODO: should change so the message is sent through the avatar rather than direct to the ClientView 355 // 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 176c86d..8358bc0 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
308 /// <param name='msg'> 308 /// <param name='msg'>
309 /// Message. 309 /// Message.
310 /// </param> 310 /// </param>
311 public bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error) 311 public void DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg)
312 { 312 {
313 error = null;
314 // Is id an avatar? 313 // Is id an avatar?
315 ScenePresence sp = m_scene.GetScenePresence(target); 314 ScenePresence sp = m_scene.GetScenePresence(target);
316 315
317 if (sp != null) 316 if (sp != null)
318 { 317 {
319 // Send message to avatar 318 // ignore if a child agent this is restricted to inside one region
319 if (sp.IsChildAgent)
320 return;
321
322 // Send message to the avatar.
323 // Channel zero only goes to the avatar
324 // non zero channel messages only go to the attachments
320 if (channel == 0) 325 if (channel == 0)
321 { 326 {
322 m_scene.SimChatBroadcast(Utils.StringToBytes(msg), ChatTypeEnum.Broadcast, 0, pos, name, id, false); 327 m_scene.SimChatToAgent(target, Utils.StringToBytes(msg), pos, name, id, false);
323 } 328 }
324 329 else
325 List<SceneObjectGroup> attachments = sp.GetAttachments();
326
327 if (attachments.Count == 0)
328 return true;
329
330 // Get uuid of attachments
331 List<UUID> targets = new List<UUID>();
332 foreach (SceneObjectGroup sog in attachments)
333 { 330 {
334 if (!sog.IsDeleted) 331 List<SceneObjectGroup> attachments = sp.GetAttachments();
335 targets.Add(sog.UUID); 332 if (attachments.Count == 0)
336 } 333 return;
337 334
338 // Need to check each attachment 335 // Get uuid of attachments
339 foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) 336 List<UUID> targets = new List<UUID>();
340 { 337 foreach (SceneObjectGroup sog in attachments)
341 if (li.GetHostID().Equals(id)) 338 {
342 continue; 339 if (!sog.IsDeleted)
340 targets.Add(sog.UUID);
341 }
343 342
344 if (m_scene.GetSceneObjectPart(li.GetHostID()) == null) 343 // Need to check each attachment
345 continue; 344 foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg))
345 {
346 if (li.GetHostID().Equals(id))
347 continue;
346 348
347 if (targets.Contains(li.GetHostID())) 349 if (m_scene.GetSceneObjectPart(li.GetHostID()) == null)
348 QueueMessage(new ListenerInfo(li, name, id, msg)); 350 continue;
349 }
350 351
351 return true; 352 if (targets.Contains(li.GetHostID()))
352 } 353 QueueMessage(new ListenerInfo(li, name, id, msg));
354 }
355 }
353 356
354 // Need to toss an error here 357 return;
355 if (channel == 0)
356 {
357 error = "Cannot use llRegionSayTo to message objects on channel 0";
358 return false;
359 } 358 }
360 359
360 // No avatar found so look for an object
361 foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) 361 foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg))
362 { 362 {
363 // Dont process if this message is from yourself! 363 // Dont process if this message is from yourself!
@@ -375,7 +375,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
375 } 375 }
376 } 376 }
377 377
378 return true; 378 return;
379 } 379 }
380 380
381 protected void QueueMessage(ListenerInfo li) 381 protected void QueueMessage(ListenerInfo li)
diff --git a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs
index e8e375e..4e74781 100644
--- a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs
+++ b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs
@@ -103,7 +103,7 @@ namespace OpenSim.Region.Framework.Interfaces
103 /// <param name='msg'> 103 /// <param name='msg'>
104 /// Message. 104 /// Message.
105 /// </param> 105 /// </param>
106 bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error); 106 void DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg);
107 107
108 /// <summary> 108 /// <summary>
109 /// Are there any listen events ready to be dispatched? 109 /// 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 87ffc74..2701d6e 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -38,8 +38,9 @@ namespace OpenSim.Region.Framework.Scenes
38{ 38{
39 public partial class Scene 39 public partial class Scene
40 { 40 {
41
41 protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, 42 protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
42 UUID fromID, bool fromAgent, bool broadcast) 43 UUID fromID, UUID targetID, bool fromAgent, bool broadcast)
43 { 44 {
44 OSChatMessage args = new OSChatMessage(); 45 OSChatMessage args = new OSChatMessage();
45 46
@@ -63,14 +64,20 @@ namespace OpenSim.Region.Framework.Scenes
63 } 64 }
64 65
65 args.From = fromName; 66 args.From = fromName;
66 //args. 67 args.TargetUUID = targetID;
67 68
68 if (broadcast) 69 if (broadcast)
69 EventManager.TriggerOnChatBroadcast(this, args); 70 EventManager.TriggerOnChatBroadcast(this, args);
70 else 71 else
71 EventManager.TriggerOnChatFromWorld(this, args); 72 EventManager.TriggerOnChatFromWorld(this, args);
72 } 73 }
73 74
75 protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
76 UUID fromID, bool fromAgent, bool broadcast)
77 {
78 SimChat(message, type, channel, fromPos, fromName, fromID, UUID.Zero, fromAgent, broadcast);
79 }
80
74 /// <summary> 81 /// <summary>
75 /// 82 ///
76 /// </summary> 83 /// </summary>
@@ -108,6 +115,19 @@ namespace OpenSim.Region.Framework.Scenes
108 { 115 {
109 SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true); 116 SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true);
110 } 117 }
118 /// <summary>
119 ///
120 /// </summary>
121 /// <param name="message"></param>
122 /// <param name="type"></param>
123 /// <param name="fromPos"></param>
124 /// <param name="fromName"></param>
125 /// <param name="fromAgentID"></param>
126 /// <param name="targetID"></param>
127 public void SimChatToAgent(UUID targetID, byte[] message, Vector3 fromPos, string fromName, UUID fromID, bool fromAgent)
128 {
129 SimChat(message, ChatTypeEnum.Say, 0, fromPos, fromName, fromID, targetID, fromAgent, false);
130 }
111 131
112 /// <summary> 132 /// <summary>
113 /// Invoked when the client requests a prim. 133 /// 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 36c9d5e..a2176ba 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -839,13 +839,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
839 839
840 m_host.AddScriptLPS(1); 840 m_host.AddScriptLPS(1);
841 841
842 if (channel == ScriptBaseClass.DEBUG_CHANNEL)
843 {
844 return;
845 }
846
842 UUID TargetID; 847 UUID TargetID;
843 UUID.TryParse(target, out TargetID); 848 UUID.TryParse(target, out TargetID);
844 849
845 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); 850 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
846 if (wComm != null) 851 if (wComm != null)
847 if (!wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg, out error)) 852 wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg);
848 LSLError(error);
849 } 853 }
850 854
851 public LSL_Integer llListen(int channelID, string name, string ID, string msg) 855 public LSL_Integer llListen(int channelID, string name, string ID, string msg)