aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/NHibernate/NHibernateRegionData.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/NHibernate/NHibernateRegionData.cs')
-rw-r--r--OpenSim/Data/NHibernate/NHibernateRegionData.cs35
1 files changed, 23 insertions, 12 deletions
diff --git a/OpenSim/Data/NHibernate/NHibernateRegionData.cs b/OpenSim/Data/NHibernate/NHibernateRegionData.cs
index 38c9b9f..fb0a545 100644
--- a/OpenSim/Data/NHibernate/NHibernateRegionData.cs
+++ b/OpenSim/Data/NHibernate/NHibernateRegionData.cs
@@ -120,13 +120,14 @@ namespace OpenSim.Data.NHibernate
120 { 120 {
121 ICriteria criteria = session.CreateCriteria(typeof(SceneObjectPart)); 121 ICriteria criteria = session.CreateCriteria(typeof(SceneObjectPart));
122 criteria.Add(Expression.Eq("UUID", p.UUID)); 122 criteria.Add(Expression.Eq("UUID", p.UUID));
123 if (criteria.List().Count < 1) 123 ArrayList l = (ArrayList)criteria.List();
124 if (l.Count < 1)
124 { 125 {
125 session.Save(p); 126 session.Save(p);
126 } 127 }
127 else if (criteria.List().Count == 1) 128 else if (l.Count == 1)
128 { 129 {
129 SceneObjectPart old = (SceneObjectPart)criteria.List()[0]; 130 SceneObjectPart old = (SceneObjectPart)l[0];
130 session.Evict(old); 131 session.Evict(old);
131 session.Update(p); 132 session.Update(p);
132 } 133 }
@@ -147,13 +148,14 @@ namespace OpenSim.Data.NHibernate
147 { 148 {
148 ICriteria criteria = session.CreateCriteria(typeof(Terrain)); 149 ICriteria criteria = session.CreateCriteria(typeof(Terrain));
149 criteria.Add(Expression.Eq("RegionID", t.RegionID)); 150 criteria.Add(Expression.Eq("RegionID", t.RegionID));
150 if (criteria.List().Count < 1) 151 ArrayList l = (ArrayList)criteria.List();
152 if (l.Count < 1)
151 { 153 {
152 session.Save(t); 154 session.Save(t);
153 } 155 }
154 else if (criteria.List().Count == 1) 156 else if (l.Count == 1)
155 { 157 {
156 Terrain old = (Terrain)criteria.List()[0]; 158 Terrain old = (Terrain)l[0];
157 session.Evict(old); 159 session.Evict(old);
158 session.Update(t); 160 session.Update(t);
159 } 161 }
@@ -278,7 +280,8 @@ namespace OpenSim.Data.NHibernate
278 /// <param name="regionID">region UUID</param> 280 /// <param name="regionID">region UUID</param>
279 public void StoreTerrain(double[,] ter, LLUUID regionID) 281 public void StoreTerrain(double[,] ter, LLUUID regionID)
280 { 282 {
281 283 Terrain t = new Terrain(regionID, ter);
284 SaveOrUpdate(t);
282 } 285 }
283 286
284 /// <summary> 287 /// <summary>
@@ -288,11 +291,19 @@ namespace OpenSim.Data.NHibernate
288 /// <returns>Heightfield data</returns> 291 /// <returns>Heightfield data</returns>
289 public double[,] LoadTerrain(LLUUID regionID) 292 public double[,] LoadTerrain(LLUUID regionID)
290 { 293 {
291 double[,] terret = new double[256,256]; 294 try
292 terret.Initialize(); 295 {
293 296 Terrain t = session.Load(typeof(Terrain), regionID) as Terrain;
294 297 return t.Doubles;
295 return terret; 298 }
299 catch (Exception e)
300 {
301 m_log.Error("[NHIBERNATE] issue loading terrain", e);
302
303 double[,] terret = new double[256,256];
304 terret.Initialize();
305 return terret;
306 }
296 } 307 }
297 308
298 /// <summary> 309 /// <summary>