aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorSean Dague2008-07-17 20:58:20 +0000
committerSean Dague2008-07-17 20:58:20 +0000
commit4663999c243e7ac6f05f3bb6b76fefb2ff285134 (patch)
treed99fbe2b410de768c1775db45396cf1a22610339 /OpenSim
parentadd a Terrain object for the purpose of mapping. This may make sense (diff)
downloadopensim-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 '')
-rw-r--r--OpenSim/Data/NHibernate/NHibernateRegionData.cs35
-rw-r--r--OpenSim/Data/NHibernate/Resources/MySQLDialect/002_RegionStore.sql9
-rw-r--r--OpenSim/Data/NHibernate/Resources/RegionStore.hbm.xml7
-rw-r--r--OpenSim/Data/NHibernate/Terrain.cs6
4 files changed, 44 insertions, 13 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>
diff --git a/OpenSim/Data/NHibernate/Resources/MySQLDialect/002_RegionStore.sql b/OpenSim/Data/NHibernate/Resources/MySQLDialect/002_RegionStore.sql
new file mode 100644
index 0000000..4e9c974
--- /dev/null
+++ b/OpenSim/Data/NHibernate/Resources/MySQLDialect/002_RegionStore.sql
@@ -0,0 +1,9 @@
1BEGIN;
2
3CREATE TABLE `Terrain` (
4 `RegionID` char(36) not null,
5 `Map` blob,
6 PRIMARY KEY (`RegionID`)
7) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8
9COMMIT; \ No newline at end of file
diff --git a/OpenSim/Data/NHibernate/Resources/RegionStore.hbm.xml b/OpenSim/Data/NHibernate/Resources/RegionStore.hbm.xml
index 40d3864..9fc8065 100644
--- a/OpenSim/Data/NHibernate/Resources/RegionStore.hbm.xml
+++ b/OpenSim/Data/NHibernate/Resources/RegionStore.hbm.xml
@@ -103,6 +103,11 @@
103 <property name="ExtraParams" type="System.Byte[]" /> 103 <property name="ExtraParams" type="System.Byte[]" />
104 <property name="State" type="System.Byte" /> 104 <property name="State" type="System.Byte" />
105 </component> 105 </component>
106 106 </class>
107 <class name="OpenSim.Data.NHibernate.Terrain, OpenSim.Data.NHibernate" table="Terrain" lazy="false">
108 <id name="RegionID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate">
109 <generator class="assigned" />
110 </id>
111 <property name="Map" type="System.Byte[]" />
107 </class> 112 </class>
108</hibernate-mapping> \ No newline at end of file 113</hibernate-mapping> \ No newline at end of file
diff --git a/OpenSim/Data/NHibernate/Terrain.cs b/OpenSim/Data/NHibernate/Terrain.cs
index f125ae3..4c184da 100644
--- a/OpenSim/Data/NHibernate/Terrain.cs
+++ b/OpenSim/Data/NHibernate/Terrain.cs
@@ -62,6 +62,12 @@ namespace OpenSim.Data.NHibernate
62 set { map = parseTerrain(value); } 62 set { map = parseTerrain(value); }
63 } 63 }
64 64
65 public double[,] Doubles
66 {
67 get {return map;}
68 set {map = value;}
69 }
70
65 private static double[,] parseTerrain(byte[] data) 71 private static double[,] parseTerrain(byte[] data)
66 { 72 {
67 double[,] terret = new double[Constants.RegionSize,Constants.RegionSize]; 73 double[,] terret = new double[Constants.RegionSize,Constants.RegionSize];