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.cs96
1 files changed, 60 insertions, 36 deletions
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs
index 3883e24..afd42d7 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
@@ -241,7 +241,7 @@ namespace OpenSim.Data.MySQL
241 } 241 }
242 } 242 }
243 243
244 public void RemoveObject(UUID obj, UUID regionUUID) 244 public virtual void RemoveObject(UUID obj, UUID regionUUID)
245 { 245 {
246// m_log.DebugFormat("[REGION DB]: Deleting scene object {0} from {1} in database", obj, regionUUID); 246// m_log.DebugFormat("[REGION DB]: Deleting scene object {0} from {1} in database", obj, regionUUID);
247 247
@@ -390,7 +390,7 @@ namespace OpenSim.Data.MySQL
390 } 390 }
391 } 391 }
392 392
393 public List<SceneObjectGroup> LoadObjects(UUID regionID) 393 public virtual List<SceneObjectGroup> LoadObjects(UUID regionID)
394 { 394 {
395 const int ROWS_PER_QUERY = 5000; 395 const int ROWS_PER_QUERY = 5000;
396 396
@@ -559,36 +559,51 @@ namespace OpenSim.Data.MySQL
559 } 559 }
560 } 560 }
561 561
562 public void StoreTerrain(double[,] ter, UUID regionID) 562 public virtual void StoreTerrain(double[,] ter, UUID regionID)
563 { 563 {
564 m_log.Info("[REGION DB]: Storing terrain"); 564 Util.FireAndForget(delegate(object x)
565
566 lock (m_dbLock)
567 { 565 {
568 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 566 double[,] oldTerrain = LoadTerrain(regionID);
569 {
570 dbcon.Open();
571 567
572 using (MySqlCommand cmd = dbcon.CreateCommand()) 568 m_log.Info("[REGION DB]: Storing terrain");
569
570 lock (m_dbLock)
571 {
572 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
573 { 573 {
574 cmd.CommandText = "delete from terrain where RegionUUID = ?RegionUUID"; 574 dbcon.Open();
575 cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString());
576 575
577 ExecuteNonQuery(cmd); 576 using (MySqlCommand cmd = dbcon.CreateCommand())
577 {
578 cmd.CommandText = "delete from terrain where RegionUUID = ?RegionUUID";
579 cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString());
578 580
579 cmd.CommandText = "insert into terrain (RegionUUID, " + 581 using (MySqlCommand cmd2 = dbcon.CreateCommand())
580 "Revision, Heightfield) values (?RegionUUID, " + 582 {
581 "1, ?Heightfield)"; 583 try
584 {
585 cmd2.CommandText = "insert into terrain (RegionUUID, " +
586 "Revision, Heightfield) values (?RegionUUID, " +
587 "1, ?Heightfield)";
582 588
583 cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter)); 589 cmd2.Parameters.AddWithValue("RegionUUID", regionID.ToString());
590 cmd2.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter, oldTerrain));
584 591
585 ExecuteNonQuery(cmd); 592 ExecuteNonQuery(cmd);
593 ExecuteNonQuery(cmd2);
594 }
595 catch (Exception e)
596 {
597 m_log.ErrorFormat(e.ToString());
598 }
599 }
600 }
586 } 601 }
587 } 602 }
588 } 603 });
589 } 604 }
590 605
591 public double[,] LoadTerrain(UUID regionID) 606 public virtual double[,] LoadTerrain(UUID regionID)
592 { 607 {
593 double[,] terrain = null; 608 double[,] terrain = null;
594 609
@@ -638,7 +653,7 @@ namespace OpenSim.Data.MySQL
638 return terrain; 653 return terrain;
639 } 654 }
640 655
641 public void RemoveLandObject(UUID globalID) 656 public virtual void RemoveLandObject(UUID globalID)
642 { 657 {
643 lock (m_dbLock) 658 lock (m_dbLock)
644 { 659 {
@@ -657,7 +672,7 @@ namespace OpenSim.Data.MySQL
657 } 672 }
658 } 673 }
659 674
660 public void StoreLandObject(ILandObject parcel) 675 public virtual void StoreLandObject(ILandObject parcel)
661 { 676 {
662 lock (m_dbLock) 677 lock (m_dbLock)
663 { 678 {
@@ -714,7 +729,7 @@ namespace OpenSim.Data.MySQL
714 } 729 }
715 } 730 }
716 731
717 public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID) 732 public virtual RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID)
718 { 733 {
719 RegionLightShareData nWP = new RegionLightShareData(); 734 RegionLightShareData nWP = new RegionLightShareData();
720 nWP.OnSave += StoreRegionWindlightSettings; 735 nWP.OnSave += StoreRegionWindlightSettings;
@@ -736,7 +751,7 @@ namespace OpenSim.Data.MySQL
736 { 751 {
737 //No result, so store our default windlight profile and return it 752 //No result, so store our default windlight profile and return it
738 nWP.regionID = regionUUID; 753 nWP.regionID = regionUUID;
739 StoreRegionWindlightSettings(nWP); 754 // StoreRegionWindlightSettings(nWP);
740 return nWP; 755 return nWP;
741 } 756 }
742 else 757 else
@@ -811,7 +826,7 @@ namespace OpenSim.Data.MySQL
811 return nWP; 826 return nWP;
812 } 827 }
813 828
814 public RegionSettings LoadRegionSettings(UUID regionUUID) 829 public virtual RegionSettings LoadRegionSettings(UUID regionUUID)
815 { 830 {
816 RegionSettings rs = null; 831 RegionSettings rs = null;
817 832
@@ -851,7 +866,7 @@ namespace OpenSim.Data.MySQL
851 return rs; 866 return rs;
852 } 867 }
853 868
854 public void StoreRegionWindlightSettings(RegionLightShareData wl) 869 public virtual void StoreRegionWindlightSettings(RegionLightShareData wl)
855 { 870 {
856 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 871 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
857 { 872 {
@@ -954,7 +969,7 @@ namespace OpenSim.Data.MySQL
954 } 969 }
955 } 970 }
956 971
957 public void RemoveRegionWindlightSettings(UUID regionID) 972 public virtual void RemoveRegionWindlightSettings(UUID regionID)
958 { 973 {
959 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 974 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
960 { 975 {
@@ -969,7 +984,7 @@ namespace OpenSim.Data.MySQL
969 } 984 }
970 } 985 }
971 986
972 public void StoreRegionSettings(RegionSettings rs) 987 public virtual void StoreRegionSettings(RegionSettings rs)
973 { 988 {
974 lock (m_dbLock) 989 lock (m_dbLock)
975 { 990 {
@@ -996,7 +1011,7 @@ namespace OpenSim.Data.MySQL
996 "use_estate_sun, fixed_sun, sun_position, " + 1011 "use_estate_sun, fixed_sun, sun_position, " +
997 "covenant, Sandbox, sunvectorx, sunvectory, " + 1012 "covenant, Sandbox, sunvectorx, sunvectory, " +
998 "sunvectorz, loaded_creation_datetime, " + 1013 "sunvectorz, loaded_creation_datetime, " +
999 "loaded_creation_id, map_tile_ID) values (?RegionUUID, ?BlockTerraform, " + 1014 "loaded_creation_id, map_tile_ID, block_search, casino) values (?RegionUUID, ?BlockTerraform, " +
1000 "?BlockFly, ?AllowDamage, ?RestrictPushing, " + 1015 "?BlockFly, ?AllowDamage, ?RestrictPushing, " +
1001 "?AllowLandResell, ?AllowLandJoinDivide, " + 1016 "?AllowLandResell, ?AllowLandJoinDivide, " +
1002 "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + 1017 "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " +
@@ -1011,7 +1026,7 @@ namespace OpenSim.Data.MySQL
1011 "?SunPosition, ?Covenant, ?Sandbox, " + 1026 "?SunPosition, ?Covenant, ?Sandbox, " +
1012 "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + 1027 "?SunVectorX, ?SunVectorY, ?SunVectorZ, " +
1013 "?LoadedCreationDateTime, ?LoadedCreationID, " + 1028 "?LoadedCreationDateTime, ?LoadedCreationID, " +
1014 "?TerrainImageID)"; 1029 "?TerrainImageID, ?block_search, ?casino)";
1015 1030
1016 FillRegionSettingsCommand(cmd, rs); 1031 FillRegionSettingsCommand(cmd, rs);
1017 1032
@@ -1022,7 +1037,7 @@ namespace OpenSim.Data.MySQL
1022 SaveSpawnPoints(rs); 1037 SaveSpawnPoints(rs);
1023 } 1038 }
1024 1039
1025 public List<LandData> LoadLandObjects(UUID regionUUID) 1040 public virtual List<LandData> LoadLandObjects(UUID regionUUID)
1026 { 1041 {
1027 List<LandData> landData = new List<LandData>(); 1042 List<LandData> landData = new List<LandData>();
1028 1043
@@ -1300,6 +1315,9 @@ namespace OpenSim.Data.MySQL
1300 1315
1301 newSettings.TerrainImageID = DBGuid.FromDB(row["map_tile_ID"]); 1316 newSettings.TerrainImageID = DBGuid.FromDB(row["map_tile_ID"]);
1302 1317
1318 newSettings.GodBlockSearch = Convert.ToBoolean(row["block_search"]);
1319 newSettings.Casino = Convert.ToBoolean(row["casino"]);
1320
1303 return newSettings; 1321 return newSettings;
1304 } 1322 }
1305 1323
@@ -1397,7 +1415,7 @@ namespace OpenSim.Data.MySQL
1397 /// </summary> 1415 /// </summary>
1398 /// <param name="val"></param> 1416 /// <param name="val"></param>
1399 /// <returns></returns> 1417 /// <returns></returns>
1400 private static Array SerializeTerrain(double[,] val) 1418 private static Array SerializeTerrain(double[,] val, double[,] oldTerrain)
1401 { 1419 {
1402 MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) *sizeof (double)); 1420 MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) *sizeof (double));
1403 BinaryWriter bw = new BinaryWriter(str); 1421 BinaryWriter bw = new BinaryWriter(str);
@@ -1406,7 +1424,11 @@ namespace OpenSim.Data.MySQL
1406 for (int x = 0; x < (int)Constants.RegionSize; x++) 1424 for (int x = 0; x < (int)Constants.RegionSize; x++)
1407 for (int y = 0; y < (int)Constants.RegionSize; y++) 1425 for (int y = 0; y < (int)Constants.RegionSize; y++)
1408 { 1426 {
1409 double height = val[x, y]; 1427 double height = 20.0;
1428 if (oldTerrain != null)
1429 height = oldTerrain[x, y];
1430 if (!double.IsNaN(val[x, y]))
1431 height = val[x, y];
1410 if (height == 0.0) 1432 if (height == 0.0)
1411 height = double.Epsilon; 1433 height = double.Epsilon;
1412 1434
@@ -1629,6 +1651,8 @@ namespace OpenSim.Data.MySQL
1629 cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); 1651 cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime);
1630 cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); 1652 cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID);
1631 cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID); 1653 cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID);
1654 cmd.Parameters.AddWithValue("block_search", settings.GodBlockSearch);
1655 cmd.Parameters.AddWithValue("casino", settings.Casino);
1632 1656
1633 } 1657 }
1634 1658
@@ -1787,7 +1811,7 @@ namespace OpenSim.Data.MySQL
1787 cmd.Parameters.AddWithValue("Media", null == s.Media ? null : s.Media.ToXml()); 1811 cmd.Parameters.AddWithValue("Media", null == s.Media ? null : s.Media.ToXml());
1788 } 1812 }
1789 1813
1790 public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items) 1814 public virtual void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items)
1791 { 1815 {
1792 lock (m_dbLock) 1816 lock (m_dbLock)
1793 { 1817 {