From f42d085ab17098709bcba0c816c9742a213d3c01 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Wed, 16 Sep 2009 15:06:08 -0700 Subject: SceneObjectGroup cleanup. Removes the default constructor and unnecessary null checks on m_rootPart --- OpenSim/Data/NHibernate/NHibernateRegionData.cs | 32 +++++++++++++++++-------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'OpenSim/Data/NHibernate') diff --git a/OpenSim/Data/NHibernate/NHibernateRegionData.cs b/OpenSim/Data/NHibernate/NHibernateRegionData.cs index 26ec500..673ca6f 100644 --- a/OpenSim/Data/NHibernate/NHibernateRegionData.cs +++ b/OpenSim/Data/NHibernate/NHibernateRegionData.cs @@ -178,25 +178,38 @@ namespace OpenSim.Data.NHibernate private SceneObjectGroup LoadObject(UUID uuid, UUID region) { - SceneObjectGroup group = new SceneObjectGroup(); - ICriteria criteria = manager.GetSession().CreateCriteria(typeof(SceneObjectPart)); criteria.Add(Expression.Eq("RegionID", region)); criteria.Add(Expression.Eq("ParentUUID", uuid)); criteria.AddOrder(Order.Asc("ParentID")); - foreach (SceneObjectPart p in criteria.List()) + IList parts = criteria.List(); + + SceneObjectGroup group = null; + + // Find the root part + for (int i = 0; i < parts.Count; i++) { - // root part - if (p.UUID == uuid) + if (parts[i].UUID == uuid) { - group.SetRootPart(p); + group = new SceneObjectGroup(parts[i]); + break; } - else + } + + // Add the children parts + if (group != null) + { + for (int i = 0; i < parts.Count; i++) { - group.AddPart(p); + if (parts[i].UUID != uuid) + group.AddPart(parts[i]); } } + else + { + m_log.Error("[NHIBERNATE]: LoadObject() Attempted to load a SceneObjectGroup with no root SceneObjectPart "); + } return group; } @@ -237,8 +250,7 @@ namespace OpenSim.Data.NHibernate // root part if (p.UUID == p.ParentUUID) { - SceneObjectGroup group = new SceneObjectGroup(); - group.SetRootPart(p); + SceneObjectGroup group = new SceneObjectGroup(p); SOG.Add(p.ParentUUID, group); } else -- cgit v1.1