From 24aedf52c6b903720f588694880e9613b115cc0c Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Fri, 14 Mar 2008 15:28:34 +0000 Subject: [PATCH] * Added null root part guard * Normalized some UUID handling * Compacted a few Contains/Add into Set --- .../Region/Environment/Scenes/EntityBase.cs | 2 +- .../Region/Environment/Scenes/InnerScene.cs | 27 +++++-------------- .../Environment/Scenes/SceneObjectGroup.cs | 10 ++++++- .../Environment/Scenes/SceneObjectPart.cs | 1 + .../3Di/LoadBalancer/LoadBalancerPlugin.cs | 14 +++++----- 5 files changed, 25 insertions(+), 29 deletions(-) diff --git a/OpenSim/Region/Environment/Scenes/EntityBase.cs b/OpenSim/Region/Environment/Scenes/EntityBase.cs index 2a8c1e940f..670ca1392f 100644 --- a/OpenSim/Region/Environment/Scenes/EntityBase.cs +++ b/OpenSim/Region/Environment/Scenes/EntityBase.cs @@ -46,7 +46,7 @@ namespace OpenSim.Region.Environment.Scenes get { return m_scene; } } - public LLUUID m_uuid; + protected LLUUID m_uuid; public virtual LLUUID UUID { diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index 053fc85fdd..c75ca8176f 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs @@ -489,40 +489,27 @@ namespace OpenSim.Region.Environment.Scenes if (child) { m_numChildAgents++; - m_log.Info("[SCENE]"+ m_regInfo.RegionName + ": Creating new child agent."); + m_log.Info("[SCENE]" + m_regInfo.RegionName + ": Creating new child agent."); } else { m_numRootAgents++; - m_log.Info("[SCENE] "+ m_regInfo.RegionName + ": Creating new root agent."); - m_log.Info("[SCENE] "+ m_regInfo.RegionName + ": Adding Physical agent."); + m_log.Info("[SCENE] " + m_regInfo.RegionName + ": Creating new root agent."); + m_log.Info("[SCENE] " + m_regInfo.RegionName + ": Adding Physical agent."); presence.AddToPhysicalScene(); } lock (Entities) { - if (!Entities.ContainsKey(presence.m_uuid)) - { - Entities.Add(presence.m_uuid, presence); - } - else - { - Entities[presence.m_uuid] = presence; - } + Entities[presence.UUID] = presence; } + lock (ScenePresences) { - if (ScenePresences.ContainsKey(presence.m_uuid)) - { - ScenePresences[presence.m_uuid] = presence; - } - else - { - ScenePresences.Add(presence.m_uuid, presence); - } + ScenePresences[presence.UUID] = presence; } - } + } public void SwapRootChildAgent(bool direction_RC_CR_T_F) { diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 47c4567a79..e295f87ed3 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -123,7 +123,15 @@ namespace OpenSim.Region.Environment.Scenes public override LLVector3 AbsolutePosition { - get { return m_rootPart.GroupPosition; } + get + { + if( m_rootPart == null ) + { + throw new NullReferenceException(string.Format("Object {0} has no root part.", m_uuid)); + } + + return m_rootPart.GroupPosition; + } set { LLVector3 val = value; diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index 5b3ea0fbdc..060003e8f6 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -270,6 +270,7 @@ namespace OpenSim.Region.Environment.Scenes m_groupPosition.Y = PhysActor.Position.Y; m_groupPosition.Z = PhysActor.Position.Z; } + return m_groupPosition; } set diff --git a/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs b/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs index 27fa1481a7..325385a71c 100644 --- a/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs +++ b/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs @@ -438,9 +438,9 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer string filename; IClientAPI controller = null; - m_log.InfoFormat("[BALANCER] "+"agent id : {0}", pre.m_uuid); + m_log.InfoFormat("[BALANCER] "+"agent id : {0}", pre.UUID); - uint[] circuits = scene.ClientManager.GetAllCircuits(pre.m_uuid); + uint[] circuits = scene.ClientManager.GetAllCircuits(pre.UUID); foreach (uint code in circuits) { @@ -535,12 +535,12 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer } sp = (ScenePresence)Util.DeserializeFromFile(filename); - Console.WriteLine("agent id = {0}", sp.m_uuid); + Console.WriteLine("agent id = {0}", sp.UUID); - scene.m_restorePresences.Add(sp.m_uuid, sp); + scene.m_restorePresences.Add(sp.UUID, sp); File.Delete(filename); - m_log.InfoFormat("[BALANCER] " + "scene presence deserialized [{0}]", sp.m_uuid); + m_log.InfoFormat("[BALANCER] " + "scene presence deserialized [{0}]", sp.UUID); // restore the ClientView @@ -645,7 +645,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer // remove all scene presences foreach (ScenePresence pre in presences) { - uint[] circuits = scene.ClientManager.GetAllCircuits(pre.m_uuid); + uint[] circuits = scene.ClientManager.GetAllCircuits(pre.UUID); foreach (uint code in circuits) { @@ -666,7 +666,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer } // remove scene presence - scene.RemoveClient(pre.m_uuid); + scene.RemoveClient(pre.UUID); } }