diff --git a/OpenSim/Data/NHibernate/NHibernateRegionData.cs b/OpenSim/Data/NHibernate/NHibernateRegionData.cs index 8ca0afe98c..3ba3556322 100644 --- a/OpenSim/Data/NHibernate/NHibernateRegionData.cs +++ b/OpenSim/Data/NHibernate/NHibernateRegionData.cs @@ -26,6 +26,7 @@ */ using System; +using System.Collections; using System.Collections.Generic; using System.IO; using System.Reflection; @@ -112,6 +113,33 @@ namespace OpenSim.Data.NHibernate { return null; } + + private void SaveOrUpdate(SceneObjectPart p) + { + try + { + ICriteria criteria = session.CreateCriteria(typeof(SceneObjectPart)); + criteria.Add(Expression.Eq("UUID", p.UUID)); + if (criteria.List().Count < 1) + { + session.Save(p); + } + else if (criteria.List().Count == 1) + { + SceneObjectPart old = (SceneObjectPart)criteria.List()[0]; + session.Evict(old); + session.Update(p); + } + else + { + m_log.Error("Not unique"); + } + } + catch (Exception e) + { + m_log.Error("[NHIBERNATE] issue saving asset", e); + } + } /// /// Adds an object into region storage @@ -125,7 +153,7 @@ namespace OpenSim.Data.NHibernate foreach (SceneObjectPart part in obj.Children.Values) { m_log.InfoFormat("Storing part {0}", part.UUID); - session.SaveOrUpdate(part); + SaveOrUpdate(part); } session.Flush(); } diff --git a/OpenSim/Data/NHibernate/Resources/RegionStore.hbm.xml b/OpenSim/Data/NHibernate/Resources/RegionStore.hbm.xml index 5b8b7f233e..40d3864f60 100644 --- a/OpenSim/Data/NHibernate/Resources/RegionStore.hbm.xml +++ b/OpenSim/Data/NHibernate/Resources/RegionStore.hbm.xml @@ -82,7 +82,26 @@ - + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim/Data/NHibernate/TextureUserType.cs b/OpenSim/Data/NHibernate/TextureUserType.cs index dac7c75432..b688a1612b 100644 --- a/OpenSim/Data/NHibernate/TextureUserType.cs +++ b/OpenSim/Data/NHibernate/TextureUserType.cs @@ -49,8 +49,16 @@ namespace OpenSim.Data.NHibernate public object DeepCopy(object texture) { - byte[] bytes = ((LLObject.TextureEntry)texture).ToBytes(); - return new LLObject.TextureEntry(bytes, 0, bytes.Length); + if (texture == null) + { + // TODO: should parametrize this texture out + return new LLObject.TextureEntry(new LLUUID("89556747-24cb-43ed-920b-47caed15465f")); + } + else + { + byte[] bytes = ((LLObject.TextureEntry)texture).ToBytes(); + return new LLObject.TextureEntry(bytes, 0, bytes.Length); + } } public object Disassemble(object texture) diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs index bdd98584bb..5657b66e92 100644 --- a/OpenSim/Framework/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/PrimitiveBaseShape.cs @@ -197,7 +197,13 @@ namespace OpenSim.Framework { get { return m_textureEntry; } - set { m_textureEntry = value; } + set + { + if (value == null) + m_textureEntry = new byte[1]; + else + m_textureEntry = value; + } } @@ -838,6 +844,9 @@ namespace OpenSim.Framework public void ReadInExtraParamsBytes(byte[] data) { + if (data == null) + return; + const ushort FlexiEP = 0x10; const ushort LightEP = 0x20; const ushort SculptEP = 0x30;