diff options
author | Melanie | 2012-06-28 22:02:20 +0100 |
---|---|---|
committer | Melanie | 2012-06-28 22:02:20 +0100 |
commit | a1a22a2f1034a1feb67b141abf4b138248cdb356 (patch) | |
tree | b1f71abd8e3f9a3106a4140ad35abba94c8468e5 /OpenSim | |
parent | Merge branch 'master' into careminster (diff) | |
download | opensim-SC-a1a22a2f1034a1feb67b141abf4b138248cdb356.zip opensim-SC-a1a22a2f1034a1feb67b141abf4b138248cdb356.tar.gz opensim-SC-a1a22a2f1034a1feb67b141abf4b138248cdb356.tar.bz2 opensim-SC-a1a22a2f1034a1feb67b141abf4b138248cdb356.tar.xz |
Revert "Mantis 5977 Corrections to llRegionSayTo"
This reverts commit 679da63da617d031e5e7ae3f2d2a29db1a23ace3.
Conflicts:
OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
Diffstat (limited to '')
6 files changed, 59 insertions, 119 deletions
diff --git a/OpenSim/Framework/OSChatMessage.cs b/OpenSim/Framework/OSChatMessage.cs index 455756d..54fa275 100644 --- a/OpenSim/Framework/OSChatMessage.cs +++ b/OpenSim/Framework/OSChatMessage.cs | |||
@@ -51,12 +51,10 @@ 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; | ||
55 | 54 | ||
56 | public OSChatMessage() | 55 | public OSChatMessage() |
57 | { | 56 | { |
58 | m_position = new Vector3(); | 57 | m_position = new Vector3(); |
59 | m_toID = UUID.Zero; | ||
60 | } | 58 | } |
61 | 59 | ||
62 | /// <summary> | 60 | /// <summary> |
@@ -104,15 +102,6 @@ namespace OpenSim.Framework | |||
104 | set { m_from = value; } | 102 | set { m_from = value; } |
105 | } | 103 | } |
106 | 104 | ||
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 | |||
116 | #region IEventArgs Members | 105 | #region IEventArgs Members |
117 | 106 | ||
118 | /// TODO: Sender and SenderObject should just be Sender and of | 107 | /// TODO: Sender and SenderObject should just be Sender and of |
@@ -143,15 +132,6 @@ namespace OpenSim.Framework | |||
143 | } | 132 | } |
144 | 133 | ||
145 | /// <summary> | 134 | /// <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> | ||
155 | /// | 135 | /// |
156 | /// </summary> | 136 | /// </summary> |
157 | public IScene Scene | 137 | public IScene Scene |
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index 6ffc7e6..5649855 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 | |||
197 | string fromName = c.From; | 197 | string fromName = c.From; |
198 | string fromNamePrefix = ""; | 198 | string fromNamePrefix = ""; |
199 | UUID fromID = UUID.Zero; | 199 | UUID fromID = UUID.Zero; |
200 | UUID targetID = c.TargetUUID; | ||
201 | string message = c.Message; | 200 | string message = c.Message; |
202 | IScene scene = c.Scene; | 201 | IScene scene = c.Scene; |
203 | Vector3 fromPos = c.Position; | 202 | Vector3 fromPos = c.Position; |
@@ -236,31 +235,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
236 | message = message.Substring(0, 1000); | 235 | message = message.Substring(0, 1000); |
237 | 236 | ||
238 | // m_log.DebugFormat( | 237 | // m_log.DebugFormat( |
239 | // "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}, targetID {5}", | 238 | // "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}", |
240 | // fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType, targetID); | 239 | // fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType); |
241 | 240 | ||
242 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); | 241 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); |
243 | 242 | ||
244 | foreach (Scene s in m_scenes) | 243 | foreach (Scene s in m_scenes) |
245 | { | 244 | { |
246 | if (targetID == UUID.Zero) | 245 | // This should use ForEachClient, but clients don't have a position. |
247 | { | 246 | // If camera is moved into client, then camera position can be used |
248 | // This should use ForEachClient, but clients don't have a position. | 247 | s.ForEachRootScenePresence( |
249 | // If camera is moved into client, then camera position can be used | 248 | delegate(ScenePresence presence) |
250 | s.ForEachRootScenePresence( | ||
251 | delegate(ScenePresence presence) | ||
252 | { | ||
253 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType, false)) | ||
254 | receiverIDs.Add(presence.UUID); | ||
255 | } | ||
256 | ); | ||
257 | } | ||
258 | else | ||
259 | { | ||
260 | // This is a send to a specific client eg from llRegionSayTo | ||
261 | // no need to check distance etc, jand send is as say | ||
262 | ScenePresence presence = s.GetScenePresence(targetID); | ||
263 | if (presence != null && !presence.IsChildAgent) | ||
264 | { | 249 | { |
265 | ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y); | 250 | ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y); |
266 | if (Presencecheck != null) | 251 | if (Presencecheck != null) |
@@ -271,14 +256,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
271 | // objects on a parcel with access restrictions | 256 | // objects on a parcel with access restrictions |
272 | if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true) | 257 | if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true) |
273 | { | 258 | { |
274 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromNamePrefix + fromName, c.Type, message, sourceType, false)) | 259 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromNamePrefix + fromName, c.Type, message, sourceType)) |
275 | receiverIDs.Add(presence.UUID); | 260 | receiverIDs.Add(presence.UUID); |
276 | } | 261 | } |
277 | } | 262 | } |
278 | } | 263 | } |
279 | } | 264 | ); |
280 | } | 265 | } |
281 | 266 | ||
282 | (scene as Scene).EventManager.TriggerOnChatToClients( | 267 | (scene as Scene).EventManager.TriggerOnChatToClients( |
283 | fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); | 268 | fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); |
284 | } | 269 | } |
@@ -358,7 +343,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
358 | /// precondition</returns> | 343 | /// precondition</returns> |
359 | protected virtual bool TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos, | 344 | protected virtual bool TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos, |
360 | UUID fromAgentID, string fromName, ChatTypeEnum type, | 345 | UUID fromAgentID, string fromName, ChatTypeEnum type, |
361 | string message, ChatSourceType src, bool ignoreDistance) | 346 | string message, ChatSourceType src) |
362 | { | 347 | { |
363 | // don't send stuff to child agents | 348 | // don't send stuff to child agents |
364 | if (presence.IsChildAgent) return false; | 349 | if (presence.IsChildAgent) return false; |
@@ -369,15 +354,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
369 | presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); | 354 | presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); |
370 | 355 | ||
371 | int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos); | 356 | int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos); |
372 | 357 | ||
373 | if (!ignoreDistance) | 358 | if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance || |
359 | type == ChatTypeEnum.Say && dis > m_saydistance || | ||
360 | type == ChatTypeEnum.Shout && dis > m_shoutdistance) | ||
374 | { | 361 | { |
375 | if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance || | 362 | return false; |
376 | type == ChatTypeEnum.Say && dis > m_saydistance || | ||
377 | type == ChatTypeEnum.Shout && dis > m_shoutdistance) | ||
378 | { | ||
379 | return false; | ||
380 | } | ||
381 | } | 363 | } |
382 | 364 | ||
383 | // TODO: should change so the message is sent through the avatar rather than direct to the ClientView | 365 | // 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 8358bc0..176c86d 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 void DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg) | 311 | public bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error) |
312 | { | 312 | { |
313 | error = null; | ||
313 | // Is id an avatar? | 314 | // Is id an avatar? |
314 | ScenePresence sp = m_scene.GetScenePresence(target); | 315 | ScenePresence sp = m_scene.GetScenePresence(target); |
315 | 316 | ||
316 | if (sp != null) | 317 | if (sp != null) |
317 | { | 318 | { |
318 | // ignore if a child agent this is restricted to inside one region | 319 | // Send message to avatar |
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 | ||
325 | if (channel == 0) | 320 | if (channel == 0) |
326 | { | 321 | { |
327 | m_scene.SimChatToAgent(target, Utils.StringToBytes(msg), pos, name, id, false); | 322 | m_scene.SimChatBroadcast(Utils.StringToBytes(msg), ChatTypeEnum.Broadcast, 0, pos, name, id, false); |
328 | } | 323 | } |
329 | else | ||
330 | { | ||
331 | List<SceneObjectGroup> attachments = sp.GetAttachments(); | ||
332 | if (attachments.Count == 0) | ||
333 | return; | ||
334 | 324 | ||
335 | // Get uuid of attachments | 325 | List<SceneObjectGroup> attachments = sp.GetAttachments(); |
336 | List<UUID> targets = new List<UUID>(); | ||
337 | foreach (SceneObjectGroup sog in attachments) | ||
338 | { | ||
339 | if (!sog.IsDeleted) | ||
340 | targets.Add(sog.UUID); | ||
341 | } | ||
342 | 326 | ||
343 | // Need to check each attachment | 327 | if (attachments.Count == 0) |
344 | foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) | 328 | return true; |
345 | { | ||
346 | if (li.GetHostID().Equals(id)) | ||
347 | continue; | ||
348 | 329 | ||
349 | if (m_scene.GetSceneObjectPart(li.GetHostID()) == null) | 330 | // Get uuid of attachments |
350 | continue; | 331 | List<UUID> targets = new List<UUID>(); |
332 | foreach (SceneObjectGroup sog in attachments) | ||
333 | { | ||
334 | if (!sog.IsDeleted) | ||
335 | targets.Add(sog.UUID); | ||
336 | } | ||
351 | 337 | ||
352 | if (targets.Contains(li.GetHostID())) | 338 | // Need to check each attachment |
353 | QueueMessage(new ListenerInfo(li, name, id, msg)); | 339 | foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) |
354 | } | 340 | { |
341 | if (li.GetHostID().Equals(id)) | ||
342 | continue; | ||
343 | |||
344 | if (m_scene.GetSceneObjectPart(li.GetHostID()) == null) | ||
345 | continue; | ||
346 | |||
347 | if (targets.Contains(li.GetHostID())) | ||
348 | QueueMessage(new ListenerInfo(li, name, id, msg)); | ||
355 | } | 349 | } |
356 | 350 | ||
357 | return; | 351 | return true; |
352 | } | ||
353 | |||
354 | // Need to toss an error here | ||
355 | if (channel == 0) | ||
356 | { | ||
357 | error = "Cannot use llRegionSayTo to message objects on channel 0"; | ||
358 | return false; | ||
358 | } | 359 | } |
359 | 360 | ||
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; | 378 | return true; |
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 4e74781..e8e375e 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 | void DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg); | 106 | bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error); |
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 cf68ff4..3ef1e29 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 | |||
38 | { | 38 | { |
39 | public partial class Scene | 39 | public partial class Scene |
40 | { | 40 | { |
41 | |||
42 | protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, | 41 | protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, |
43 | UUID fromID, UUID targetID, bool fromAgent, bool broadcast) | 42 | UUID fromID, bool fromAgent, bool broadcast) |
44 | { | 43 | { |
45 | OSChatMessage args = new OSChatMessage(); | 44 | OSChatMessage args = new OSChatMessage(); |
46 | 45 | ||
@@ -64,20 +63,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
64 | } | 63 | } |
65 | 64 | ||
66 | args.From = fromName; | 65 | args.From = fromName; |
67 | args.TargetUUID = targetID; | 66 | //args. |
68 | 67 | ||
69 | if (broadcast) | 68 | if (broadcast) |
70 | EventManager.TriggerOnChatBroadcast(this, args); | 69 | EventManager.TriggerOnChatBroadcast(this, args); |
71 | else | 70 | else |
72 | EventManager.TriggerOnChatFromWorld(this, args); | 71 | EventManager.TriggerOnChatFromWorld(this, args); |
73 | } | 72 | } |
74 | 73 | ||
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 | |||
81 | /// <summary> | 74 | /// <summary> |
82 | /// | 75 | /// |
83 | /// </summary> | 76 | /// </summary> |
@@ -115,19 +108,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
115 | { | 108 | { |
116 | SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true); | 109 | SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true); |
117 | } | 110 | } |
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 | } | ||
131 | 111 | ||
132 | /// <summary> | 112 | /// <summary> |
133 | /// Invoked when the client requests a prim. | 113 | /// 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 41de257..ffa19d9 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 | |||
921 | 921 | ||
922 | public void llRegionSayTo(string target, int channel, string msg) | 922 | public void llRegionSayTo(string target, int channel, string msg) |
923 | { | 923 | { |
924 | string error = String.Empty; | ||
925 | |||
924 | if (msg.Length > 1023) | 926 | if (msg.Length > 1023) |
925 | msg = msg.Substring(0, 1023); | 927 | msg = msg.Substring(0, 1023); |
926 | 928 | ||
927 | m_host.AddScriptLPS(1); | 929 | m_host.AddScriptLPS(1); |
928 | 930 | ||
929 | if (channel == ScriptBaseClass.DEBUG_CHANNEL) | ||
930 | { | ||
931 | return; | ||
932 | } | ||
933 | |||
934 | UUID TargetID; | 931 | UUID TargetID; |
935 | UUID.TryParse(target, out TargetID); | 932 | UUID.TryParse(target, out TargetID); |
936 | 933 | ||
937 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | 934 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); |
938 | if (wComm != null) | 935 | if (wComm != null) |
939 | wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg); | 936 | if (!wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg, out error)) |
937 | LSLError(error); | ||
940 | } | 938 | } |
941 | 939 | ||
942 | public LSL_Integer llListen(int channelID, string name, string ID, string msg) | 940 | public LSL_Integer llListen(int channelID, string name, string ID, string msg) |