From 87799c1f3ddfbc4b0994cac4e54498520899e4d4 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 24 Jan 2012 00:32:10 +0000 Subject: Change Telehubs to store only the data that is really needed and not additional redundant information. --- .../World/Estate/EstateManagementModule.cs | 78 +++++++++++++--------- .../CoreModules/World/Estate/TelehubManager.cs | 70 ++++++------------- 2 files changed, 65 insertions(+), 83 deletions(-) (limited to 'OpenSim/Region/CoreModules/World') diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index cdcea65..2789d5f 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -609,59 +609,37 @@ namespace OpenSim.Region.CoreModules.World.Estate { case "info ui": // Send info: - if (Scene.RegionInfo.RegionSettings.HasTelehub) - { - RegionSettings settings = this.Scene.RegionInfo.RegionSettings; - client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, - settings.TelehubRot, settings.SpawnPoints()); - } - else - { - return; - } + SendTelehubInfo(client); break; case "connect": // Add the Telehub part = Scene.GetSceneObjectPart((uint)param1); - if (m_Telehub.Connect(part)) - { - RegionSettings settings = this.Scene.RegionInfo.RegionSettings; - client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, - settings.TelehubRot, settings.SpawnPoints()); - } + if (part == null) + return; + SceneObjectGroup grp = part.ParentGroup; + + if (m_Telehub.Connect(grp)) + SendTelehubInfo(client); break; case "delete": // Disconnect Telehub - part = Scene.GetSceneObjectPart((uint)param1); - if (m_Telehub.DisConnect(part)) - { - RegionSettings settings = this.Scene.RegionInfo.RegionSettings; - client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, - settings.TelehubRot, settings.SpawnPoints()); - } + if (m_Telehub.Disconnect()) + SendTelehubInfo(client); break; case "spawnpoint add": // Add SpawnPoint to the Telehub part = Scene.GetSceneObjectPart((uint)param1); if( m_Telehub.AddSpawnPoint(part.AbsolutePosition)) - { - RegionSettings settings = this.Scene.RegionInfo.RegionSettings; - client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, - settings.TelehubRot, settings.SpawnPoints()); - } + SendTelehubInfo(client); break; case "spawnpoint remove": // Remove SpawnPoint from Telehub if (m_Telehub.RemoveSpawnPoint((int)param1)) - { - RegionSettings settings = this.Scene.RegionInfo.RegionSettings; - client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, - settings.TelehubRot, settings.SpawnPoints()); - } + SendTelehubInfo(client); break; default: @@ -1316,5 +1294,39 @@ namespace OpenSim.Region.CoreModules.World.Estate if (onmessage != null) onmessage(Scene.RegionInfo.RegionID, fromID, fromName, message); } + + + private void SendTelehubInfo(IClientAPI client) + { + RegionSettings settings = + this.Scene.RegionInfo.RegionSettings; + + SceneObjectGroup telehub = null; + if (settings.TelehubObject != UUID.Zero && + (telehub = Scene.GetSceneObjectGroup(settings.TelehubObject)) != null) + { + List spawnPoints = new List(); + + foreach (SpawnPoint sp in settings.SpawnPoints()) + { + spawnPoints.Add(sp.GetLocation(telehub.AbsolutePosition, telehub.GroupRotation)); + } + + client.SendTelehubInfo(settings.TelehubObject, + telehub.Name, + telehub.AbsolutePosition, + telehub.GroupRotation, + spawnPoints); + } + else + { + client.SendTelehubInfo(UUID.Zero, + String.Empty, + Vector3.Zero, + Quaternion.Identity, + new List()); + } + } } } + diff --git a/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs index 2d7d0ee..3eb7efa 100644 --- a/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs +++ b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs @@ -43,102 +43,72 @@ namespace OpenSim.Region.CoreModules.World.Estate } // Connect the Telehub - public bool Connect(SceneObjectPart part) + public bool Connect(SceneObjectGroup grp) { - bool result = false; - - if (m_Scene.RegionInfo.RegionSettings.HasTelehub) - return result; - 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.TelehubObject = grp.UUID; m_Scene.RegionInfo.RegionSettings.Save(); - - result = true; } catch (Exception ex) { - result = false; + return false; } - return result; + return true; } // Disconnect the Telehub: - public bool DisConnect(SceneObjectPart part) + public bool Disconnect() { - bool result = false; - - if (!m_Scene.RegionInfo.RegionSettings.HasTelehub) - return result; + if (m_Scene.RegionInfo.RegionSettings.TelehubObject == UUID.Zero) + return false; try { m_Scene.RegionInfo.RegionSettings.TelehubObject = UUID.Zero; - m_Scene.RegionInfo.RegionSettings.TelehubName = String.Empty; - m_Scene.RegionInfo.RegionSettings.TelehubPos = Vector3.Zero; m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints(); - m_Scene.RegionInfo.RegionSettings.HasTelehub = false; m_Scene.RegionInfo.RegionSettings.Save(); - - result = true; } catch (Exception ex) { - result = false; + return false; } - return result; + return true; } // Add a SpawnPoint to the Telehub public bool AddSpawnPoint(Vector3 point) { - bool result = false; + if (m_Scene.RegionInfo.RegionSettings.TelehubObject == UUID.Zero) + return false; - if (!m_Scene.RegionInfo.RegionSettings.HasTelehub) - return result; + SceneObjectGroup grp = m_Scene.GetSceneObjectGroup(m_Scene.RegionInfo.RegionSettings.TelehubObject); + if (grp == null) + return false; try { - // Need to update the position in case the Telehubn has been moved - UUID TelehubID = m_Scene.RegionInfo.RegionSettings.TelehubObject; - SceneObjectPart part = m_Scene.GetSceneObjectPart(TelehubID); - - Vector3 TelehubPos = part.AbsolutePosition; - Quaternion TelehubRot = part.GetWorldRotation(); - - m_Scene.RegionInfo.RegionSettings.TelehubPos = TelehubPos; - m_Scene.RegionInfo.RegionSettings.TelehubRot = TelehubRot; - - float dist = (float) Util.GetDistanceTo(TelehubPos, point); - Vector3 nvec = Util.GetNormalizedVector(point - TelehubPos); - Vector3 spoint = nvec * dist; - - m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(spoint); + SpawnPoint sp = new SpawnPoint(); + sp.SetLocation(grp.AbsolutePosition, grp.GroupRotation, point); + m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(sp); m_Scene.RegionInfo.RegionSettings.Save(); - result = true; } catch (Exception ex) { - result = false; + return false; } - return result; + return true; } // Remove a SpawnPoint from the Telehub public bool RemoveSpawnPoint(int spawnpoint) { - if (!m_Scene.RegionInfo.RegionSettings.HasTelehub) + if (m_Scene.RegionInfo.RegionSettings.TelehubObject == UUID.Zero) return false; m_Scene.RegionInfo.RegionSettings.RemoveSpawnPoint(spawnpoint); -- cgit v1.1