From 32d58d6e3e9a0ea1bfa808567d0f64c0652f8a85 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sat, 21 Jan 2012 23:26:27 -0500 Subject: Telehub Support: Telehub settings now persist to the database and are saved across sim restarts. So-far this only works on MySQL. this is a work in progress, teleport routing is not yet implemented. --- OpenSim/Data/MySQL/MySQLEstateData.cs | 66 +++++++++++++++++++++- .../Data/MySQL/Resources/EstateStore.migrations | 21 +++++++ 2 files changed, 86 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 3d647ca..a357268 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -157,6 +157,7 @@ namespace OpenSim.Data.MySQL DoCreate(es); LoadBanList(es); + LoadSpawnPoints(es); es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers"); es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users"); @@ -210,7 +211,7 @@ namespace OpenSim.Data.MySQL } LoadBanList(es); - + LoadSpawnPoints(es); es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers"); es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users"); es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups"); @@ -297,11 +298,74 @@ namespace OpenSim.Data.MySQL } SaveBanList(es); + SaveSpawnPoints(es); SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers); SaveUUIDList(es.EstateID, "estate_users", es.EstateAccess); SaveUUIDList(es.EstateID, "estate_groups", es.EstateGroups); } + private void LoadSpawnPoints(EstateSettings es) + { + es.ClearSpawnPoints(); + + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + uint EstateID = es.EstateID; + cmd.CommandText = "select PointX, PointY, PointZ from spawn_points where EstateID = ?EstateID"; + cmd.Parameters.AddWithValue("?EstateID", es.EstateID); + + using (IDataReader r = cmd.ExecuteReader()) + { + while (r.Read()) + { + Vector3 point = new Vector3(); + + point.X = (float)r["PointX"]; + point.Y = (float)r["PointY"]; + point.Z = (float)r["PointZ"]; + + es.AddSpawnPoint(point); + } + } + } + } + } + + private void SaveSpawnPoints(EstateSettings es) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "delete from spawn_points where EstateID = ?EstateID"; + cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); + + cmd.ExecuteNonQuery(); + + cmd.Parameters.Clear(); + + cmd.CommandText = "insert into spawn_points (EstateID, PointX, PointY, PointZ) values ( ?EstateID, ?PointX, ?PointY,?PointZ)"; + + foreach (Vector3 p in es.SpawnPoints()) + { + cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); + cmd.Parameters.AddWithValue("?PointX", p.X); + cmd.Parameters.AddWithValue("?PointY", p.Y); + cmd.Parameters.AddWithValue("?PointZ", p.Z); + + cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + } + } + } + } + private void LoadBanList(EstateSettings es) { es.ClearBans(); diff --git a/OpenSim/Data/MySQL/Resources/EstateStore.migrations b/OpenSim/Data/MySQL/Resources/EstateStore.migrations index df82a2e..591295b 100644 --- a/OpenSim/Data/MySQL/Resources/EstateStore.migrations +++ b/OpenSim/Data/MySQL/Resources/EstateStore.migrations @@ -78,4 +78,25 @@ ALTER TABLE estate_settings AUTO_INCREMENT = 100; COMMIT; +:VERSION 33 #--------------------- ( Supporting Telehubs +BEGIN; +CREATE TABLE IF NOT EXISTS `spawn_points` ( + `EstateID` varchar(36) COLLATE utf8_unicode_ci NOT NULL, + `PointX` float NOT NULL, + `PointY` float NOT NULL, + `PointZ` float NOT NULL, + KEY `EstateID` (`EstateID`) +) ENGINE=Innodb; + +ALTER TABLE `estate_settings` ADD COLUMN `TelehubObject` varchar(36) NOT NULL; +ALTER TABLE `estate_settings` ADD COLUMN `TelehubName` varchar(255) NOT NULL; +ALTER TABLE `estate_settings` ADD COLUMN `TelehubEnabled` tinyint(4) NOT NULL; +ALTER TABLE `estate_settings` ADD COLUMN `TelehubPosX` float NOT NULL; +ALTER TABLE `estate_settings` ADD COLUMN `TelehubPosY` float NOT NULL; +ALTER TABLE `estate_settings` ADD COLUMN `TelehubPosZ` float NOT NULL; +ALTER TABLE `estate_settings` ADD COLUMN `TelehubRotX` float NOT NULL; +ALTER TABLE `estate_settings` ADD COLUMN `TelehubRotY` float NOT NULL; +ALTER TABLE `estate_settings` ADD COLUMN `TelehubRotZ` float NOT NULL; +ALTER TABLE `estate_settings` ADD COLUMN `TelehubRotW` float NOT NULL; +COMMIT; \ No newline at end of file -- cgit v1.1