aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL/MySQLSimulationData.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLSimulationData.cs')
-rw-r--r--OpenSim/Data/MySQL/MySQLSimulationData.cs155
1 files changed, 110 insertions, 45 deletions
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs
index b2a1481..89600db 100644
--- a/OpenSim/Data/MySQL/MySQLSimulationData.cs
+++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs
@@ -66,7 +66,7 @@ namespace OpenSim.Data.MySQL
66 Initialise(connectionString); 66 Initialise(connectionString);
67 } 67 }
68 68
69 public void Initialise(string connectionString) 69 public virtual void Initialise(string connectionString)
70 { 70 {
71 m_connectionString = connectionString; 71 m_connectionString = connectionString;
72 72
@@ -113,7 +113,7 @@ namespace OpenSim.Data.MySQL
113 113
114 public void Dispose() {} 114 public void Dispose() {}
115 115
116 public void StoreObject(SceneObjectGroup obj, UUID regionUUID) 116 public virtual void StoreObject(SceneObjectGroup obj, UUID regionUUID)
117 { 117 {
118 uint flags = obj.RootPart.GetEffectiveObjectFlags(); 118 uint flags = obj.RootPart.GetEffectiveObjectFlags();
119 119
@@ -135,7 +135,7 @@ namespace OpenSim.Data.MySQL
135 foreach (SceneObjectPart prim in obj.Parts) 135 foreach (SceneObjectPart prim in obj.Parts)
136 { 136 {
137 cmd.Parameters.Clear(); 137 cmd.Parameters.Clear();
138 138
139 cmd.CommandText = "replace into prims (" + 139 cmd.CommandText = "replace into prims (" +
140 "UUID, CreationDate, " + 140 "UUID, CreationDate, " +
141 "Name, Text, Description, " + 141 "Name, Text, Description, " +
@@ -171,7 +171,9 @@ namespace OpenSim.Data.MySQL
171 "ParticleSystem, ClickAction, Material, " + 171 "ParticleSystem, ClickAction, Material, " +
172 "CollisionSound, CollisionSoundVolume, " + 172 "CollisionSound, CollisionSoundVolume, " +
173 "PassTouches, " + 173 "PassTouches, " +
174 "LinkNumber, MediaURL) values (" + "?UUID, " + 174 "LinkNumber, MediaURL, KeyframeMotion, " +
175 "PhysicsShapeType, Density, GravityModifier, " +
176 "Friction, Restitution) values (" + "?UUID, " +
175 "?CreationDate, ?Name, ?Text, " + 177 "?CreationDate, ?Name, ?Text, " +
176 "?Description, ?SitName, ?TouchName, " + 178 "?Description, ?SitName, ?TouchName, " +
177 "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + 179 "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " +
@@ -202,14 +204,17 @@ namespace OpenSim.Data.MySQL
202 "?SaleType, ?ColorR, ?ColorG, " + 204 "?SaleType, ?ColorR, ?ColorG, " +
203 "?ColorB, ?ColorA, ?ParticleSystem, " + 205 "?ColorB, ?ColorA, ?ParticleSystem, " +
204 "?ClickAction, ?Material, ?CollisionSound, " + 206 "?ClickAction, ?Material, ?CollisionSound, " +
205 "?CollisionSoundVolume, ?PassTouches, ?LinkNumber, ?MediaURL)"; 207 "?CollisionSoundVolume, ?PassTouches, " +
206 208 "?LinkNumber, ?MediaURL, ?KeyframeMotion, " +
209 "?PhysicsShapeType, ?Density, ?GravityModifier, " +
210 "?Friction, ?Restitution)";
211
207 FillPrimCommand(cmd, prim, obj.UUID, regionUUID); 212 FillPrimCommand(cmd, prim, obj.UUID, regionUUID);
208 213
209 ExecuteNonQuery(cmd); 214 ExecuteNonQuery(cmd);
210 215
211 cmd.Parameters.Clear(); 216 cmd.Parameters.Clear();
212 217
213 cmd.CommandText = "replace into primshapes (" + 218 cmd.CommandText = "replace into primshapes (" +
214 "UUID, Shape, ScaleX, ScaleY, " + 219 "UUID, Shape, ScaleX, ScaleY, " +
215 "ScaleZ, PCode, PathBegin, PathEnd, " + 220 "ScaleZ, PCode, PathBegin, PathEnd, " +
@@ -231,9 +236,9 @@ namespace OpenSim.Data.MySQL
231 "?ProfileEnd, ?ProfileCurve, " + 236 "?ProfileEnd, ?ProfileCurve, " +
232 "?ProfileHollow, ?Texture, ?ExtraParams, " + 237 "?ProfileHollow, ?Texture, ?ExtraParams, " +
233 "?State, ?Media)"; 238 "?State, ?Media)";
234 239
235 FillShapeCommand(cmd, prim); 240 FillShapeCommand(cmd, prim);
236 241
237 ExecuteNonQuery(cmd); 242 ExecuteNonQuery(cmd);
238 } 243 }
239 } 244 }
@@ -241,7 +246,7 @@ namespace OpenSim.Data.MySQL
241 } 246 }
242 } 247 }
243 248
244 public void RemoveObject(UUID obj, UUID regionUUID) 249 public virtual void RemoveObject(UUID obj, UUID regionUUID)
245 { 250 {
246// m_log.DebugFormat("[REGION DB]: Deleting scene object {0} from {1} in database", obj, regionUUID); 251// m_log.DebugFormat("[REGION DB]: Deleting scene object {0} from {1} in database", obj, regionUUID);
247 252
@@ -390,7 +395,7 @@ namespace OpenSim.Data.MySQL
390 } 395 }
391 } 396 }
392 397
393 public List<SceneObjectGroup> LoadObjects(UUID regionID) 398 public virtual List<SceneObjectGroup> LoadObjects(UUID regionID)
394 { 399 {
395 const int ROWS_PER_QUERY = 5000; 400 const int ROWS_PER_QUERY = 5000;
396 401
@@ -446,7 +451,11 @@ namespace OpenSim.Data.MySQL
446 foreach (SceneObjectPart prim in prims.Values) 451 foreach (SceneObjectPart prim in prims.Values)
447 { 452 {
448 if (prim.ParentUUID == UUID.Zero) 453 if (prim.ParentUUID == UUID.Zero)
454 {
449 objects[prim.UUID] = new SceneObjectGroup(prim); 455 objects[prim.UUID] = new SceneObjectGroup(prim);
456 if (prim.KeyframeMotion != null)
457 prim.KeyframeMotion.UpdateSceneObject(objects[prim.UUID]);
458 }
450 } 459 }
451 460
452 // Add all of the children objects to the SOGs 461 // Add all of the children objects to the SOGs
@@ -559,36 +568,51 @@ namespace OpenSim.Data.MySQL
559 } 568 }
560 } 569 }
561 570
562 public void StoreTerrain(double[,] ter, UUID regionID) 571 public virtual void StoreTerrain(double[,] ter, UUID regionID)
563 { 572 {
564 m_log.Info("[REGION DB]: Storing terrain"); 573 Util.FireAndForget(delegate(object x)
565
566 lock (m_dbLock)
567 { 574 {
568 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 575 double[,] oldTerrain = LoadTerrain(regionID);
569 {
570 dbcon.Open();
571 576
572 using (MySqlCommand cmd = dbcon.CreateCommand()) 577 m_log.Info("[REGION DB]: Storing terrain");
578
579 lock (m_dbLock)
580 {
581 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
573 { 582 {
574 cmd.CommandText = "delete from terrain where RegionUUID = ?RegionUUID"; 583 dbcon.Open();
575 cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString());
576 584
577 ExecuteNonQuery(cmd); 585 using (MySqlCommand cmd = dbcon.CreateCommand())
586 {
587 cmd.CommandText = "delete from terrain where RegionUUID = ?RegionUUID";
588 cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString());
578 589
579 cmd.CommandText = "insert into terrain (RegionUUID, " + 590 using (MySqlCommand cmd2 = dbcon.CreateCommand())
580 "Revision, Heightfield) values (?RegionUUID, " + 591 {
581 "1, ?Heightfield)"; 592 try
593 {
594 cmd2.CommandText = "insert into terrain (RegionUUID, " +
595 "Revision, Heightfield) values (?RegionUUID, " +
596 "1, ?Heightfield)";
582 597
583 cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter)); 598 cmd2.Parameters.AddWithValue("RegionUUID", regionID.ToString());
599 cmd2.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter, oldTerrain));
584 600
585 ExecuteNonQuery(cmd); 601 ExecuteNonQuery(cmd);
602 ExecuteNonQuery(cmd2);
603 }
604 catch (Exception e)
605 {
606 m_log.ErrorFormat(e.ToString());
607 }
608 }
609 }
586 } 610 }
587 } 611 }
588 } 612 });
589 } 613 }
590 614
591 public double[,] LoadTerrain(UUID regionID) 615 public virtual double[,] LoadTerrain(UUID regionID)
592 { 616 {
593 double[,] terrain = null; 617 double[,] terrain = null;
594 618
@@ -638,7 +662,7 @@ namespace OpenSim.Data.MySQL
638 return terrain; 662 return terrain;
639 } 663 }
640 664
641 public void RemoveLandObject(UUID globalID) 665 public virtual void RemoveLandObject(UUID globalID)
642 { 666 {
643 lock (m_dbLock) 667 lock (m_dbLock)
644 { 668 {
@@ -657,7 +681,7 @@ namespace OpenSim.Data.MySQL
657 } 681 }
658 } 682 }
659 683
660 public void StoreLandObject(ILandObject parcel) 684 public virtual void StoreLandObject(ILandObject parcel)
661 { 685 {
662 lock (m_dbLock) 686 lock (m_dbLock)
663 { 687 {
@@ -714,7 +738,7 @@ namespace OpenSim.Data.MySQL
714 } 738 }
715 } 739 }
716 740
717 public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID) 741 public virtual RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID)
718 { 742 {
719 RegionLightShareData nWP = new RegionLightShareData(); 743 RegionLightShareData nWP = new RegionLightShareData();
720 nWP.OnSave += StoreRegionWindlightSettings; 744 nWP.OnSave += StoreRegionWindlightSettings;
@@ -736,7 +760,7 @@ namespace OpenSim.Data.MySQL
736 { 760 {
737 //No result, so store our default windlight profile and return it 761 //No result, so store our default windlight profile and return it
738 nWP.regionID = regionUUID; 762 nWP.regionID = regionUUID;
739 StoreRegionWindlightSettings(nWP); 763 // StoreRegionWindlightSettings(nWP);
740 return nWP; 764 return nWP;
741 } 765 }
742 else 766 else
@@ -811,7 +835,7 @@ namespace OpenSim.Data.MySQL
811 return nWP; 835 return nWP;
812 } 836 }
813 837
814 public RegionSettings LoadRegionSettings(UUID regionUUID) 838 public virtual RegionSettings LoadRegionSettings(UUID regionUUID)
815 { 839 {
816 RegionSettings rs = null; 840 RegionSettings rs = null;
817 841
@@ -851,7 +875,7 @@ namespace OpenSim.Data.MySQL
851 return rs; 875 return rs;
852 } 876 }
853 877
854 public void StoreRegionWindlightSettings(RegionLightShareData wl) 878 public virtual void StoreRegionWindlightSettings(RegionLightShareData wl)
855 { 879 {
856 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 880 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
857 { 881 {
@@ -954,7 +978,7 @@ namespace OpenSim.Data.MySQL
954 } 978 }
955 } 979 }
956 980
957 public void RemoveRegionWindlightSettings(UUID regionID) 981 public virtual void RemoveRegionWindlightSettings(UUID regionID)
958 { 982 {
959 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 983 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
960 { 984 {
@@ -969,7 +993,7 @@ namespace OpenSim.Data.MySQL
969 } 993 }
970 } 994 }
971 995
972 public void StoreRegionSettings(RegionSettings rs) 996 public virtual void StoreRegionSettings(RegionSettings rs)
973 { 997 {
974 lock (m_dbLock) 998 lock (m_dbLock)
975 { 999 {
@@ -996,7 +1020,7 @@ namespace OpenSim.Data.MySQL
996 "use_estate_sun, fixed_sun, sun_position, " + 1020 "use_estate_sun, fixed_sun, sun_position, " +
997 "covenant, covenant_datetime, Sandbox, sunvectorx, sunvectory, " + 1021 "covenant, covenant_datetime, Sandbox, sunvectorx, sunvectory, " +
998 "sunvectorz, loaded_creation_datetime, " + 1022 "sunvectorz, loaded_creation_datetime, " +
999 "loaded_creation_id, map_tile_ID, " + 1023 "loaded_creation_id, map_tile_ID, block_search, casino, " +
1000 "TelehubObject, parcel_tile_ID) " + 1024 "TelehubObject, parcel_tile_ID) " +
1001 "values (?RegionUUID, ?BlockTerraform, " + 1025 "values (?RegionUUID, ?BlockTerraform, " +
1002 "?BlockFly, ?AllowDamage, ?RestrictPushing, " + 1026 "?BlockFly, ?AllowDamage, ?RestrictPushing, " +
@@ -1013,7 +1037,8 @@ namespace OpenSim.Data.MySQL
1013 "?SunPosition, ?Covenant, ?CovenantChangedDateTime, ?Sandbox, " + 1037 "?SunPosition, ?Covenant, ?CovenantChangedDateTime, ?Sandbox, " +
1014 "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + 1038 "?SunVectorX, ?SunVectorY, ?SunVectorZ, " +
1015 "?LoadedCreationDateTime, ?LoadedCreationID, " + 1039 "?LoadedCreationDateTime, ?LoadedCreationID, " +
1016 "?TerrainImageID, ?TelehubObject, ?ParcelImageID) "; 1040 "?TerrainImageID, ?block_search, ?casino, " +
1041 "?TelehubObject, ?ParcelImageID)";
1017 1042
1018 FillRegionSettingsCommand(cmd, rs); 1043 FillRegionSettingsCommand(cmd, rs);
1019 1044
@@ -1024,7 +1049,7 @@ namespace OpenSim.Data.MySQL
1024 SaveSpawnPoints(rs); 1049 SaveSpawnPoints(rs);
1025 } 1050 }
1026 1051
1027 public List<LandData> LoadLandObjects(UUID regionUUID) 1052 public virtual List<LandData> LoadLandObjects(UUID regionUUID)
1028 { 1053 {
1029 List<LandData> landData = new List<LandData>(); 1054 List<LandData> landData = new List<LandData>();
1030 1055
@@ -1211,6 +1236,25 @@ namespace OpenSim.Data.MySQL
1211 if (!(row["MediaURL"] is System.DBNull)) 1236 if (!(row["MediaURL"] is System.DBNull))
1212 prim.MediaUrl = (string)row["MediaURL"]; 1237 prim.MediaUrl = (string)row["MediaURL"];
1213 1238
1239 if (!(row["KeyframeMotion"] is DBNull))
1240 {
1241 Byte[] data = (byte[])row["KeyframeMotion"];
1242 if (data.Length > 0)
1243 prim.KeyframeMotion = KeyframeMotion.FromData(null, data);
1244 else
1245 prim.KeyframeMotion = null;
1246 }
1247 else
1248 {
1249 prim.KeyframeMotion = null;
1250 }
1251
1252 prim.PhysicsShapeType = (byte)Convert.ToInt32(row["PhysicsShapeType"].ToString());
1253 prim.Density = (float)(double)row["Density"];
1254 prim.GravityModifier = (float)(double)row["GravityModifier"];
1255 prim.Friction = (float)(double)row["Friction"];
1256 prim.Bounciness = (float)(double)row["Restitution"];
1257
1214 return prim; 1258 return prim;
1215 } 1259 }
1216 1260
@@ -1304,6 +1348,9 @@ namespace OpenSim.Data.MySQL
1304 newSettings.ParcelImageID = DBGuid.FromDB(row["parcel_tile_ID"]); 1348 newSettings.ParcelImageID = DBGuid.FromDB(row["parcel_tile_ID"]);
1305 newSettings.TelehubObject = DBGuid.FromDB(row["TelehubObject"]); 1349 newSettings.TelehubObject = DBGuid.FromDB(row["TelehubObject"]);
1306 1350
1351 newSettings.GodBlockSearch = Convert.ToBoolean(row["block_search"]);
1352 newSettings.Casino = Convert.ToBoolean(row["casino"]);
1353
1307 return newSettings; 1354 return newSettings;
1308 } 1355 }
1309 1356
@@ -1401,7 +1448,7 @@ namespace OpenSim.Data.MySQL
1401 /// </summary> 1448 /// </summary>
1402 /// <param name="val"></param> 1449 /// <param name="val"></param>
1403 /// <returns></returns> 1450 /// <returns></returns>
1404 private static Array SerializeTerrain(double[,] val) 1451 private static Array SerializeTerrain(double[,] val, double[,] oldTerrain)
1405 { 1452 {
1406 MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) *sizeof (double)); 1453 MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) *sizeof (double));
1407 BinaryWriter bw = new BinaryWriter(str); 1454 BinaryWriter bw = new BinaryWriter(str);
@@ -1410,7 +1457,11 @@ namespace OpenSim.Data.MySQL
1410 for (int x = 0; x < (int)Constants.RegionSize; x++) 1457 for (int x = 0; x < (int)Constants.RegionSize; x++)
1411 for (int y = 0; y < (int)Constants.RegionSize; y++) 1458 for (int y = 0; y < (int)Constants.RegionSize; y++)
1412 { 1459 {
1413 double height = val[x, y]; 1460 double height = 20.0;
1461 if (oldTerrain != null)
1462 height = oldTerrain[x, y];
1463 if (!double.IsNaN(val[x, y]))
1464 height = val[x, y];
1414 if (height == 0.0) 1465 if (height == 0.0)
1415 height = double.Epsilon; 1466 height = double.Epsilon;
1416 1467
@@ -1556,6 +1607,17 @@ namespace OpenSim.Data.MySQL
1556 1607
1557 cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum); 1608 cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum);
1558 cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl); 1609 cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl);
1610
1611 if (prim.KeyframeMotion != null)
1612 cmd.Parameters.AddWithValue("KeyframeMotion", prim.KeyframeMotion.Serialize());
1613 else
1614 cmd.Parameters.AddWithValue("KeyframeMotion", new Byte[0]);
1615
1616 cmd.Parameters.AddWithValue("PhysicsShapeType", prim.PhysicsShapeType);
1617 cmd.Parameters.AddWithValue("Density", (double)prim.Density);
1618 cmd.Parameters.AddWithValue("GravityModifier", (double)prim.GravityModifier);
1619 cmd.Parameters.AddWithValue("Friction", (double)prim.Friction);
1620 cmd.Parameters.AddWithValue("Restitution", (double)prim.Bounciness);
1559 } 1621 }
1560 1622
1561 /// <summary> 1623 /// <summary>
@@ -1634,6 +1696,9 @@ namespace OpenSim.Data.MySQL
1634 cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); 1696 cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime);
1635 cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); 1697 cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID);
1636 cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID); 1698 cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID);
1699 cmd.Parameters.AddWithValue("block_search", settings.GodBlockSearch);
1700 cmd.Parameters.AddWithValue("casino", settings.Casino);
1701
1637 cmd.Parameters.AddWithValue("ParcelImageID", settings.ParcelImageID); 1702 cmd.Parameters.AddWithValue("ParcelImageID", settings.ParcelImageID);
1638 cmd.Parameters.AddWithValue("TelehubObject", settings.TelehubObject); 1703 cmd.Parameters.AddWithValue("TelehubObject", settings.TelehubObject);
1639 } 1704 }
@@ -1794,7 +1859,7 @@ namespace OpenSim.Data.MySQL
1794 cmd.Parameters.AddWithValue("Media", null == s.Media ? null : s.Media.ToXml()); 1859 cmd.Parameters.AddWithValue("Media", null == s.Media ? null : s.Media.ToXml());
1795 } 1860 }
1796 1861
1797 public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items) 1862 public virtual void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items)
1798 { 1863 {
1799 lock (m_dbLock) 1864 lock (m_dbLock)
1800 { 1865 {