diff options
author | Sean Dague | 2008-07-17 20:58:20 +0000 |
---|---|---|
committer | Sean Dague | 2008-07-17 20:58:20 +0000 |
commit | 4663999c243e7ac6f05f3bb6b76fefb2ff285134 (patch) | |
tree | d99fbe2b410de768c1775db45396cf1a22610339 /OpenSim/Data/NHibernate/NHibernateRegionData.cs | |
parent | add a Terrain object for the purpose of mapping. This may make sense (diff) | |
download | opensim-SC-4663999c243e7ac6f05f3bb6b76fefb2ff285134.zip opensim-SC-4663999c243e7ac6f05f3bb6b76fefb2ff285134.tar.gz opensim-SC-4663999c243e7ac6f05f3bb6b76fefb2ff285134.tar.bz2 opensim-SC-4663999c243e7ac6f05f3bb6b76fefb2ff285134.tar.xz |
first pass at Terrain implementation
Diffstat (limited to 'OpenSim/Data/NHibernate/NHibernateRegionData.cs')
-rw-r--r-- | OpenSim/Data/NHibernate/NHibernateRegionData.cs | 35 |
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> |