aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs237
1 files changed, 21 insertions, 216 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index e9e1fa3..8de31d7 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -3687,12 +3687,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3687 avgTimeDilation += update.TimeDilation; 3687 avgTimeDilation += update.TimeDilation;
3688 avgTimeDilation *= 0.5f; 3688 avgTimeDilation *= 0.5f;
3689 3689
3690// <MIC>
3691// DEBUGGING CODE... REMOVE
3692// if (update.Entity is ScenePresence)
3693// LogAvatarUpdateEvent(this.m_agentId,update.Entity.UUID,timeinqueue);
3694// </MIC>
3695
3696 if (update.Entity is SceneObjectPart) 3690 if (update.Entity is SceneObjectPart)
3697 { 3691 {
3698 SceneObjectPart part = (SceneObjectPart)update.Entity; 3692 SceneObjectPart part = (SceneObjectPart)update.Entity;
@@ -5017,7 +5011,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5017 AddLocalPacketHandler(PacketType.TeleportLocationRequest, HandleTeleportLocationRequest); 5011 AddLocalPacketHandler(PacketType.TeleportLocationRequest, HandleTeleportLocationRequest);
5018 AddLocalPacketHandler(PacketType.UUIDNameRequest, HandleUUIDNameRequest, false); 5012 AddLocalPacketHandler(PacketType.UUIDNameRequest, HandleUUIDNameRequest, false);
5019 AddLocalPacketHandler(PacketType.RegionHandleRequest, HandleRegionHandleRequest); 5013 AddLocalPacketHandler(PacketType.RegionHandleRequest, HandleRegionHandleRequest);
5020 AddLocalPacketHandler(PacketType.ParcelInfoRequest, HandleParcelInfoRequest, false); 5014 AddLocalPacketHandler(PacketType.ParcelInfoRequest, HandleParcelInfoRequest);
5021 AddLocalPacketHandler(PacketType.ParcelAccessListRequest, HandleParcelAccessListRequest, false); 5015 AddLocalPacketHandler(PacketType.ParcelAccessListRequest, HandleParcelAccessListRequest, false);
5022 AddLocalPacketHandler(PacketType.ParcelAccessListUpdate, HandleParcelAccessListUpdate, false); 5016 AddLocalPacketHandler(PacketType.ParcelAccessListUpdate, HandleParcelAccessListUpdate, false);
5023 AddLocalPacketHandler(PacketType.ParcelPropertiesRequest, HandleParcelPropertiesRequest, false); 5017 AddLocalPacketHandler(PacketType.ParcelPropertiesRequest, HandleParcelPropertiesRequest, false);
@@ -8888,13 +8882,29 @@ namespace OpenSim.Region.ClientStack.LindenUDP
8888 case "instantmessage": 8882 case "instantmessage":
8889 if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) 8883 if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
8890 { 8884 {
8891 if (messagePacket.ParamList.Length < 5) 8885 if (messagePacket.ParamList.Length < 2)
8892 return true; 8886 return true;
8887
8893 UUID invoice = messagePacket.MethodData.Invoice; 8888 UUID invoice = messagePacket.MethodData.Invoice;
8894 UUID SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
8895 string SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter);
8896 string Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter);
8897 UUID sessionID = messagePacket.AgentData.SessionID; 8889 UUID sessionID = messagePacket.AgentData.SessionID;
8890
8891 UUID SenderID;
8892 string SenderName;
8893 string Message;
8894
8895 if (messagePacket.ParamList.Length < 5)
8896 {
8897 SenderID = AgentId;
8898 SenderName = Utils.BytesToString(messagePacket.ParamList[0].Parameter);
8899 Message = Utils.BytesToString(messagePacket.ParamList[1].Parameter);
8900 }
8901 else
8902 {
8903 SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
8904 SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter);
8905 Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter);
8906 }
8907
8898 OnEstateBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message); 8908 OnEstateBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message);
8899 } 8909 }
8900 return true; 8910 return true;
@@ -11789,209 +11799,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11789 OutPacket(pack, ThrottleOutPacketType.Task); 11799 OutPacket(pack, ThrottleOutPacketType.Task);
11790 } 11800 }
11791 11801
11792 #region PriorityQueue
11793 public class PriorityQueue
11794 {
11795 internal delegate bool UpdatePriorityHandler(ref uint priority, ISceneEntity entity);
11796
11797 // Heap[0] for self updates
11798 // Heap[1..12] for entity updates
11799
11800 internal const uint m_numberOfQueues = 12;
11801 private MinHeap<MinHeapItem>[] m_heaps = new MinHeap<MinHeapItem>[m_numberOfQueues];
11802 private Dictionary<uint, LookupItem> m_lookupTable;
11803 private object m_syncRoot = new object();
11804 private uint m_nextQueue = 0;
11805 private UInt64 m_nextRequest = 0;
11806
11807 internal PriorityQueue() :
11808 this(MinHeap<MinHeapItem>.DEFAULT_CAPACITY) { }
11809 internal PriorityQueue(int capacity)
11810 {
11811 m_lookupTable = new Dictionary<uint, LookupItem>(capacity);
11812
11813 for (int i = 0; i < m_heaps.Length; ++i)
11814 m_heaps[i] = new MinHeap<MinHeapItem>(capacity);
11815 }
11816
11817 public object SyncRoot { get { return this.m_syncRoot; } }
11818
11819 internal int Count
11820 {
11821 get
11822 {
11823 int count = 0;
11824 for (int i = 0; i < m_heaps.Length; ++i)
11825 count += m_heaps[i].Count;
11826 return count;
11827 }
11828 }
11829
11830 public bool Enqueue(uint pqueue, EntityUpdate value)
11831 {
11832 LookupItem lookup;
11833
11834 uint localid = value.Entity.LocalId;
11835 UInt64 entry = m_nextRequest++;
11836 if (m_lookupTable.TryGetValue(localid, out lookup))
11837 {
11838 entry = lookup.Heap[lookup.Handle].EntryOrder;
11839 value.Flags |= lookup.Heap[lookup.Handle].Value.Flags;
11840 lookup.Heap.Remove(lookup.Handle);
11841 }
11842
11843 pqueue = Util.Clamp<uint>(pqueue, 0, m_numberOfQueues - 1);
11844 lookup.Heap = m_heaps[pqueue];
11845 lookup.Heap.Add(new MinHeapItem(pqueue, entry, value), ref lookup.Handle);
11846 m_lookupTable[localid] = lookup;
11847
11848 return true;
11849 }
11850
11851 internal bool TryDequeue(out EntityUpdate value, out Int32 timeinqueue)
11852 {
11853 for (int i = 0; i < m_numberOfQueues; ++i)
11854 {
11855 // To get the fair queing, we cycle through each of the
11856 // queues when finding an element to dequeue, this code
11857 // assumes that the distribution of updates in the queues
11858 // is polynomial, probably quadractic (eg distance of PI * R^2)
11859 uint h = (uint)((m_nextQueue + i) % m_numberOfQueues);
11860 if (m_heaps[h].Count > 0)
11861 {
11862 m_nextQueue = (uint)((h + 1) % m_numberOfQueues);
11863
11864 MinHeapItem item = m_heaps[h].RemoveMin();
11865 m_lookupTable.Remove(item.Value.Entity.LocalId);
11866 timeinqueue = Util.EnvironmentTickCountSubtract(item.EntryTime);
11867 value = item.Value;
11868
11869 return true;
11870 }
11871 }
11872
11873 timeinqueue = 0;
11874 value = default(EntityUpdate);
11875 return false;
11876 }
11877
11878 internal void Reprioritize(UpdatePriorityHandler handler)
11879 {
11880 MinHeapItem item;
11881 foreach (LookupItem lookup in new List<LookupItem>(this.m_lookupTable.Values))
11882 {
11883 if (lookup.Heap.TryGetValue(lookup.Handle, out item))
11884 {
11885 uint pqueue = item.PriorityQueue;
11886 uint localid = item.Value.Entity.LocalId;
11887
11888 if (handler(ref pqueue, item.Value.Entity))
11889 {
11890 // unless the priority queue has changed, there is no need to modify
11891 // the entry
11892 pqueue = Util.Clamp<uint>(pqueue, 0, m_numberOfQueues - 1);
11893 if (pqueue != item.PriorityQueue)
11894 {
11895 lookup.Heap.Remove(lookup.Handle);
11896
11897 LookupItem litem = lookup;
11898 litem.Heap = m_heaps[pqueue];
11899 litem.Heap.Add(new MinHeapItem(pqueue, item), ref litem.Handle);
11900 m_lookupTable[localid] = litem;
11901 }
11902 }
11903 else
11904 {
11905 m_log.WarnFormat("[LLCLIENTVIEW]: UpdatePriorityHandler returned false for {0}",item.Value.Entity.UUID);
11906 lookup.Heap.Remove(lookup.Handle);
11907 this.m_lookupTable.Remove(localid);
11908 }
11909 }
11910 }
11911 }
11912
11913 public override string ToString()
11914 {
11915 string s = "";
11916 for (int i = 0; i < m_numberOfQueues; i++)
11917 {
11918 if (s != "") s += ",";
11919 s += m_heaps[i].Count.ToString();
11920 }
11921 return s;
11922 }
11923
11924 #region MinHeapItem
11925 private struct MinHeapItem : IComparable<MinHeapItem>
11926 {
11927 private EntityUpdate value;
11928 internal EntityUpdate Value {
11929 get {
11930 return this.value;
11931 }
11932 }
11933
11934 private uint pqueue;
11935 internal uint PriorityQueue {
11936 get {
11937 return this.pqueue;
11938 }
11939 }
11940
11941 private Int32 entrytime;
11942 internal Int32 EntryTime {
11943 get {
11944 return this.entrytime;
11945 }
11946 }
11947
11948 private UInt64 entryorder;
11949 internal UInt64 EntryOrder
11950 {
11951 get {
11952 return this.entryorder;
11953 }
11954 }
11955
11956 internal MinHeapItem(uint pqueue, MinHeapItem other)
11957 {
11958 this.entrytime = other.entrytime;
11959 this.entryorder = other.entryorder;
11960 this.value = other.value;
11961 this.pqueue = pqueue;
11962 }
11963
11964 internal MinHeapItem(uint pqueue, UInt64 entryorder, EntityUpdate value)
11965 {
11966 this.entrytime = Util.EnvironmentTickCount();
11967 this.entryorder = entryorder;
11968 this.value = value;
11969 this.pqueue = pqueue;
11970 }
11971
11972 public override string ToString()
11973 {
11974 return String.Format("[{0},{1},{2}]",pqueue,entryorder,value.Entity.LocalId);
11975 }
11976
11977 public int CompareTo(MinHeapItem other)
11978 {
11979 // I'm assuming that the root part of an SOG is added to the update queue
11980 // before the component parts
11981 return Comparer<UInt64>.Default.Compare(this.EntryOrder, other.EntryOrder);
11982 }
11983 }
11984 #endregion
11985
11986 #region LookupItem
11987 private struct LookupItem
11988 {
11989 internal MinHeap<MinHeapItem> Heap;
11990 internal IHandle Handle;
11991 }
11992 #endregion
11993 }
11994
11995 public struct PacketProcessor 11802 public struct PacketProcessor
11996 { 11803 {
11997 public PacketMethod method; 11804 public PacketMethod method;
@@ -12012,8 +11819,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
12012 } 11819 }
12013 } 11820 }
12014 11821
12015 #endregion
12016
12017 public static OSD BuildEvent(string eventName, OSD eventBody) 11822 public static OSD BuildEvent(string eventName, OSD eventBody)
12018 { 11823 {
12019 OSDMap osdEvent = new OSDMap(2); 11824 OSDMap osdEvent = new OSDMap(2);