From 39c9b656c871bf0eaba104f197a902123d7d9428 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Mon, 23 Jan 2012 09:42:15 -0500 Subject: Cleanup unused parts, add some error handling --- .../CoreModules/World/Estate/TelehubManager.cs | 105 ++++++++++----------- 1 file changed, 52 insertions(+), 53 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs index ee77ae1..68b4ba5 100644 --- a/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs +++ b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs @@ -35,83 +35,66 @@ namespace OpenSim.Region.CoreModules.World.Estate { public class TelehubManager { - - private UUID ObjectID; - private string ObjectName; - private Vector3 ObjectPosition; - Quaternion ObjectRotation; - List SpawnPoint = new List(); - UUID EstateID; - bool m_HasTelehub = false; Scene m_Scene; - // This will get an option... - Vector3 InitialSpawnPoint = new Vector3(0.0f,0.0f,0.0f); - - public bool HasTelehub - { - get { return m_HasTelehub; } - } public TelehubManager(Scene scene) { m_Scene = scene; } - // Fill our Telehub struct with values -// 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 bool Connect(SceneObjectPart part) { - m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints(); + bool result = false; - 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(); + if (m_Scene.RegionInfo.RegionSettings.HasTelehub) + return result; - // Clear this for now - m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(InitialSpawnPoint); - m_Scene.RegionInfo.RegionSettings.HasTelehub = true; - m_Scene.RegionInfo.RegionSettings.Save(); - return true; + try + { + m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints(); + + 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(); + m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(new Vector3(0.0f,0.0f,0.0f)); + m_Scene.RegionInfo.RegionSettings.HasTelehub = true; + m_Scene.RegionInfo.RegionSettings.Save(); + + result = true; + } + catch (Exception ex) + { + result = false; + } + + return result; } - // Disconnect the Telehub: Clear it out for now, look at just disableing + // Disconnect the Telehub: public bool DisConnect(SceneObjectPart part) { bool result = false; - try{ + if (!m_Scene.RegionInfo.RegionSettings.HasTelehub) + return result; + + 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; } @@ -119,19 +102,35 @@ namespace OpenSim.Region.CoreModules.World.Estate // Add a SpawnPoint to the Telehub public bool AddSpawnPoint(Vector3 point) { + bool result = false; - 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; + if (!m_Scene.RegionInfo.RegionSettings.HasTelehub) + return result; - m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(spoint); - m_Scene.RegionInfo.RegionSettings.Save(); - return true; + try + { + 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_Scene.RegionInfo.RegionSettings.AddSpawnPoint(spoint); + m_Scene.RegionInfo.RegionSettings.Save(); + result = true; + } + catch (Exception ex) + { + result = false; + } + + return result; } // Remove a SpawnPoint from the Telehub public bool RemoveSpawnPoint(int spawnpoint) { + if (!m_Scene.RegionInfo.RegionSettings.HasTelehub) + return false; + m_Scene.RegionInfo.RegionSettings.RemoveSpawnPoint(spawnpoint); m_Scene.RegionInfo.RegionSettings.Save(); -- cgit v1.1 From 9cfc43005d8d906083b176a2961aa3892193dcb4 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Mon, 23 Jan 2012 10:28:18 -0500 Subject: Cleanup --- OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs index 68b4ba5..9b92df9 100644 --- a/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs +++ b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs @@ -109,10 +109,13 @@ namespace OpenSim.Region.CoreModules.World.Estate try { - float dist = (float) Util.GetDistanceTo(m_Scene.RegionInfo.RegionSettings.TelehubPos, point); - Vector3 nvec = Util.GetNormalizedVector(point - m_Scene.RegionInfo.RegionSettings.TelehubPos); + Vector3 thPos = m_Scene.RegionInfo.RegionSettings.TelehubPos; + Quaternion thRot = m_Scene.RegionInfo.RegionSettings.TelehubRot; + + float dist = (float) Util.GetDistanceTo(thPos, point); + Vector3 nvec = Util.GetNormalizedVector(point - thPos); Vector3 spoint = nvec * dist; - + m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(spoint); m_Scene.RegionInfo.RegionSettings.Save(); result = true; -- cgit v1.1