From bbbe9e73cca2a0ed5d35db1b054b8ed4cd23bfea Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Mon, 18 Jan 2010 09:14:19 -0800
Subject: * Fixed misspelling of field in GridService * Moved
 TeleportClientHome to EntityTransferModule

---
 .../EntityTransfer/EntityTransferModule.cs         | 35 +++++++++++++++++++-
 .../EntityTransfer/HGEntityTransferModule.cs       | 37 ----------------------
 .../Framework/Interfaces/IEntityTransferModule.cs  |  3 ++
 OpenSim/Region/Framework/Scenes/Scene.cs           | 21 ++++--------
 OpenSim/Services/GridService/GridService.cs        |  2 +-
 5 files changed, 44 insertions(+), 54 deletions(-)

diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 622d057..fcc7a85 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -50,7 +50,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
     {
         private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
 
-        private bool m_Enabled = false;
+        protected bool m_Enabled = false;
         protected Scene m_aScene;
         protected List<UUID> m_agentsInTransit;
 
@@ -94,6 +94,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
                 m_aScene = scene;
 
             scene.RegisterModuleInterface<IEntityTransferModule>(this);
+            scene.EventManager.OnNewClient += OnNewClient;
+        }
+
+        protected void OnNewClient(IClientAPI client)
+        {
+            client.OnTeleportHomeRequest += TeleportHome;
         }
 
         public virtual void Close()
@@ -499,6 +505,33 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
 
         #endregion
 
+        #region Teleport Home
+
+        public virtual void TeleportHome(UUID id, IClientAPI client)
+        {
+            m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName);
+
+            OpenSim.Services.Interfaces.PresenceInfo pinfo = m_aScene.PresenceService.GetAgent(client.SessionId);
+
+            if (pinfo != null)
+            {
+                GridRegion regionInfo = m_aScene.GridService.GetRegionByUUID(UUID.Zero, pinfo.HomeRegionID);
+                if (regionInfo == null)
+                {
+                    // can't find the Home region: Tell viewer and abort
+                    client.SendTeleportFailed("Your home region could not be found.");
+                    return;
+                }
+                // a little eekie that this goes back to Scene and with a forced cast, will fix that at some point...
+                ((Scene)(client.Scene)).RequestTeleportLocation(
+                    client, regionInfo.RegionHandle, pinfo.HomePosition, pinfo.HomeLookAt,
+                    (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome));
+            }
+        }
+
+        #endregion
+
+
         #region Agent Crossings
 
         public void Cross(ScenePresence agent, bool isFlying)
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index 6645293..101aea0 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
@@ -47,7 +47,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
     {
         private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
 
-        private bool m_Enabled = false;
         private IHypergridService m_HypergridService;
         private IHypergridService HyperGridService
         {
@@ -84,42 +83,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
             }
         }
 
-        public override void PostInitialise()
-        {
-        }
-
-        public override void AddRegion(Scene scene)
-        {
-            if (!m_Enabled)
-                return;
-
-            if (m_aScene == null)
-                m_aScene = scene;
-
-            scene.RegisterModuleInterface<IEntityTransferModule>(this);
-        }
-
-        public override void Close()
-        {
-            if (!m_Enabled)
-                return;
-        }
-
-
-        public override void RemoveRegion(Scene scene)
-        {
-            if (!m_Enabled)
-                return;
-            if (scene == m_aScene)
-                m_aScene = null;
-        }
-
-        public override void RegionLoaded(Scene scene)
-        {
-            if (!m_Enabled)
-                return;
-
-        }
 
         #endregion
 
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
index a0505df..73c68f1 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
@@ -30,6 +30,7 @@ using OpenSim.Services.Interfaces;
 using GridRegion = OpenSim.Services.Interfaces.GridRegion;
 
 using OpenMetaverse;
+using OpenSim.Framework;
 using OpenSim.Region.Framework.Scenes;
 
 namespace OpenSim.Region.Framework.Interfaces
@@ -39,6 +40,8 @@ namespace OpenSim.Region.Framework.Interfaces
         void Teleport(ScenePresence agent, ulong regionHandle, Vector3 position,
                                                       Vector3 lookAt, uint teleportFlags);
 
+        void TeleportHome(UUID id, IClientAPI client);
+
         void Cross(ScenePresence agent, bool isFlying);
 
         void AgentArrivedAtDestination(UUID agent);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 5730b56..3cfb236 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2558,7 +2558,6 @@ namespace OpenSim.Region.Framework.Scenes
         {
             client.OnTeleportLocationRequest += RequestTeleportLocation;
             client.OnTeleportLandmarkRequest += RequestTeleportLandmark;
-            client.OnTeleportHomeRequest += TeleportClientHome;
         }
 
         public virtual void SubscribeToClientScriptEvents(IClientAPI client)
@@ -2713,7 +2712,7 @@ namespace OpenSim.Region.Framework.Scenes
         {
             client.OnTeleportLocationRequest -= RequestTeleportLocation;
             client.OnTeleportLandmarkRequest -= RequestTeleportLandmark;
-            client.OnTeleportHomeRequest -= TeleportClientHome;
+            //client.OnTeleportHomeRequest -= TeleportClientHome;
         }
 
         public virtual void UnSubscribeToClientScriptEvents(IClientAPI client)
@@ -2760,20 +2759,12 @@ namespace OpenSim.Region.Framework.Scenes
         /// <param name="client">The IClientAPI for the client</param>
         public virtual void TeleportClientHome(UUID agentId, IClientAPI client)
         {
-            OpenSim.Services.Interfaces.PresenceInfo pinfo = PresenceService.GetAgent(client.SessionId);
-
-            if (pinfo != null)
+            if (m_teleportModule != null)
+                m_teleportModule.TeleportHome(agentId, client);
+            else
             {
-                GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, pinfo.HomeRegionID);
-                if (regionInfo == null)
-                {
-                    // can't find the Home region: Tell viewer and abort
-                    client.SendTeleportFailed("Your home-region could not be found.");
-                    return;
-                }
-                RequestTeleportLocation(
-                    client, regionInfo.RegionHandle, pinfo.HomePosition, pinfo.HomeLookAt,
-                    (uint)(TPFlags.SetLastToTarget | TPFlags.ViaHome));
+                m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
+                client.SendTeleportFailed("Unable to perform teleports on this simulator.");
             }
         }
 
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs
index e912705..9e0790c 100644
--- a/OpenSim/Services/GridService/GridService.cs
+++ b/OpenSim/Services/GridService/GridService.cs
@@ -109,7 +109,7 @@ namespace OpenSim.Services.GridService
                 //
                 // Get it's flags
                 //
-                OpenSim.Data.RegionFlags rflags = (OpenSim.Data.RegionFlags)Convert.ToInt32(region.Data["Flags"]);
+                OpenSim.Data.RegionFlags rflags = (OpenSim.Data.RegionFlags)Convert.ToInt32(region.Data["flags"]);
 
                 // Is this a reservation?
                 //
-- 
cgit v1.1