diff options
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLSimulationData.cs')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLSimulationData.cs | 69 |
1 files changed, 44 insertions, 25 deletions
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 6d14b82..b201c51 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,7 +559,7 @@ 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 | m_log.Info("[REGION DB]: Storing terrain"); |
565 | 565 | ||
@@ -574,21 +574,35 @@ namespace OpenSim.Data.MySQL | |||
574 | cmd.CommandText = "delete from terrain where RegionUUID = ?RegionUUID"; | 574 | cmd.CommandText = "delete from terrain where RegionUUID = ?RegionUUID"; |
575 | cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); | 575 | cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); |
576 | 576 | ||
577 | ExecuteNonQuery(cmd); | 577 | using (MySqlCommand cmd2 = dbcon.CreateCommand()) |
578 | 578 | { | |
579 | cmd.CommandText = "insert into terrain (RegionUUID, " + | 579 | try |
580 | "Revision, Heightfield) values (?RegionUUID, " + | 580 | { |
581 | "1, ?Heightfield)"; | 581 | cmd2.CommandText = "insert into terrain (RegionUUID, " + |
582 | "Revision, Heightfield) values (?RegionUUID, " + | ||
583 | "1, ?Heightfield)"; | ||
582 | 584 | ||
583 | cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter)); | 585 | cmd2.Parameters.AddWithValue("RegionUUID", regionID.ToString()); |
586 | cmd2.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter)); | ||
584 | 587 | ||
585 | ExecuteNonQuery(cmd); | 588 | ExecuteNonQuery(cmd); |
589 | ExecuteNonQuery(cmd2); | ||
590 | } | ||
591 | catch | ||
592 | { | ||
593 | // If we get here there is a NaN in the terrain | ||
594 | // and the terrain can't be saved. A crash here | ||
595 | // is much better than losing all the work | ||
596 | m_log.ErrorFormat("[DATA]: Unable to save terrain. Stopping simulator to prevent data loss"); | ||
597 | Environment.Exit(1); | ||
598 | } | ||
599 | } | ||
586 | } | 600 | } |
587 | } | 601 | } |
588 | } | 602 | } |
589 | } | 603 | } |
590 | 604 | ||
591 | public double[,] LoadTerrain(UUID regionID) | 605 | public virtual double[,] LoadTerrain(UUID regionID) |
592 | { | 606 | { |
593 | double[,] terrain = null; | 607 | double[,] terrain = null; |
594 | 608 | ||
@@ -638,7 +652,7 @@ namespace OpenSim.Data.MySQL | |||
638 | return terrain; | 652 | return terrain; |
639 | } | 653 | } |
640 | 654 | ||
641 | public void RemoveLandObject(UUID globalID) | 655 | public virtual void RemoveLandObject(UUID globalID) |
642 | { | 656 | { |
643 | lock (m_dbLock) | 657 | lock (m_dbLock) |
644 | { | 658 | { |
@@ -657,7 +671,7 @@ namespace OpenSim.Data.MySQL | |||
657 | } | 671 | } |
658 | } | 672 | } |
659 | 673 | ||
660 | public void StoreLandObject(ILandObject parcel) | 674 | public virtual void StoreLandObject(ILandObject parcel) |
661 | { | 675 | { |
662 | lock (m_dbLock) | 676 | lock (m_dbLock) |
663 | { | 677 | { |
@@ -714,7 +728,7 @@ namespace OpenSim.Data.MySQL | |||
714 | } | 728 | } |
715 | } | 729 | } |
716 | 730 | ||
717 | public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID) | 731 | public virtual RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID) |
718 | { | 732 | { |
719 | RegionLightShareData nWP = new RegionLightShareData(); | 733 | RegionLightShareData nWP = new RegionLightShareData(); |
720 | nWP.OnSave += StoreRegionWindlightSettings; | 734 | nWP.OnSave += StoreRegionWindlightSettings; |
@@ -736,7 +750,7 @@ namespace OpenSim.Data.MySQL | |||
736 | { | 750 | { |
737 | //No result, so store our default windlight profile and return it | 751 | //No result, so store our default windlight profile and return it |
738 | nWP.regionID = regionUUID; | 752 | nWP.regionID = regionUUID; |
739 | StoreRegionWindlightSettings(nWP); | 753 | // StoreRegionWindlightSettings(nWP); |
740 | return nWP; | 754 | return nWP; |
741 | } | 755 | } |
742 | else | 756 | else |
@@ -811,7 +825,7 @@ namespace OpenSim.Data.MySQL | |||
811 | return nWP; | 825 | return nWP; |
812 | } | 826 | } |
813 | 827 | ||
814 | public RegionSettings LoadRegionSettings(UUID regionUUID) | 828 | public virtual RegionSettings LoadRegionSettings(UUID regionUUID) |
815 | { | 829 | { |
816 | RegionSettings rs = null; | 830 | RegionSettings rs = null; |
817 | 831 | ||
@@ -849,7 +863,7 @@ namespace OpenSim.Data.MySQL | |||
849 | return rs; | 863 | return rs; |
850 | } | 864 | } |
851 | 865 | ||
852 | public void StoreRegionWindlightSettings(RegionLightShareData wl) | 866 | public virtual void StoreRegionWindlightSettings(RegionLightShareData wl) |
853 | { | 867 | { |
854 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 868 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
855 | { | 869 | { |
@@ -952,7 +966,7 @@ namespace OpenSim.Data.MySQL | |||
952 | } | 966 | } |
953 | } | 967 | } |
954 | 968 | ||
955 | public void RemoveRegionWindlightSettings(UUID regionID) | 969 | public virtual void RemoveRegionWindlightSettings(UUID regionID) |
956 | { | 970 | { |
957 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 971 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
958 | { | 972 | { |
@@ -967,7 +981,7 @@ namespace OpenSim.Data.MySQL | |||
967 | } | 981 | } |
968 | } | 982 | } |
969 | 983 | ||
970 | public void StoreRegionSettings(RegionSettings rs) | 984 | public virtual void StoreRegionSettings(RegionSettings rs) |
971 | { | 985 | { |
972 | lock (m_dbLock) | 986 | lock (m_dbLock) |
973 | { | 987 | { |
@@ -994,7 +1008,7 @@ namespace OpenSim.Data.MySQL | |||
994 | "use_estate_sun, fixed_sun, sun_position, " + | 1008 | "use_estate_sun, fixed_sun, sun_position, " + |
995 | "covenant, Sandbox, sunvectorx, sunvectory, " + | 1009 | "covenant, Sandbox, sunvectorx, sunvectory, " + |
996 | "sunvectorz, loaded_creation_datetime, " + | 1010 | "sunvectorz, loaded_creation_datetime, " + |
997 | "loaded_creation_id, map_tile_ID) values (?RegionUUID, ?BlockTerraform, " + | 1011 | "loaded_creation_id, map_tile_ID, block_search, casino) values (?RegionUUID, ?BlockTerraform, " + |
998 | "?BlockFly, ?AllowDamage, ?RestrictPushing, " + | 1012 | "?BlockFly, ?AllowDamage, ?RestrictPushing, " + |
999 | "?AllowLandResell, ?AllowLandJoinDivide, " + | 1013 | "?AllowLandResell, ?AllowLandJoinDivide, " + |
1000 | "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + | 1014 | "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + |
@@ -1009,7 +1023,7 @@ namespace OpenSim.Data.MySQL | |||
1009 | "?SunPosition, ?Covenant, ?Sandbox, " + | 1023 | "?SunPosition, ?Covenant, ?Sandbox, " + |
1010 | "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + | 1024 | "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + |
1011 | "?LoadedCreationDateTime, ?LoadedCreationID, " + | 1025 | "?LoadedCreationDateTime, ?LoadedCreationID, " + |
1012 | "?TerrainImageID)"; | 1026 | "?TerrainImageID, ?block_search, ?casino)"; |
1013 | 1027 | ||
1014 | FillRegionSettingsCommand(cmd, rs); | 1028 | FillRegionSettingsCommand(cmd, rs); |
1015 | 1029 | ||
@@ -1019,7 +1033,7 @@ namespace OpenSim.Data.MySQL | |||
1019 | } | 1033 | } |
1020 | } | 1034 | } |
1021 | 1035 | ||
1022 | public List<LandData> LoadLandObjects(UUID regionUUID) | 1036 | public virtual List<LandData> LoadLandObjects(UUID regionUUID) |
1023 | { | 1037 | { |
1024 | List<LandData> landData = new List<LandData>(); | 1038 | List<LandData> landData = new List<LandData>(); |
1025 | 1039 | ||
@@ -1297,6 +1311,9 @@ namespace OpenSim.Data.MySQL | |||
1297 | 1311 | ||
1298 | newSettings.TerrainImageID = DBGuid.FromDB(row["map_tile_ID"]); | 1312 | newSettings.TerrainImageID = DBGuid.FromDB(row["map_tile_ID"]); |
1299 | 1313 | ||
1314 | newSettings.GodBlockSearch = Convert.ToBoolean(row["block_search"]); | ||
1315 | newSettings.Casino = Convert.ToBoolean(row["casino"]); | ||
1316 | |||
1300 | return newSettings; | 1317 | return newSettings; |
1301 | } | 1318 | } |
1302 | 1319 | ||
@@ -1626,6 +1643,8 @@ namespace OpenSim.Data.MySQL | |||
1626 | cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); | 1643 | cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); |
1627 | cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); | 1644 | cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); |
1628 | cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID); | 1645 | cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID); |
1646 | cmd.Parameters.AddWithValue("block_search", settings.GodBlockSearch); | ||
1647 | cmd.Parameters.AddWithValue("casino", settings.Casino); | ||
1629 | 1648 | ||
1630 | } | 1649 | } |
1631 | 1650 | ||
@@ -1784,7 +1803,7 @@ namespace OpenSim.Data.MySQL | |||
1784 | cmd.Parameters.AddWithValue("Media", null == s.Media ? null : s.Media.ToXml()); | 1803 | cmd.Parameters.AddWithValue("Media", null == s.Media ? null : s.Media.ToXml()); |
1785 | } | 1804 | } |
1786 | 1805 | ||
1787 | public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items) | 1806 | public virtual void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items) |
1788 | { | 1807 | { |
1789 | lock (m_dbLock) | 1808 | lock (m_dbLock) |
1790 | { | 1809 | { |