diff options
author | UbitUmarov | 2016-09-18 20:02:59 +0100 |
---|---|---|
committer | UbitUmarov | 2016-09-18 20:02:59 +0100 |
commit | 82997c5907bcb0591b815ed9343e9d2c56ba5710 (patch) | |
tree | 699c875eb48f6efa3ca2c8b5d22315df20b5130f /OpenSim/Data/MySQL | |
parent | Merge branch 'master' into httptests (diff) | |
parent | fix typo in table name, thx tglion (diff) | |
download | opensim-SC-82997c5907bcb0591b815ed9343e9d2c56ba5710.zip opensim-SC-82997c5907bcb0591b815ed9343e9d2c56ba5710.tar.gz opensim-SC-82997c5907bcb0591b815ed9343e9d2c56ba5710.tar.bz2 opensim-SC-82997c5907bcb0591b815ed9343e9d2c56ba5710.tar.xz |
Merge branch 'master' into httptests
Diffstat (limited to 'OpenSim/Data/MySQL')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLSimulationData.cs | 82 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/Resources/RegionStore.migrations | 11 |
2 files changed, 93 insertions, 0 deletions
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 46364a5..ab24b76 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs | |||
@@ -639,6 +639,53 @@ namespace OpenSim.Data.MySQL | |||
639 | }); | 639 | }); |
640 | } | 640 | } |
641 | 641 | ||
642 | public void StoreBakedTerrain(TerrainData terrData, UUID regionID) | ||
643 | { | ||
644 | Util.FireAndForget(delegate(object x) | ||
645 | { | ||
646 | m_log.Info("[REGION DB]: Storing Baked terrain"); | ||
647 | |||
648 | lock (m_dbLock) | ||
649 | { | ||
650 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
651 | { | ||
652 | dbcon.Open(); | ||
653 | |||
654 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
655 | { | ||
656 | cmd.CommandText = "delete from bakedterrain where RegionUUID = ?RegionUUID"; | ||
657 | cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); | ||
658 | |||
659 | using (MySqlCommand cmd2 = dbcon.CreateCommand()) | ||
660 | { | ||
661 | try | ||
662 | { | ||
663 | cmd2.CommandText = "insert into bakedterrain (RegionUUID, " + | ||
664 | "Revision, Heightfield) values (?RegionUUID, " + | ||
665 | "?Revision, ?Heightfield)"; | ||
666 | |||
667 | int terrainDBRevision; | ||
668 | Array terrainDBblob; | ||
669 | terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob); | ||
670 | |||
671 | cmd2.Parameters.AddWithValue("RegionUUID", regionID.ToString()); | ||
672 | cmd2.Parameters.AddWithValue("Revision", terrainDBRevision); | ||
673 | cmd2.Parameters.AddWithValue("Heightfield", terrainDBblob); | ||
674 | |||
675 | ExecuteNonQuery(cmd); | ||
676 | ExecuteNonQuery(cmd2); | ||
677 | } | ||
678 | catch (Exception e) | ||
679 | { | ||
680 | m_log.ErrorFormat(e.ToString()); | ||
681 | } | ||
682 | } | ||
683 | } | ||
684 | } | ||
685 | } | ||
686 | }); | ||
687 | } | ||
688 | |||
642 | // Legacy region loading | 689 | // Legacy region loading |
643 | public virtual double[,] LoadTerrain(UUID regionID) | 690 | public virtual double[,] LoadTerrain(UUID regionID) |
644 | { | 691 | { |
@@ -686,6 +733,41 @@ namespace OpenSim.Data.MySQL | |||
686 | return terrData; | 733 | return terrData; |
687 | } | 734 | } |
688 | 735 | ||
736 | public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) | ||
737 | { | ||
738 | TerrainData terrData = null; | ||
739 | |||
740 | lock (m_dbLock) | ||
741 | { | ||
742 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
743 | { | ||
744 | dbcon.Open(); | ||
745 | |||
746 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
747 | { | ||
748 | cmd.CommandText = "select RegionUUID, Revision, Heightfield " + | ||
749 | "from bakedterrain where RegionUUID = ?RegionUUID "; | ||
750 | cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); | ||
751 | |||
752 | using (IDataReader reader = ExecuteReader(cmd)) | ||
753 | { | ||
754 | while (reader.Read()) | ||
755 | { | ||
756 | int rev = Convert.ToInt32(reader["Revision"]); | ||
757 | if ((reader["Heightfield"] != DBNull.Value)) | ||
758 | { | ||
759 | byte[] blob = (byte[])reader["Heightfield"]; | ||
760 | terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob); | ||
761 | } | ||
762 | } | ||
763 | } | ||
764 | } | ||
765 | } | ||
766 | } | ||
767 | |||
768 | return terrData; | ||
769 | } | ||
770 | |||
689 | public virtual void RemoveLandObject(UUID globalID) | 771 | public virtual void RemoveLandObject(UUID globalID) |
690 | { | 772 | { |
691 | lock (m_dbLock) | 773 | lock (m_dbLock) |
diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index c32f645..1de5a01 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations | |||
@@ -379,3 +379,14 @@ ALTER TABLE `prims` ADD COLUMN `RotationAxisLocks` tinyint(4) NOT NULL default ' | |||
379 | 379 | ||
380 | COMMIT; | 380 | COMMIT; |
381 | 381 | ||
382 | :VERSION 54 #----- add baked terrain store | ||
383 | |||
384 | BEGIN; | ||
385 | |||
386 | CREATE TABLE IF NOT EXISTS `bakedterrain` ( | ||
387 | `RegionUUID` varchar(255) DEFAULT NULL, | ||
388 | `Revision` int(11) DEFAULT NULL, | ||
389 | `Heightfield` longblob | ||
390 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
391 | |||
392 | COMMIT; | ||