diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 3d647ca38c..3dd46cbdf6 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -210,7 +210,6 @@ namespace OpenSim.Data.MySQL } LoadBanList(es); - es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers"); es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users"); es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups"); diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 40619deb77..afd42d759c 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -861,6 +861,8 @@ namespace OpenSim.Data.MySQL } } + LoadSpawnPoints(rs); + return rs; } @@ -1032,6 +1034,7 @@ namespace OpenSim.Data.MySQL } } } + SaveSpawnPoints(rs); } public virtual List LoadLandObjects(UUID regionUUID) @@ -1852,5 +1855,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/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index c2b130cb88..3872a75393 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 `RegionID` (`RegionID`) +) 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/RegionSettings.cs b/OpenSim/Framework/RegionSettings.cs index f0786fc90d..2c9f7d24f2 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; @@ -410,5 +411,155 @@ namespace OpenSim.Framework get { return m_Casino; } set { m_Casino = 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/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index d9dc6b7dd8..bbaa08ef03 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -9303,10 +9303,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 35ad939c70..4f3b2710c3 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -55,7 +55,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; @@ -615,22 +615,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.RegionSettings.HasTelehub) { - telehub = m_Telehub.TelehubVals(); - client.SendTelehubInfo(telehub.ObjectID, telehub.ObjectName, telehub.ObjectPosition, - telehub.ObjectRotation, telehub.SpawnPoint); + RegionSettings settings = this.Scene.RegionInfo.RegionSettings; + client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, + settings.TelehubRot, settings.SpawnPoints()); } else { @@ -641,32 +639,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)) + { + RegionSettings settings = this.Scene.RegionInfo.RegionSettings; + 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)) + { + RegionSettings settings = this.Scene.RegionInfo.RegionSettings; + 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)) + { + RegionSettings settings = this.Scene.RegionInfo.RegionSettings; + 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)) + { + RegionSettings settings = this.Scene.RegionInfo.RegionSettings; + 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 c99c9baa38..ee77ae1d28 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; @@ -53,7 +45,7 @@ namespace OpenSim.Region.CoreModules.World.Estate bool m_HasTelehub = false; Scene m_Scene; // 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 { @@ -66,65 +58,84 @@ namespace OpenSim.Region.CoreModules.World.Estate } // 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_Scene.RegionInfo.RegionSettings.ClearSpawnPoints(); - return TelehubVals(); + 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_Scene.RegionInfo.RegionSettings.AddSpawnPoint(InitialSpawnPoint); + m_Scene.RegionInfo.RegionSettings.HasTelehub = true; + m_Scene.RegionInfo.RegionSettings.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; + bool result = false; - return TelehubVals(); + try{ + 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_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) + { + 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_Scene.RegionInfo.RegionSettings.TelehubPos, point); + Vector3 nvec = Util.GetNormalizedVector(point - m_Scene.RegionInfo.RegionSettings.TelehubPos); Vector3 spoint = nvec * dist; - SpawnPoint.Add(spoint); - return TelehubVals(); + m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(spoint); + m_Scene.RegionInfo.RegionSettings.Save(); + return true; } // Remove a SpawnPoint from the Telehub - public Telehub RemoveSpawnPoint(int spawnpoint) + public bool RemoveSpawnPoint(int spawnpoint) { - SpawnPoint.RemoveAt(spawnpoint); + m_Scene.RegionInfo.RegionSettings.RemoveSpawnPoint(spawnpoint); + m_Scene.RegionInfo.RegionSettings.Save(); - return TelehubVals(); + return true; } } -} \ No newline at end of file +}