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 +++ OpenSim/Framework/EstateSettings.cs | 150 +++++++++++++++++++++ .../Region/ClientStack/Linden/UDP/LLClientView.cs | 14 +- .../World/Estate/EstateManagementModule.cs | 50 ++++--- .../CoreModules/World/Estate/TelehubManager.cs | 111 ++++++++------- 6 files changed, 341 insertions(+), 71 deletions(-) (limited to 'OpenSim') 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 diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs index 2a495b0..9bdeab8 100644 --- a/OpenSim/Framework/EstateSettings.cs +++ b/OpenSim/Framework/EstateSettings.cs @@ -373,5 +373,155 @@ namespace OpenSim.Framework return l_EstateAccess.Contains(user); } + + // Telehub support + private bool m_TelehubEnabled = false; + public bool HasTelehub + { + get { return m_TelehubEnabled; } + set { m_TelehubEnabled = value; } + } + + // Connected Telehub object + private UUID m_TelehubObject; + public UUID TelehubObject + { + get + { + if (HasTelehub) + { + return m_TelehubObject; + } + else + { + return UUID.Zero; + } + } + set + { + m_TelehubObject = value; + } + } + + // Connected Telehub name + private string m_TelehubName; + public string TelehubName + { + get + { + if (HasTelehub) + { + return m_TelehubName; + } + else + { + return String.Empty; + } + } + set + { + m_TelehubName = value; + } + } + + // Connected Telehub position + private float m_TelehubPosX; + private float m_TelehubPosY; + private float m_TelehubPosZ; + public Vector3 TelehubPos + { + get + { + if (HasTelehub) + { + Vector3 Pos = new Vector3(m_TelehubPosX, m_TelehubPosY, m_TelehubPosZ); + return Pos; + } + else + { + return Vector3.Zero; + } + } + set + { + + m_TelehubPosX = value.X; + m_TelehubPosY = value.Y; + m_TelehubPosZ = value.Z; + } + } + + // Connected Telehub rotation + private float m_TelehubRotX; + private float m_TelehubRotY; + private float m_TelehubRotZ; + private float m_TelehubRotW; + public Quaternion TelehubRot + { + get + { + if (HasTelehub) + { + Quaternion quat = new Quaternion(); + + quat.X = m_TelehubRotX; + quat.Y = m_TelehubRotY; + quat.Z = m_TelehubRotZ; + quat.W = m_TelehubRotW; + + return quat; + } + else + { + // What else to do?? + Quaternion quat = new Quaternion(); + + quat.X = m_TelehubRotX; + quat.X = m_TelehubRotY; + quat.X = m_TelehubRotZ; + quat.X = m_TelehubRotW; + + return quat; + } + } + set + { + m_TelehubRotX = value.X; + m_TelehubRotY = value.Y; + m_TelehubRotZ = value.Z; + m_TelehubRotW = value.W; + } + } + + // Our Connected Telehub's SpawnPoints + public List l_SpawnPoints = new List(); + + // Add a SpawnPoint + // ** These are not region coordinates ** + // They are relative to the Telehub coordinates + // + public void AddSpawnPoint(Vector3 point) + { + l_SpawnPoints.Add(point); + } + + // Remove a SpawnPoint + public void RemoveSpawnPoint(int point_index) + { + l_SpawnPoints.RemoveAt(point_index); + } + + // Return the List of SpawnPoints + public List SpawnPoints() + { + return l_SpawnPoints; + + } + + // Clear the SpawnPoints List of all entries + public void ClearSpawnPoints() + { + l_SpawnPoints.Clear(); + } } } diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index a94fb20..29ad966 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -9242,10 +9242,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP { UUID invoice = messagePacket.MethodData.Invoice; UUID SenderID = messagePacket.AgentData.AgentID; - UInt32 param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter)); + UInt32 param1 = 0u; string command = (string)Utils.BytesToString(messagePacket.ParamList[0].Parameter); + if (command != "info ui") + { + try + { + param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter)); + } + catch (Exception ex) + { + + } + } + EstateManageTelehub handlerEstateManageTelehub = OnEstateManageTelehub; if (handlerEstateManageTelehub != null) { diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 0d4df6c..6a02ffe 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -53,7 +53,7 @@ namespace OpenSim.Region.CoreModules.World.Estate protected EstateManagementCommands m_commands; private EstateTerrainXferHandler TerrainUploader; - private TelehubManager m_Telehub; + public TelehubManager m_Telehub; public event ChangeDelegate OnRegionInfoChange; public event ChangeDelegate OnEstateInfoChange; @@ -600,22 +600,20 @@ namespace OpenSim.Region.CoreModules.World.Estate } } - private void handleOnEstateManageTelehub (IClientAPI client, UUID invoice, UUID senderID, string cmd, uint param1) + public void handleOnEstateManageTelehub (IClientAPI client, UUID invoice, UUID senderID, string cmd, uint param1) { uint ObjectLocalID; SceneObjectPart part; - // UUID EstateID = Scene.RegionInfo.EstateSettings.EstateID; - TelehubManager.Telehub telehub; switch (cmd) { case "info ui": // Send info: - if (m_Telehub.HasTelehub) + if (Scene.RegionInfo.EstateSettings.HasTelehub) { - telehub = m_Telehub.TelehubVals(); - client.SendTelehubInfo(telehub.ObjectID, telehub.ObjectName, telehub.ObjectPosition, - telehub.ObjectRotation, telehub.SpawnPoint); + EstateSettings settings = this.Scene.RegionInfo.EstateSettings; + client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, + settings.TelehubRot, settings.SpawnPoints()); } else { @@ -626,32 +624,44 @@ namespace OpenSim.Region.CoreModules.World.Estate case "connect": // Add the Telehub part = Scene.GetSceneObjectPart((uint)param1); - telehub = m_Telehub.Connect(part); - client.SendTelehubInfo(telehub.ObjectID, telehub.ObjectName, telehub.ObjectPosition, - telehub.ObjectRotation, telehub.SpawnPoint); + if (m_Telehub.Connect(part)) + { + EstateSettings settings = this.Scene.RegionInfo.EstateSettings; + client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, + settings.TelehubRot, settings.SpawnPoints()); + } break; case "delete": // Disconnect Telehub part = Scene.GetSceneObjectPart((uint)param1); - telehub = m_Telehub.DisConnect(part); - client.SendTelehubInfo(telehub.ObjectID, telehub.ObjectName, telehub.ObjectPosition, - telehub.ObjectRotation, telehub.SpawnPoint); + if (m_Telehub.DisConnect(part)) + { + EstateSettings settings = this.Scene.RegionInfo.EstateSettings; + client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, + settings.TelehubRot, settings.SpawnPoints()); + } break; case "spawnpoint add": // Add SpawnPoint to the Telehub part = Scene.GetSceneObjectPart((uint)param1); - telehub = m_Telehub.AddSpawnPoint(part.AbsolutePosition); - client.SendTelehubInfo(telehub.ObjectID, telehub.ObjectName, telehub.ObjectPosition, - telehub.ObjectRotation, telehub.SpawnPoint); + if( m_Telehub.AddSpawnPoint(part.AbsolutePosition)) + { + EstateSettings settings = this.Scene.RegionInfo.EstateSettings; + client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, + settings.TelehubRot, settings.SpawnPoints()); + } break; case "spawnpoint remove": // Remove SpawnPoint from Telehub - telehub = m_Telehub.RemoveSpawnPoint((int)param1); - client.SendTelehubInfo(telehub.ObjectID, telehub.ObjectName, telehub.ObjectPosition, - telehub.ObjectRotation, telehub.SpawnPoint); + if (m_Telehub.RemoveSpawnPoint((int)param1)) + { + EstateSettings settings = this.Scene.RegionInfo.EstateSettings; + client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, + settings.TelehubRot, settings.SpawnPoints()); + } break; default: diff --git a/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs index c99c9ba..309ef13 100644 --- a/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs +++ b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs @@ -35,14 +35,6 @@ namespace OpenSim.Region.CoreModules.World.Estate { public class TelehubManager { - public struct Telehub - { - public UUID ObjectID; - public string ObjectName; - public Vector3 ObjectPosition; - public Quaternion ObjectRotation; - public List SpawnPoint; - }; private UUID ObjectID; private string ObjectName; @@ -52,8 +44,9 @@ namespace OpenSim.Region.CoreModules.World.Estate UUID EstateID; bool m_HasTelehub = false; Scene m_Scene; + EstateSettings m_EstateSettings; // This will get an option... - Vector3 InitialSpawnPoint = new Vector3(0.0f,0.0f,-3.0f); + Vector3 InitialSpawnPoint = new Vector3(0.0f,0.0f,0.0f); public bool HasTelehub { @@ -63,68 +56,88 @@ namespace OpenSim.Region.CoreModules.World.Estate public TelehubManager(Scene scene) { m_Scene = scene; + m_EstateSettings = m_Scene.RegionInfo.EstateSettings; } // Fill our Telehub struct with values - public Telehub TelehubVals() - { - Telehub telehub = new Telehub(); - - telehub.ObjectID = ObjectID; - telehub.ObjectName = ObjectName; - telehub.ObjectPosition = ObjectPosition; - telehub.ObjectRotation = ObjectRotation; - telehub.SpawnPoint = SpawnPoint; - return telehub; - } +// public Telehub TelehubVals() +// { +// // Telehub telehub = new Telehub(); +// EstateSettings telehub = m_EstateSettings; +// +// telehub.TelehubObject = ObjectID; +// telehub.TelehubName = ObjectName; +// telehub.TelehubPos = ObjectPosition; +// telehub.TelehubRot = ObjectRotation; +// telehub. = SpawnPoint; +// return telehub; +// } // Connect the Telehub - public Telehub Connect(SceneObjectPart part) + public bool Connect(SceneObjectPart part) { - ObjectID = part.UUID; - ObjectName = part.Name; - ObjectPosition = part.AbsolutePosition; - ObjectRotation = part.GetWorldRotation(); - // Clear this for now - SpawnPoint.Clear(); - SpawnPoint.Add(InitialSpawnPoint); - m_HasTelehub = true; + m_EstateSettings.ClearSpawnPoints(); - return TelehubVals(); + m_EstateSettings.TelehubObject = part.UUID; + m_EstateSettings.TelehubName = part.Name; + m_EstateSettings.TelehubPos = part.AbsolutePosition; + m_EstateSettings.TelehubRot = part.GetWorldRotation(); + + // Clear this for now + m_EstateSettings.AddSpawnPoint(InitialSpawnPoint); + m_EstateSettings.HasTelehub = true; + m_EstateSettings.Save(); + return true; } - // Disconnect the Telehub - public Telehub DisConnect(SceneObjectPart part) + // Disconnect the Telehub: Clear it out for now, look at just disableing + public bool DisConnect(SceneObjectPart part) { - ObjectID = UUID.Zero; - ObjectName = String.Empty; - ObjectPosition = Vector3.Zero; - ObjectRotation = Quaternion.Identity; - SpawnPoint.Clear(); - m_HasTelehub = false; - - return TelehubVals(); + bool result = false; + + try{ + m_EstateSettings.TelehubObject = UUID.Zero; + m_EstateSettings.TelehubName = String.Empty; + m_EstateSettings.TelehubPos = Vector3.Zero; + // This is probably wrong! But, HasTelehub will block access + m_EstateSettings.TelehubRot = Quaternion.Identity; + m_EstateSettings.ClearSpawnPoints(); + m_EstateSettings.HasTelehub = false; + m_EstateSettings.Save(); + result = true; + } + catch (Exception ex) + { + result = false; + } + finally + { + + } + + return result; } // Add a SpawnPoint to the Telehub - public Telehub AddSpawnPoint(Vector3 point) + public bool AddSpawnPoint(Vector3 point) { - float dist = (float) Util.GetDistanceTo(ObjectPosition, point); - - Vector3 nvec = Util.GetNormalizedVector(point - ObjectPosition); + float dist = (float) Util.GetDistanceTo(m_EstateSettings.TelehubPos, point); + Vector3 nvec = Util.GetNormalizedVector(point - m_EstateSettings.TelehubPos); Vector3 spoint = nvec * dist; - SpawnPoint.Add(spoint); - return TelehubVals(); + m_EstateSettings.AddSpawnPoint(spoint); + m_EstateSettings.Save(); + return true; } // Remove a SpawnPoint from the Telehub - public Telehub RemoveSpawnPoint(int spawnpoint) + public bool RemoveSpawnPoint(int spawnpoint) { - SpawnPoint.RemoveAt(spawnpoint); + m_EstateSettings.RemoveSpawnPoint(spawnpoint); + m_EstateSettings.Save(); - return TelehubVals(); + return true; } } } \ No newline at end of file -- cgit v1.1 From 68365c20c0b3a3164881398f3bc3710f7960c52d Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 22 Jan 2012 11:36:04 +0000 Subject: Move Telehub tables and data from EstateSettings to RegionSettings. This is damage control es EstateSettings is not the place this can be put. EstateSettings is nt unique to a region and therefore would introduce a hard limit of one telehub per estate, completely shutting off the option of having SL style telehubs, e.g. one per region. Whole estate teleport routing can still be implemented id desiresd, this way all options are open while the other way most options get closed off. --- OpenSim/Data/MySQL/MySQLEstateData.cs | 65 --------- OpenSim/Data/MySQL/MySQLSimulationData.cs | 70 ++++++++++ .../Data/MySQL/Resources/EstateStore.migrations | 21 --- .../Data/MySQL/Resources/RegionStore.migrations | 26 +++- OpenSim/Framework/EstateSettings.cs | 150 --------------------- OpenSim/Framework/RegionSettings.cs | 150 +++++++++++++++++++++ .../World/Estate/EstateManagementModule.cs | 12 +- .../CoreModules/World/Estate/TelehubManager.cs | 46 +++---- 8 files changed, 273 insertions(+), 267 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index a357268..3dd46cb 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -157,7 +157,6 @@ namespace OpenSim.Data.MySQL DoCreate(es); LoadBanList(es); - LoadSpawnPoints(es); es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers"); es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users"); @@ -211,7 +210,6 @@ 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"); @@ -298,74 +296,11 @@ 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/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 6d14b82..3883e24 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -846,6 +846,8 @@ namespace OpenSim.Data.MySQL } } + LoadSpawnPoints(rs); + return rs; } @@ -1017,6 +1019,7 @@ namespace OpenSim.Data.MySQL } } } + SaveSpawnPoints(rs); } public List LoadLandObjects(UUID regionUUID) @@ -1828,5 +1831,72 @@ namespace OpenSim.Data.MySQL } } } + + private void LoadSpawnPoints(RegionSettings rs) + { + rs.ClearSpawnPoints(); + + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "select PointX, PointY, PointZ from spawn_points where RegionID = ?RegionID"; + cmd.Parameters.AddWithValue("?RegionID", rs.RegionUUID.ToString()); + + 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"]; + + rs.AddSpawnPoint(point); + } + } + } + } + } + } + + private void SaveSpawnPoints(RegionSettings rs) + { + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "delete from spawn_points where RegionID = ?RegionID"; + cmd.Parameters.AddWithValue("?RegionID", rs.RegionUUID.ToString()); + + cmd.ExecuteNonQuery(); + + cmd.Parameters.Clear(); + + cmd.CommandText = "insert into spawn_points (RegionID, PointX, PointY, PointZ) values ( ?EstateID, ?PointX, ?PointY,?PointZ)"; + + foreach (Vector3 p in rs.SpawnPoints()) + { + cmd.Parameters.AddWithValue("?EstateID", rs.RegionUUID.ToString()); + cmd.Parameters.AddWithValue("?PointX", p.X); + cmd.Parameters.AddWithValue("?PointY", p.Y); + cmd.Parameters.AddWithValue("?PointZ", p.Z); + + cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + } + } + } + } + } } } diff --git a/OpenSim/Data/MySQL/Resources/EstateStore.migrations b/OpenSim/Data/MySQL/Resources/EstateStore.migrations index 591295b..df82a2e 100644 --- a/OpenSim/Data/MySQL/Resources/EstateStore.migrations +++ b/OpenSim/Data/MySQL/Resources/EstateStore.migrations @@ -78,25 +78,4 @@ 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 diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index 987625b..ce66cfb 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -841,4 +841,28 @@ alter table regionban ENGINE = MyISAM; alter table regionsettings ENGINE = MyISAM; alter table terrain ENGINE = MyISAM; -COMMIT; \ No newline at end of file +COMMIT; + +:VERSION 39 #--------------- Telehub support + +BEGIN; +CREATE TABLE IF NOT EXISTS `spawn_points` ( + `RegionID` 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 `regionsettings` ADD COLUMN `TelehubObject` varchar(36) NOT NULL; +ALTER TABLE `regionsettings` ADD COLUMN `TelehubName` varchar(255) NOT NULL; +ALTER TABLE `regionsettings` ADD COLUMN `TelehubEnabled` tinyint(4) NOT NULL; +ALTER TABLE `regionsettings` ADD COLUMN `TelehubPosX` float NOT NULL; +ALTER TABLE `regionsettings` ADD COLUMN `TelehubPosY` float NOT NULL; +ALTER TABLE `regionsettings` ADD COLUMN `TelehubPosZ` float NOT NULL; +ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotX` float NOT NULL; +ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotY` float NOT NULL; +ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotZ` float NOT NULL; +ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotW` float NOT NULL; +COMMIT; + diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs index 9bdeab8..2a495b0 100644 --- a/OpenSim/Framework/EstateSettings.cs +++ b/OpenSim/Framework/EstateSettings.cs @@ -373,155 +373,5 @@ namespace OpenSim.Framework return l_EstateAccess.Contains(user); } - - // Telehub support - private bool m_TelehubEnabled = false; - public bool HasTelehub - { - get { return m_TelehubEnabled; } - set { m_TelehubEnabled = value; } - } - - // Connected Telehub object - private UUID m_TelehubObject; - public UUID TelehubObject - { - get - { - if (HasTelehub) - { - return m_TelehubObject; - } - else - { - return UUID.Zero; - } - } - set - { - m_TelehubObject = value; - } - } - - // Connected Telehub name - private string m_TelehubName; - public string TelehubName - { - get - { - if (HasTelehub) - { - return m_TelehubName; - } - else - { - return String.Empty; - } - } - set - { - m_TelehubName = value; - } - } - - // Connected Telehub position - private float m_TelehubPosX; - private float m_TelehubPosY; - private float m_TelehubPosZ; - public Vector3 TelehubPos - { - get - { - if (HasTelehub) - { - Vector3 Pos = new Vector3(m_TelehubPosX, m_TelehubPosY, m_TelehubPosZ); - return Pos; - } - else - { - return Vector3.Zero; - } - } - set - { - - m_TelehubPosX = value.X; - m_TelehubPosY = value.Y; - m_TelehubPosZ = value.Z; - } - } - - // Connected Telehub rotation - private float m_TelehubRotX; - private float m_TelehubRotY; - private float m_TelehubRotZ; - private float m_TelehubRotW; - public Quaternion TelehubRot - { - get - { - if (HasTelehub) - { - Quaternion quat = new Quaternion(); - - quat.X = m_TelehubRotX; - quat.Y = m_TelehubRotY; - quat.Z = m_TelehubRotZ; - quat.W = m_TelehubRotW; - - return quat; - } - else - { - // What else to do?? - Quaternion quat = new Quaternion(); - - quat.X = m_TelehubRotX; - quat.X = m_TelehubRotY; - quat.X = m_TelehubRotZ; - quat.X = m_TelehubRotW; - - return quat; - } - } - set - { - m_TelehubRotX = value.X; - m_TelehubRotY = value.Y; - m_TelehubRotZ = value.Z; - m_TelehubRotW = value.W; - } - } - - // Our Connected Telehub's SpawnPoints - public List l_SpawnPoints = new List(); - - // Add a SpawnPoint - // ** These are not region coordinates ** - // They are relative to the Telehub coordinates - // - public void AddSpawnPoint(Vector3 point) - { - l_SpawnPoints.Add(point); - } - - // Remove a SpawnPoint - public void RemoveSpawnPoint(int point_index) - { - l_SpawnPoints.RemoveAt(point_index); - } - - // Return the List of SpawnPoints - public List SpawnPoints() - { - return l_SpawnPoints; - - } - - // Clear the SpawnPoints List of all entries - public void ClearSpawnPoints() - { - l_SpawnPoints.Clear(); - } } } diff --git a/OpenSim/Framework/RegionSettings.cs b/OpenSim/Framework/RegionSettings.cs index 673cf20..a2dd64f 100644 --- a/OpenSim/Framework/RegionSettings.cs +++ b/OpenSim/Framework/RegionSettings.cs @@ -26,6 +26,7 @@ */ using System; +using System.Collections.Generic; using System.IO; using OpenMetaverse; @@ -397,5 +398,154 @@ namespace OpenSim.Framework set { m_LoadedCreationID = value; } } + // Telehub support + private bool m_TelehubEnabled = false; + public bool HasTelehub + { + get { return m_TelehubEnabled; } + set { m_TelehubEnabled = value; } + } + + // Connected Telehub object + private UUID m_TelehubObject; + public UUID TelehubObject + { + get + { + if (HasTelehub) + { + return m_TelehubObject; + } + else + { + return UUID.Zero; + } + } + set + { + m_TelehubObject = value; + } + } + + // Connected Telehub name + private string m_TelehubName; + public string TelehubName + { + get + { + if (HasTelehub) + { + return m_TelehubName; + } + else + { + return String.Empty; + } + } + set + { + m_TelehubName = value; + } + } + + // Connected Telehub position + private float m_TelehubPosX; + private float m_TelehubPosY; + private float m_TelehubPosZ; + public Vector3 TelehubPos + { + get + { + if (HasTelehub) + { + Vector3 Pos = new Vector3(m_TelehubPosX, m_TelehubPosY, m_TelehubPosZ); + return Pos; + } + else + { + return Vector3.Zero; + } + } + set + { + + m_TelehubPosX = value.X; + m_TelehubPosY = value.Y; + m_TelehubPosZ = value.Z; + } + } + + // Connected Telehub rotation + private float m_TelehubRotX; + private float m_TelehubRotY; + private float m_TelehubRotZ; + private float m_TelehubRotW; + public Quaternion TelehubRot + { + get + { + if (HasTelehub) + { + Quaternion quat = new Quaternion(); + + quat.X = m_TelehubRotX; + quat.Y = m_TelehubRotY; + quat.Z = m_TelehubRotZ; + quat.W = m_TelehubRotW; + + return quat; + } + else + { + // What else to do?? + Quaternion quat = new Quaternion(); + + quat.X = m_TelehubRotX; + quat.X = m_TelehubRotY; + quat.X = m_TelehubRotZ; + quat.X = m_TelehubRotW; + + return quat; + } + } + set + { + m_TelehubRotX = value.X; + m_TelehubRotY = value.Y; + m_TelehubRotZ = value.Z; + m_TelehubRotW = value.W; + } + } + + // Our Connected Telehub's SpawnPoints + public List l_SpawnPoints = new List(); + + // Add a SpawnPoint + // ** These are not region coordinates ** + // They are relative to the Telehub coordinates + // + public void AddSpawnPoint(Vector3 point) + { + l_SpawnPoints.Add(point); + } + + // Remove a SpawnPoint + public void RemoveSpawnPoint(int point_index) + { + l_SpawnPoints.RemoveAt(point_index); + } + + // Return the List of SpawnPoints + public List SpawnPoints() + { + return l_SpawnPoints; + + } + + // Clear the SpawnPoints List of all entries + public void ClearSpawnPoints() + { + l_SpawnPoints.Clear(); + } } } diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 6a02ffe..cdcea65 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -609,9 +609,9 @@ namespace OpenSim.Region.CoreModules.World.Estate { case "info ui": // Send info: - if (Scene.RegionInfo.EstateSettings.HasTelehub) + if (Scene.RegionInfo.RegionSettings.HasTelehub) { - EstateSettings settings = this.Scene.RegionInfo.EstateSettings; + RegionSettings settings = this.Scene.RegionInfo.RegionSettings; client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, settings.TelehubRot, settings.SpawnPoints()); } @@ -626,7 +626,7 @@ namespace OpenSim.Region.CoreModules.World.Estate part = Scene.GetSceneObjectPart((uint)param1); if (m_Telehub.Connect(part)) { - EstateSettings settings = this.Scene.RegionInfo.EstateSettings; + RegionSettings settings = this.Scene.RegionInfo.RegionSettings; client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, settings.TelehubRot, settings.SpawnPoints()); } @@ -637,7 +637,7 @@ namespace OpenSim.Region.CoreModules.World.Estate part = Scene.GetSceneObjectPart((uint)param1); if (m_Telehub.DisConnect(part)) { - EstateSettings settings = this.Scene.RegionInfo.EstateSettings; + RegionSettings settings = this.Scene.RegionInfo.RegionSettings; client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, settings.TelehubRot, settings.SpawnPoints()); } @@ -648,7 +648,7 @@ namespace OpenSim.Region.CoreModules.World.Estate part = Scene.GetSceneObjectPart((uint)param1); if( m_Telehub.AddSpawnPoint(part.AbsolutePosition)) { - EstateSettings settings = this.Scene.RegionInfo.EstateSettings; + RegionSettings settings = this.Scene.RegionInfo.RegionSettings; client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, settings.TelehubRot, settings.SpawnPoints()); } @@ -658,7 +658,7 @@ namespace OpenSim.Region.CoreModules.World.Estate // Remove SpawnPoint from Telehub if (m_Telehub.RemoveSpawnPoint((int)param1)) { - EstateSettings settings = this.Scene.RegionInfo.EstateSettings; + RegionSettings settings = this.Scene.RegionInfo.RegionSettings; client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, settings.TelehubRot, settings.SpawnPoints()); } diff --git a/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs index 309ef13..ee77ae1 100644 --- a/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs +++ b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs @@ -44,7 +44,6 @@ namespace OpenSim.Region.CoreModules.World.Estate UUID EstateID; bool m_HasTelehub = false; Scene m_Scene; - EstateSettings m_EstateSettings; // This will get an option... Vector3 InitialSpawnPoint = new Vector3(0.0f,0.0f,0.0f); @@ -56,7 +55,6 @@ namespace OpenSim.Region.CoreModules.World.Estate public TelehubManager(Scene scene) { m_Scene = scene; - m_EstateSettings = m_Scene.RegionInfo.EstateSettings; } // Fill our Telehub struct with values @@ -76,17 +74,17 @@ namespace OpenSim.Region.CoreModules.World.Estate // Connect the Telehub public bool Connect(SceneObjectPart part) { - m_EstateSettings.ClearSpawnPoints(); + m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints(); - m_EstateSettings.TelehubObject = part.UUID; - m_EstateSettings.TelehubName = part.Name; - m_EstateSettings.TelehubPos = part.AbsolutePosition; - m_EstateSettings.TelehubRot = part.GetWorldRotation(); + m_Scene.RegionInfo.RegionSettings.TelehubObject = part.UUID; + m_Scene.RegionInfo.RegionSettings.TelehubName = part.Name; + m_Scene.RegionInfo.RegionSettings.TelehubPos = part.AbsolutePosition; + m_Scene.RegionInfo.RegionSettings.TelehubRot = part.GetWorldRotation(); // Clear this for now - m_EstateSettings.AddSpawnPoint(InitialSpawnPoint); - m_EstateSettings.HasTelehub = true; - m_EstateSettings.Save(); + m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(InitialSpawnPoint); + m_Scene.RegionInfo.RegionSettings.HasTelehub = true; + m_Scene.RegionInfo.RegionSettings.Save(); return true; } @@ -96,14 +94,14 @@ namespace OpenSim.Region.CoreModules.World.Estate bool result = false; try{ - m_EstateSettings.TelehubObject = UUID.Zero; - m_EstateSettings.TelehubName = String.Empty; - m_EstateSettings.TelehubPos = Vector3.Zero; + m_Scene.RegionInfo.RegionSettings.TelehubObject = UUID.Zero; + m_Scene.RegionInfo.RegionSettings.TelehubName = String.Empty; + m_Scene.RegionInfo.RegionSettings.TelehubPos = Vector3.Zero; // This is probably wrong! But, HasTelehub will block access - m_EstateSettings.TelehubRot = Quaternion.Identity; - m_EstateSettings.ClearSpawnPoints(); - m_EstateSettings.HasTelehub = false; - m_EstateSettings.Save(); + m_Scene.RegionInfo.RegionSettings.TelehubRot = Quaternion.Identity; + m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints(); + m_Scene.RegionInfo.RegionSettings.HasTelehub = false; + m_Scene.RegionInfo.RegionSettings.Save(); result = true; } catch (Exception ex) @@ -122,22 +120,22 @@ namespace OpenSim.Region.CoreModules.World.Estate public bool AddSpawnPoint(Vector3 point) { - float dist = (float) Util.GetDistanceTo(m_EstateSettings.TelehubPos, point); - Vector3 nvec = Util.GetNormalizedVector(point - m_EstateSettings.TelehubPos); + float dist = (float) Util.GetDistanceTo(m_Scene.RegionInfo.RegionSettings.TelehubPos, point); + Vector3 nvec = Util.GetNormalizedVector(point - m_Scene.RegionInfo.RegionSettings.TelehubPos); Vector3 spoint = nvec * dist; - m_EstateSettings.AddSpawnPoint(spoint); - m_EstateSettings.Save(); + m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(spoint); + m_Scene.RegionInfo.RegionSettings.Save(); return true; } // Remove a SpawnPoint from the Telehub public bool RemoveSpawnPoint(int spawnpoint) { - m_EstateSettings.RemoveSpawnPoint(spawnpoint); - m_EstateSettings.Save(); + m_Scene.RegionInfo.RegionSettings.RemoveSpawnPoint(spawnpoint); + m_Scene.RegionInfo.RegionSettings.Save(); return true; } } -} \ No newline at end of file +} -- cgit v1.1 From 24b20f6e4b98b5d7049d2db77d8701529eab75ca Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 22 Jan 2012 15:35:14 +0000 Subject: Change the key name I missed in last commit --- OpenSim/Data/MySQL/Resources/RegionStore.migrations | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index ce66cfb..3132148 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations @@ -851,7 +851,7 @@ CREATE TABLE IF NOT EXISTS `spawn_points` ( `PointX` float NOT NULL, `PointY` float NOT NULL, `PointZ` float NOT NULL, - KEY `EstateID` (`EstateID`) + KEY `RegionID` (`RegionID`) ) ENGINE=Innodb; ALTER TABLE `regionsettings` ADD COLUMN `TelehubObject` varchar(36) NOT NULL; -- cgit v1.1