diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs | 124 |
1 files changed, 69 insertions, 55 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index 3484387..a5203ea 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs | |||
@@ -96,6 +96,8 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
96 | // private static readonly ILog m_log = | 96 | // private static readonly ILog m_log = |
97 | // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 97 | // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
98 | 98 | ||
99 | private const int DEBUG_CHANNEL = 2147483647; | ||
100 | |||
99 | private ListenerManager m_listenerManager; | 101 | private ListenerManager m_listenerManager; |
100 | private Queue m_pending; | 102 | private Queue m_pending; |
101 | private Queue m_pendingQ; | 103 | private Queue m_pendingQ; |
@@ -111,7 +113,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
111 | // wrap this in a try block so that defaults will work if | 113 | // wrap this in a try block so that defaults will work if |
112 | // the config file doesn't specify otherwise. | 114 | // the config file doesn't specify otherwise. |
113 | int maxlisteners = 1000; | 115 | int maxlisteners = 1000; |
114 | int maxhandles = 64; | 116 | int maxhandles = 65; |
115 | try | 117 | try |
116 | { | 118 | { |
117 | m_whisperdistance = config.Configs["Chat"].GetInt( | 119 | m_whisperdistance = config.Configs["Chat"].GetInt( |
@@ -128,8 +130,15 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
128 | catch (Exception) | 130 | catch (Exception) |
129 | { | 131 | { |
130 | } | 132 | } |
131 | if (maxlisteners < 1) maxlisteners = int.MaxValue; | 133 | |
132 | if (maxhandles < 1) maxhandles = int.MaxValue; | 134 | if (maxlisteners < 1) |
135 | maxlisteners = int.MaxValue; | ||
136 | if (maxhandles < 1) | ||
137 | maxhandles = int.MaxValue; | ||
138 | |||
139 | if (maxlisteners < maxhandles) | ||
140 | maxlisteners = maxhandles; | ||
141 | |||
133 | m_listenerManager = new ListenerManager(maxlisteners, maxhandles); | 142 | m_listenerManager = new ListenerManager(maxlisteners, maxhandles); |
134 | m_pendingQ = new Queue(); | 143 | m_pendingQ = new Queue(); |
135 | m_pending = Queue.Synchronized(m_pendingQ); | 144 | m_pending = Queue.Synchronized(m_pendingQ); |
@@ -309,6 +318,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
309 | // Determine which listen event filters match the given set of arguments, this results | 318 | // Determine which listen event filters match the given set of arguments, this results |
310 | // in a limited set of listeners, each belonging a host. If the host is in range, add them | 319 | // in a limited set of listeners, each belonging a host. If the host is in range, add them |
311 | // to the pending queue. | 320 | // to the pending queue. |
321 | |||
312 | foreach (ListenerInfo li | 322 | foreach (ListenerInfo li |
313 | in m_listenerManager.GetListeners(UUID.Zero, channel, | 323 | in m_listenerManager.GetListeners(UUID.Zero, channel, |
314 | name, id, msg)) | 324 | name, id, msg)) |
@@ -366,79 +376,82 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
366 | /// <param name='msg'> | 376 | /// <param name='msg'> |
367 | /// Message. | 377 | /// Message. |
368 | /// </param> | 378 | /// </param> |
369 | public void DeliverMessageTo(UUID target, int channel, Vector3 pos, | 379 | public void DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg) |
370 | string name, UUID id, string msg) | ||
371 | { | 380 | { |
372 | // Is id an avatar? | 381 | if (channel == DEBUG_CHANNEL) |
373 | ScenePresence sp = m_scene.GetScenePresence(target); | 382 | return; |
374 | 383 | ||
384 | if(target == UUID.Zero) | ||
385 | return; | ||
386 | |||
387 | // Is target an avatar? | ||
388 | ScenePresence sp = m_scene.GetScenePresence(target); | ||
375 | if (sp != null) | 389 | if (sp != null) |
376 | { | 390 | { |
377 | // ignore if a child agent this is restricted to inside one | 391 | // Send message to avatar |
378 | // region | 392 | if (channel == 0) |
379 | if (sp.IsChildAgent) | 393 | { |
394 | // Channel 0 goes to viewer ONLY | ||
395 | m_scene.SimChat(Utils.StringToBytes(msg), ChatTypeEnum.Broadcast, 0, pos, name, id, target, false, false); | ||
380 | return; | 396 | return; |
397 | } | ||
381 | 398 | ||
382 | // Channel zero only goes to the avatar | 399 | // for now messages to prims don't cross regions |
383 | // non zero channel messages only go to the attachments of the avatar. | 400 | if(sp.IsChildAgent) |
384 | if (channel != 0) | 401 | return; |
385 | { | ||
386 | List<SceneObjectGroup> attachments = sp.GetAttachments(); | ||
387 | if (attachments.Count == 0) | ||
388 | return; | ||
389 | 402 | ||
390 | // Get uuid of attachments | 403 | List<SceneObjectGroup> attachments = sp.GetAttachments(); |
391 | List<UUID> targets = new List<UUID>(); | 404 | |
392 | foreach (SceneObjectGroup sog in attachments) | 405 | if (attachments.Count == 0) |
393 | { | 406 | return; |
394 | if (!sog.IsDeleted) | ||
395 | targets.Add(sog.UUID); | ||
396 | } | ||
397 | 407 | ||
398 | // Need to check each attachment | 408 | // Get uuid of attachments |
399 | foreach (ListenerInfo li | 409 | List<UUID> targets = new List<UUID>(); |
400 | in m_listenerManager.GetListeners(UUID.Zero, | 410 | foreach (SceneObjectGroup sog in attachments) |
401 | channel, name, id, msg)) | 411 | { |
412 | if (!sog.IsDeleted) | ||
402 | { | 413 | { |
403 | if (li.GetHostID().Equals(id)) | 414 | SceneObjectPart[] parts = sog.Parts; |
404 | continue; | 415 | foreach(SceneObjectPart p in parts) |
416 | targets.Add(p.UUID); | ||
417 | } | ||
418 | } | ||
405 | 419 | ||
406 | if (m_scene.GetSceneObjectPart( | 420 | foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) |
407 | li.GetHostID()) == null) | 421 | { |
408 | { | 422 | UUID liHostID = li.GetHostID(); |
409 | continue; | 423 | if (liHostID.Equals(id)) |
410 | } | 424 | continue; |
425 | if (m_scene.GetSceneObjectPart(liHostID) == null) | ||
426 | continue; | ||
411 | 427 | ||
412 | if (targets.Contains(li.GetHostID())) | 428 | if (targets.Contains(liHostID)) |
413 | QueueMessage(new ListenerInfo(li, name, id, msg)); | 429 | QueueMessage(new ListenerInfo(li, name, id, msg)); |
414 | } | ||
415 | } | 430 | } |
416 | 431 | ||
417 | return; | 432 | return; |
418 | } | 433 | } |
419 | 434 | ||
420 | // No avatar found so look for an object | 435 | SceneObjectPart part = m_scene.GetSceneObjectPart(target); |
421 | foreach (ListenerInfo li | 436 | if (part == null) // Not even an object |
422 | in m_listenerManager.GetListeners(UUID.Zero, channel, | 437 | return; // No error |
423 | name, id, msg)) | 438 | |
439 | foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) | ||
424 | { | 440 | { |
441 | UUID liHostID = li.GetHostID(); | ||
425 | // Dont process if this message is from yourself! | 442 | // Dont process if this message is from yourself! |
426 | if (li.GetHostID().Equals(id)) | 443 | if (liHostID.Equals(id)) |
427 | continue; | 444 | continue; |
428 | 445 | ||
429 | SceneObjectPart sPart = m_scene.GetSceneObjectPart( | 446 | if (m_scene.GetSceneObjectPart(liHostID) == null) |
430 | li.GetHostID()); | ||
431 | if (sPart == null) | ||
432 | continue; | 447 | continue; |
433 | 448 | ||
434 | if (li.GetHostID().Equals(target)) | 449 | if (liHostID.Equals(target)) |
435 | { | 450 | { |
436 | QueueMessage(new ListenerInfo(li, name, id, msg)); | 451 | QueueMessage(new ListenerInfo(li, name, id, msg)); |
437 | break; | 452 | break; |
438 | } | 453 | } |
439 | } | 454 | } |
440 | |||
441 | return; | ||
442 | } | 455 | } |
443 | 456 | ||
444 | protected void QueueMessage(ListenerInfo li) | 457 | protected void QueueMessage(ListenerInfo li) |
@@ -557,9 +570,9 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
557 | return coll[0].GetHandle(); | 570 | return coll[0].GetHandle(); |
558 | } | 571 | } |
559 | 572 | ||
560 | if (m_curlisteners < m_maxlisteners) | 573 | lock (m_listeners) |
561 | { | 574 | { |
562 | lock (m_listeners) | 575 | if (m_curlisteners < m_maxlisteners) |
563 | { | 576 | { |
564 | int newHandle = GetNewHandle(itemID); | 577 | int newHandle = GetNewHandle(itemID); |
565 | 578 | ||
@@ -599,11 +612,9 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
599 | li.GetHandle().Equals(handle)) | 612 | li.GetHandle().Equals(handle)) |
600 | { | 613 | { |
601 | lis.Value.Remove(li); | 614 | lis.Value.Remove(li); |
615 | m_curlisteners--; | ||
602 | if (lis.Value.Count == 0) | 616 | if (lis.Value.Count == 0) |
603 | { | 617 | m_listeners.Remove(lis.Key); // bailing of loop so this does not smoke |
604 | m_listeners.Remove(lis.Key); | ||
605 | m_curlisteners--; | ||
606 | } | ||
607 | // there should be only one, so we bail out early | 618 | // there should be only one, so we bail out early |
608 | return; | 619 | return; |
609 | } | 620 | } |
@@ -712,6 +723,9 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
712 | } | 723 | } |
713 | } | 724 | } |
714 | 725 | ||
726 | if(handles.Count >= m_maxhandles) | ||
727 | return -1; | ||
728 | |||
715 | // Note: 0 is NOT a valid handle for llListen() to return | 729 | // Note: 0 is NOT a valid handle for llListen() to return |
716 | for (int i = 1; i <= m_maxhandles; i++) | 730 | for (int i = 1; i <= m_maxhandles; i++) |
717 | { | 731 | { |