From 13526097f24b7a8ad63b1d482c44b44397fa055f Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 1 May 2008 16:35:00 +0000 Subject: * Spring cleaning on Region.Environment. * Converted a large number of read-only fields to be actually, readonly. * Reformatted code sections. * Removed redundant code. --- .../Region/Environment/Types/BasicQuadTreeNode.cs | 53 ++++++----- OpenSim/Region/Environment/Types/UpdateQueue.cs | 103 +++++++++++---------- 2 files changed, 79 insertions(+), 77 deletions(-) (limited to 'OpenSim/Region/Environment/Types') diff --git a/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs b/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs index 24ce94b..41f17e5 100644 --- a/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs +++ b/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs @@ -33,16 +33,15 @@ namespace OpenSim.Region.Environment.Types { public class BasicQuadTreeNode { - private List m_objects = new List(); - private BasicQuadTreeNode[] m_childNodes = null; - private BasicQuadTreeNode m_parent = null; - - private short m_leftX; - private short m_leftY; - private short m_width; - private short m_height; + private readonly short m_height; + private readonly short m_leftX; + private readonly short m_leftY; + private readonly List m_objects = new List(); + private readonly BasicQuadTreeNode m_parent; //private int m_quadNumber; - private string m_quadID; + private readonly string m_quadID; + private readonly short m_width; + private BasicQuadTreeNode[] m_childNodes; public BasicQuadTreeNode(BasicQuadTreeNode parent, string quadID, short leftX, short leftY, short width, short height) @@ -67,9 +66,9 @@ namespace OpenSim.Region.Environment.Types } else { - if (obj.AbsolutePosition.X < (m_leftX + (m_width/2))) + if (obj.AbsolutePosition.X < (m_leftX + (m_width / 2))) { - if (obj.AbsolutePosition.Y < (m_leftY + (m_height/2))) + if (obj.AbsolutePosition.Y < (m_leftY + (m_height / 2))) { m_childNodes[0].AddObject(obj); } @@ -80,7 +79,7 @@ namespace OpenSim.Region.Environment.Types } else { - if (obj.AbsolutePosition.Y < (m_leftY + (m_height/2))) + if (obj.AbsolutePosition.Y < (m_leftY + (m_height / 2))) { m_childNodes[1].AddObject(obj); } @@ -98,17 +97,17 @@ namespace OpenSim.Region.Environment.Types { m_childNodes = new BasicQuadTreeNode[4]; m_childNodes[0] = - new BasicQuadTreeNode(this, m_quadID + "1/", m_leftX, m_leftY, (short) (m_width/2), - (short) (m_height/2)); + new BasicQuadTreeNode(this, m_quadID + "1/", m_leftX, m_leftY, (short) (m_width / 2), + (short) (m_height / 2)); m_childNodes[1] = - new BasicQuadTreeNode(this, m_quadID + "2/", (short) (m_leftX + (m_width/2)), m_leftY, - (short) (m_width/2), (short) (m_height/2)); + new BasicQuadTreeNode(this, m_quadID + "2/", (short) (m_leftX + (m_width / 2)), m_leftY, + (short) (m_width / 2), (short) (m_height / 2)); m_childNodes[2] = - new BasicQuadTreeNode(this, m_quadID + "3/", m_leftX, (short) (m_leftY + (m_height/2)), - (short) (m_width/2), (short) (m_height/2)); + new BasicQuadTreeNode(this, m_quadID + "3/", m_leftX, (short) (m_leftY + (m_height / 2)), + (short) (m_width / 2), (short) (m_height / 2)); m_childNodes[3] = - new BasicQuadTreeNode(this, m_quadID + "4/", (short) (m_leftX + (m_width/2)), - (short) (m_height + (m_height/2)), (short) (m_width/2), (short) (m_height/2)); + new BasicQuadTreeNode(this, m_quadID + "4/", (short) (m_leftX + (m_width / 2)), + (short) (m_height + (m_height / 2)), (short) (m_width / 2), (short) (m_height / 2)); } else { @@ -127,9 +126,9 @@ namespace OpenSim.Region.Environment.Types } else { - if (x < m_leftX + (m_width/2)) + if (x < m_leftX + (m_width / 2)) { - if (y < m_leftY + (m_height/2)) + if (y < m_leftY + (m_height / 2)) { return m_childNodes[0].GetObjectsFrom(x, y); } @@ -140,7 +139,7 @@ namespace OpenSim.Region.Environment.Types } else { - if (y < m_leftY + (m_height/2)) + if (y < m_leftY + (m_height / 2)) { return m_childNodes[1].GetObjectsFrom(x, y); } @@ -181,9 +180,9 @@ namespace OpenSim.Region.Environment.Types } else { - if (x < m_leftX + (m_width/2)) + if (x < m_leftX + (m_width / 2)) { - if (y < m_leftY + (m_height/2)) + if (y < m_leftY + (m_height / 2)) { return m_childNodes[0].GetNodeID(x, y); } @@ -194,7 +193,7 @@ namespace OpenSim.Region.Environment.Types } else { - if (y < m_leftY + (m_height/2)) + if (y < m_leftY + (m_height / 2)) { return m_childNodes[1].GetNodeID(x, y); } @@ -266,4 +265,4 @@ namespace OpenSim.Region.Environment.Types return retVal; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Types/UpdateQueue.cs b/OpenSim/Region/Environment/Types/UpdateQueue.cs index ec1ffd2..24fe116 100644 --- a/OpenSim/Region/Environment/Types/UpdateQueue.cs +++ b/OpenSim/Region/Environment/Types/UpdateQueue.cs @@ -34,26 +34,70 @@ using OpenSim.Region.Environment.Scenes; namespace OpenSim.Region.Environment.Types { - [Serializable] - public class UpdateQueue : ISerializable + [Serializable] + public class UpdateQueue : ISerializable { - private Queue m_queue; + private readonly List m_ids; + private readonly Queue m_queue; - private List m_ids; + private readonly object m_syncObject = new object(); - private object m_syncObject = new object(); + public UpdateQueue() + { + m_queue = new Queue(); + m_ids = new List(); + } + + protected UpdateQueue(SerializationInfo info, StreamingContext context) + { + //System.Console.WriteLine("UpdateQueue Deserialize BGN"); + + if (info == null) + { + throw new ArgumentNullException("info"); + } + + m_queue = (Queue) info.GetValue("m_queue", typeof (Queue)); + List ids_work = (List) info.GetValue("m_ids", typeof (List)); + + foreach (Guid guid in ids_work) + { + m_ids.Add(new LLUUID(guid)); + } + + //System.Console.WriteLine("UpdateQueue Deserialize END"); + } public int Count { get { return m_queue.Count; } } - public UpdateQueue() + #region ISerializable Members + + [SecurityPermission(SecurityAction.LinkDemand, + Flags = SecurityPermissionFlag.SerializationFormatter)] + public virtual void GetObjectData( + SerializationInfo info, StreamingContext context) { - m_queue = new Queue(); - m_ids = new List(); + if (info == null) + { + throw new ArgumentNullException("info"); + } + + List ids_work = new List(); + + foreach (LLUUID uuid in m_ids) + { + ids_work.Add(uuid.UUID); + } + + info.AddValue("m_queue", m_queue); + info.AddValue("m_ids", ids_work); } + #endregion + public void Clear() { lock (m_syncObject) @@ -89,46 +133,5 @@ namespace OpenSim.Region.Environment.Types return part; } - - protected UpdateQueue(SerializationInfo info, StreamingContext context) - { - //System.Console.WriteLine("UpdateQueue Deserialize BGN"); - - if (info == null) - { - throw new ArgumentNullException("info"); - } - - m_queue = (Queue)info.GetValue("m_queue", typeof(Queue)); - List ids_work = (List)info.GetValue("m_ids", typeof(List)); - - foreach (Guid guid in ids_work) - { - m_ids.Add(new LLUUID(guid)); - } - - //System.Console.WriteLine("UpdateQueue Deserialize END"); - } - - [SecurityPermission(SecurityAction.LinkDemand, - Flags = SecurityPermissionFlag.SerializationFormatter)] - public virtual void GetObjectData( - SerializationInfo info, StreamingContext context) - { - if (info == null) - { - throw new ArgumentNullException("info"); - } - - List ids_work = new List(); - - foreach (LLUUID uuid in m_ids) - { - ids_work.Add(uuid.UUID); - } - - info.AddValue("m_queue", m_queue); - info.AddValue("m_ids", ids_work); - } } -} +} \ No newline at end of file -- cgit v1.1