diff options
author | Talun | 2012-04-22 23:07:50 +0100 |
---|---|---|
committer | BlueWall | 2012-04-23 07:16:33 -0400 |
commit | 679da63da617d031e5e7ae3f2d2a29db1a23ace3 (patch) | |
tree | 3feb83235a10b67ed068fb69de74d3c005b7a717 /OpenSim/Region/CoreModules | |
parent | refactor: simply some properties code in BasicPhysicsPlugin (diff) | |
download | opensim-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>
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | 52 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs | 70 |
2 files changed, 70 insertions, 52 deletions
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) |