aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorSignpostMarv2012-11-11 00:38:27 +0000
committerDiva Canto2012-11-10 17:09:47 -0800
commitb3dddd7447c42a60f1e4a2452e6a6c6dbe9d5618 (patch)
treebb1e1a9ae404bed41a4db411185da2b7c6a24c69 /OpenSim
parentConverting WorldCommModule to INonSharedRegionModule (diff)
downloadopensim-SC-b3dddd7447c42a60f1e4a2452e6a6c6dbe9d5618.zip
opensim-SC-b3dddd7447c42a60f1e4a2452e6a6c6dbe9d5618.tar.gz
opensim-SC-b3dddd7447c42a60f1e4a2452e6a6c6dbe9d5618.tar.bz2
opensim-SC-b3dddd7447c42a60f1e4a2452e6a6c6dbe9d5618.tar.xz
document & 80-character width terminal formatting
Signed-off-by: Diva Canto <diva@metaverseink.com>
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs170
1 files changed, 114 insertions, 56 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
index 2c26e63..c88be82 100644
--- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs
@@ -29,9 +29,12 @@ using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text.RegularExpressions; 31using System.Text.RegularExpressions;
32
32using Nini.Config; 33using Nini.Config;
33using Mono.Addins; 34using Mono.Addins;
35
34using OpenMetaverse; 36using OpenMetaverse;
37
35using OpenSim.Framework; 38using OpenSim.Framework;
36using OpenSim.Region.Framework.Interfaces; 39using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
@@ -111,11 +114,16 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
111 int maxhandles = 64; 114 int maxhandles = 64;
112 try 115 try
113 { 116 {
114 m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); 117 m_whisperdistance = config.Configs["Chat"].GetInt(
115 m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); 118 "whisper_distance", m_whisperdistance);
116 m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance); 119 m_saydistance = config.Configs["Chat"].GetInt(
117 maxlisteners = config.Configs["LL-Functions"].GetInt("max_listens_per_region", maxlisteners); 120 "say_distance", m_saydistance);
118 maxhandles = config.Configs["LL-Functions"].GetInt("max_listens_per_script", maxhandles); 121 m_shoutdistance = config.Configs["Chat"].GetInt(
122 "shout_distance", m_shoutdistance);
123 maxlisteners = config.Configs["LL-Functions"].GetInt(
124 "max_listens_per_region", maxlisteners);
125 maxhandles = config.Configs["LL-Functions"].GetInt(
126 "max_listens_per_script", maxhandles);
119 } 127 }
120 catch (Exception) 128 catch (Exception)
121 { 129 {
@@ -269,7 +277,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
269 277
270 if ((source = m_scene.GetSceneObjectPart(id)) != null) 278 if ((source = m_scene.GetSceneObjectPart(id)) != null)
271 position = source.AbsolutePosition; 279 position = source.AbsolutePosition;
272 else if ((avatar = m_scene.GetScenePresence(id)) != null) 280 else if ((avatar = m_scene.GetScenePresence(id)) != null)
273 position = avatar.AbsolutePosition; 281 position = avatar.AbsolutePosition;
274 else if (ChatTypeEnum.Region == type) 282 else if (ChatTypeEnum.Region == type)
275 position = CenterOfRegion; 283 position = CenterOfRegion;
@@ -292,7 +300,8 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
292 /// <param name="name">name of sender (object or avatar)</param> 300 /// <param name="name">name of sender (object or avatar)</param>
293 /// <param name="id">key of sender (object or avatar)</param> 301 /// <param name="id">key of sender (object or avatar)</param>
294 /// <param name="msg">msg to sent</param> 302 /// <param name="msg">msg to sent</param>
295 public void DeliverMessage(ChatTypeEnum type, int channel, string name, UUID id, string msg, Vector3 position) 303 public void DeliverMessage(ChatTypeEnum type, int channel,
304 string name, UUID id, string msg, Vector3 position)
296 { 305 {
297 // m_log.DebugFormat("[WorldComm] got[2] type {0}, channel {1}, name {2}, id {3}, msg {4}", 306 // m_log.DebugFormat("[WorldComm] got[2] type {0}, channel {1}, name {2}, id {3}, msg {4}",
298 // type, channel, name, id, msg); 307 // type, channel, name, id, msg);
@@ -300,17 +309,21 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
300 // Determine which listen event filters match the given set of arguments, this results 309 // Determine which listen event filters match the given set of arguments, this results
301 // in a limited set of listeners, each belonging a host. If the host is in range, add them 310 // in a limited set of listeners, each belonging a host. If the host is in range, add them
302 // to the pending queue. 311 // to the pending queue.
303 foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) 312 foreach (ListenerInfo li
313 in m_listenerManager.GetListeners(UUID.Zero, channel,
314 name, id, msg))
304 { 315 {
305 // Dont process if this message is from yourself! 316 // Dont process if this message is from yourself!
306 if (li.GetHostID().Equals(id)) 317 if (li.GetHostID().Equals(id))
307 continue; 318 continue;
308 319
309 SceneObjectPart sPart = m_scene.GetSceneObjectPart(li.GetHostID()); 320 SceneObjectPart sPart = m_scene.GetSceneObjectPart(
321 li.GetHostID());
310 if (sPart == null) 322 if (sPart == null)
311 continue; 323 continue;
312 324
313 double dis = Util.GetDistanceTo(sPart.AbsolutePosition, position); 325 double dis = Util.GetDistanceTo(sPart.AbsolutePosition,
326 position);
314 switch (type) 327 switch (type)
315 { 328 {
316 case ChatTypeEnum.Whisper: 329 case ChatTypeEnum.Whisper:
@@ -353,14 +366,16 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
353 /// <param name='msg'> 366 /// <param name='msg'>
354 /// Message. 367 /// Message.
355 /// </param> 368 /// </param>
356 public void DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg) 369 public void DeliverMessageTo(UUID target, int channel, Vector3 pos,
370 string name, UUID id, string msg)
357 { 371 {
358 // Is id an avatar? 372 // Is id an avatar?
359 ScenePresence sp = m_scene.GetScenePresence(target); 373 ScenePresence sp = m_scene.GetScenePresence(target);
360 374
361 if (sp != null) 375 if (sp != null)
362 { 376 {
363 // ignore if a child agent this is restricted to inside one region 377 // ignore if a child agent this is restricted to inside one
378 // region
364 if (sp.IsChildAgent) 379 if (sp.IsChildAgent)
365 return; 380 return;
366 381
@@ -369,8 +384,9 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
369 // non zero channel messages only go to the attachments 384 // non zero channel messages only go to the attachments
370 if (channel == 0) 385 if (channel == 0)
371 { 386 {
372 m_scene.SimChatToAgent(target, Utils.StringToBytes(msg), pos, name, id, false); 387 m_scene.SimChatToAgent(target, Utils.StringToBytes(msg),
373 } 388 pos, name, id, false);
389 }
374 else 390 else
375 { 391 {
376 List<SceneObjectGroup> attachments = sp.GetAttachments(); 392 List<SceneObjectGroup> attachments = sp.GetAttachments();
@@ -386,13 +402,18 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
386 } 402 }
387 403
388 // Need to check each attachment 404 // Need to check each attachment
389 foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) 405 foreach (ListenerInfo li
406 in m_listenerManager.GetListeners(UUID.Zero,
407 channel, name, id, msg))
390 { 408 {
391 if (li.GetHostID().Equals(id)) 409 if (li.GetHostID().Equals(id))
392 continue; 410 continue;
393 411
394 if (m_scene.GetSceneObjectPart(li.GetHostID()) == null) 412 if (m_scene.GetSceneObjectPart(
413 li.GetHostID()) == null)
414 {
395 continue; 415 continue;
416 }
396 417
397 if (targets.Contains(li.GetHostID())) 418 if (targets.Contains(li.GetHostID()))
398 QueueMessage(new ListenerInfo(li, name, id, msg)); 419 QueueMessage(new ListenerInfo(li, name, id, msg));
@@ -403,17 +424,20 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
403 } 424 }
404 425
405 // No avatar found so look for an object 426 // No avatar found so look for an object
406 foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) 427 foreach (ListenerInfo li
428 in m_listenerManager.GetListeners(UUID.Zero, channel,
429 name, id, msg))
407 { 430 {
408 // Dont process if this message is from yourself! 431 // Dont process if this message is from yourself!
409 if (li.GetHostID().Equals(id)) 432 if (li.GetHostID().Equals(id))
410 continue; 433 continue;
411 434
412 SceneObjectPart sPart = m_scene.GetSceneObjectPart(li.GetHostID()); 435 SceneObjectPart sPart = m_scene.GetSceneObjectPart(
436 li.GetHostID());
413 if (sPart == null) 437 if (sPart == null)
414 continue; 438 continue;
415 439
416 if ( li.GetHostID().Equals(target)) 440 if (li.GetHostID().Equals(target))
417 { 441 {
418 QueueMessage(new ListenerInfo(li, name, id, msg)); 442 QueueMessage(new ListenerInfo(li, name, id, msg));
419 break; 443 break;
@@ -467,9 +491,15 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
467 private void DeliverClientMessage(Object sender, OSChatMessage e) 491 private void DeliverClientMessage(Object sender, OSChatMessage e)
468 { 492 {
469 if (null != e.Sender) 493 if (null != e.Sender)
470 DeliverMessage(e.Type, e.Channel, e.Sender.Name, e.Sender.AgentId, e.Message, e.Position); 494 {
495 DeliverMessage(e.Type, e.Channel, e.Sender.Name,
496 e.Sender.AgentId, e.Message, e.Position);
497 }
471 else 498 else
472 DeliverMessage(e.Type, e.Channel, e.From, UUID.Zero, e.Message, e.Position); 499 {
500 DeliverMessage(e.Type, e.Channel, e.From, UUID.Zero,
501 e.Message, e.Position);
502 }
473 } 503 }
474 504
475 public Object[] GetSerializationData(UUID itemID) 505 public Object[] GetSerializationData(UUID itemID)
@@ -486,7 +516,8 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
486 516
487 public class ListenerManager 517 public class ListenerManager
488 { 518 {
489 private Dictionary<int, List<ListenerInfo>> m_listeners = new Dictionary<int, List<ListenerInfo>>(); 519 private Dictionary<int, List<ListenerInfo>> m_listeners =
520 new Dictionary<int, List<ListenerInfo>>();
490 private int m_maxlisteners; 521 private int m_maxlisteners;
491 private int m_maxhandles; 522 private int m_maxhandles;
492 private int m_curlisteners; 523 private int m_curlisteners;
@@ -544,14 +575,15 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
544 itemID, hostID, channel, name, id, msg, 575 itemID, hostID, channel, name, id, msg,
545 regexBitfield); 576 regexBitfield);
546 577
547 List<ListenerInfo> listeners; 578 List<ListenerInfo> listeners;
548 if (!m_listeners.TryGetValue(channel,out listeners)) 579 if (!m_listeners.TryGetValue(
549 { 580 channel, out listeners))
550 listeners = new List<ListenerInfo>(); 581 {
551 m_listeners.Add(channel, listeners); 582 listeners = new List<ListenerInfo>();
552 } 583 m_listeners.Add(channel, listeners);
553 listeners.Add(li); 584 }
554 m_curlisteners++; 585 listeners.Add(li);
586 m_curlisteners++;
555 587
556 return newHandle; 588 return newHandle;
557 } 589 }
@@ -564,11 +596,13 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
564 { 596 {
565 lock (m_listeners) 597 lock (m_listeners)
566 { 598 {
567 foreach (KeyValuePair<int,List<ListenerInfo>> lis in m_listeners) 599 foreach (KeyValuePair<int, List<ListenerInfo>> lis
600 in m_listeners)
568 { 601 {
569 foreach (ListenerInfo li in lis.Value) 602 foreach (ListenerInfo li in lis.Value)
570 { 603 {
571 if (li.GetItemID().Equals(itemID) && li.GetHandle().Equals(handle)) 604 if (li.GetItemID().Equals(itemID) &&
605 li.GetHandle().Equals(handle))
572 { 606 {
573 lis.Value.Remove(li); 607 lis.Value.Remove(li);
574 if (lis.Value.Count == 0) 608 if (lis.Value.Count == 0)
@@ -591,13 +625,15 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
591 625
592 lock (m_listeners) 626 lock (m_listeners)
593 { 627 {
594 foreach (KeyValuePair<int,List<ListenerInfo>> lis in m_listeners) 628 foreach (KeyValuePair<int, List<ListenerInfo>> lis
629 in m_listeners)
595 { 630 {
596 foreach (ListenerInfo li in lis.Value) 631 foreach (ListenerInfo li in lis.Value)
597 { 632 {
598 if (li.GetItemID().Equals(itemID)) 633 if (li.GetItemID().Equals(itemID))
599 { 634 {
600 // store them first, else the enumerated bails on us 635 // store them first, else the enumerated bails on
636 // us
601 removedListeners.Add(li); 637 removedListeners.Add(li);
602 } 638 }
603 } 639 }
@@ -624,11 +660,13 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
624 { 660 {
625 lock (m_listeners) 661 lock (m_listeners)
626 { 662 {
627 foreach (KeyValuePair<int,List<ListenerInfo>> lis in m_listeners) 663 foreach (KeyValuePair<int, List<ListenerInfo>> lis
664 in m_listeners)
628 { 665 {
629 foreach (ListenerInfo li in lis.Value) 666 foreach (ListenerInfo li in lis.Value)
630 { 667 {
631 if (li.GetItemID().Equals(itemID) && li.GetHandle() == handle) 668 if (li.GetItemID().Equals(itemID) &&
669 li.GetHandle() == handle)
632 { 670 {
633 li.Activate(); 671 li.Activate();
634 // only one, bail out 672 // only one, bail out
@@ -643,11 +681,13 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
643 { 681 {
644 lock (m_listeners) 682 lock (m_listeners)
645 { 683 {
646 foreach (KeyValuePair<int,List<ListenerInfo>> lis in m_listeners) 684 foreach (KeyValuePair<int, List<ListenerInfo>> lis
685 in m_listeners)
647 { 686 {
648 foreach (ListenerInfo li in lis.Value) 687 foreach (ListenerInfo li in lis.Value)
649 { 688 {
650 if (li.GetItemID().Equals(itemID) && li.GetHandle() == handle) 689 if (li.GetItemID().Equals(itemID) &&
690 li.GetHandle() == handle)
651 { 691 {
652 li.Deactivate(); 692 li.Deactivate();
653 // only one, bail out 693 // only one, bail out
@@ -658,19 +698,24 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
658 } 698 }
659 } 699 }
660 700
661 // non-locked access, since its always called in the context of the lock 701 /// <summary>
702 /// non-locked access, since its always called in the context of the
703 /// lock
704 /// </summary>
705 /// <param name="itemID"></param>
706 /// <returns></returns>
662 private int GetNewHandle(UUID itemID) 707 private int GetNewHandle(UUID itemID)
663 { 708 {
664 List<int> handles = new List<int>(); 709 List<int> handles = new List<int>();
665 710
666 // build a list of used keys for this specific itemID... 711 // build a list of used keys for this specific itemID...
667 foreach (KeyValuePair<int,List<ListenerInfo>> lis in m_listeners) 712 foreach (KeyValuePair<int, List<ListenerInfo>> lis in m_listeners)
668 { 713 {
669 foreach (ListenerInfo li in lis.Value) 714 foreach (ListenerInfo li in lis.Value)
670 { 715 {
671 if (li.GetItemID().Equals(itemID)) 716 if (li.GetItemID().Equals(itemID))
672 handles.Add(li.GetHandle()); 717 handles.Add(li.GetHandle());
673 } 718 }
674 } 719 }
675 720
676 // Note: 0 is NOT a valid handle for llListen() to return 721 // Note: 0 is NOT a valid handle for llListen() to return
@@ -709,7 +754,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
709 lock (m_listeners) 754 lock (m_listeners)
710 { 755 {
711 List<ListenerInfo> listeners; 756 List<ListenerInfo> listeners;
712 if (!m_listeners.TryGetValue(channel,out listeners)) 757 if (!m_listeners.TryGetValue(channel, out listeners))
713 { 758 {
714 return collection; 759 return collection;
715 } 760 }
@@ -720,7 +765,8 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
720 { 765 {
721 continue; 766 continue;
722 } 767 }
723 if (!itemID.Equals(UUID.Zero) && !li.GetItemID().Equals(itemID)) 768 if (!itemID.Equals(UUID.Zero) &&
769 !li.GetItemID().Equals(itemID))
724 { 770 {
725 continue; 771 continue;
726 } 772 }
@@ -785,11 +831,14 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
785 lock (m_listeners) 831 lock (m_listeners)
786 { 832 {
787 if (!m_listeners.ContainsKey((int)item[2])) 833 if (!m_listeners.ContainsKey((int)item[2]))
788 m_listeners.Add((int)item[2], new List<ListenerInfo>()); 834 {
835 m_listeners.Add((int)item[2],
836 new List<ListenerInfo>());
837 }
789 m_listeners[(int)item[2]].Add(info); 838 m_listeners[(int)item[2]].Add(info);
790 } 839 }
791 840
792 idx+=dataItemLength; 841 idx += dataItemLength;
793 } 842 }
794 } 843 }
795 } 844 }
@@ -820,17 +869,23 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
820 message, regexBitfield); 869 message, regexBitfield);
821 } 870 }
822 871
823 public ListenerInfo(ListenerInfo li, string name, UUID id, string message) 872 public ListenerInfo(ListenerInfo li, string name, UUID id,
873 string message)
824 { 874 {
825 Initialise(li.m_handle, li.m_localID, li.m_itemID, li.m_hostID, li.m_channel, name, id, message, 0); 875 Initialise(li.m_handle, li.m_localID, li.m_itemID, li.m_hostID,
876 li.m_channel, name, id, message, 0);
826 } 877 }
827 878
828 public ListenerInfo(ListenerInfo li, string name, UUID id, string message, int regexBitfield) 879 public ListenerInfo(ListenerInfo li, string name, UUID id,
880 string message, int regexBitfield)
829 { 881 {
830 Initialise(li.m_handle, li.m_localID, li.m_itemID, li.m_hostID, li.m_channel, name, id, message, regexBitfield); 882 Initialise(li.m_handle, li.m_localID, li.m_itemID, li.m_hostID,
883 li.m_channel, name, id, message, regexBitfield);
831 } 884 }
832 885
833 private void Initialise(int handle, uint localID, UUID ItemID, UUID hostID, int channel, string name, UUID id, string message, int regexBitfield) 886 private void Initialise(int handle, uint localID, UUID ItemID,
887 UUID hostID, int channel, string name, UUID id,
888 string message, int regexBitfield)
834 { 889 {
835 m_active = true; 890 m_active = true;
836 m_handle = handle; 891 m_handle = handle;
@@ -859,9 +914,12 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
859 return data; 914 return data;
860 } 915 }
861 916
862 public static ListenerInfo FromData(uint localID, UUID ItemID, UUID hostID, Object[] data) 917 public static ListenerInfo FromData(uint localID, UUID ItemID,
918 UUID hostID, Object[] data)
863 { 919 {
864 ListenerInfo linfo = new ListenerInfo((int)data[1], localID, ItemID, hostID, (int)data[2], (string)data[3], (UUID)data[4], (string)data[5]); 920 ListenerInfo linfo = new ListenerInfo((int)data[1], localID,
921 ItemID, hostID, (int)data[2], (string)data[3],
922 (UUID)data[4], (string)data[5]);
865 linfo.m_active = (bool)data[0]; 923 linfo.m_active = (bool)data[0];
866 if (data.Length >= 7) 924 if (data.Length >= 7)
867 { 925 {