Exemple #1
0
        public override bool TeleportHome(UUID id, IClientAPI client)
        {
            m_log.DebugFormat(
                "[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.Name, client.AgentId);

            // Let's find out if this is a foreign user or a local user
            IUserManagement uMan = Scene.RequestModuleInterface <IUserManagement>();

            if (uMan != null && uMan.IsLocalGridUser(id))
            {
                // local grid user
                m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: User is local");
                return(base.TeleportHome(id, client));
            }

            // Foreign user wants to go home
            //
            AgentCircuitData aCircuit = ((Scene)(client.Scene)).AuthenticateHandler.GetAgentCircuitData(client.CircuitCode);

            if (aCircuit == null || (aCircuit != null && !aCircuit.ServiceURLs.ContainsKey("HomeURI")))
            {
                client.SendTeleportFailed("Your information has been lost");
                m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Unable to locate agent's gateway information");
                return(false);
            }

            IUserAgentService userAgentService = new UserAgentServiceConnector(aCircuit.ServiceURLs["HomeURI"].ToString());
            Vector3           position = Vector3.UnitY, lookAt = Vector3.UnitY;
            GridRegion        finalDestination = userAgentService.GetHomeRegion(aCircuit.AgentID, out position, out lookAt);

            if (finalDestination == null)
            {
                client.SendTeleportFailed("Your home region could not be found");
                m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent's home region not found");
                return(false);
            }

            ScenePresence sp = ((Scene)(client.Scene)).GetScenePresence(client.AgentId);

            if (sp == null)
            {
                client.SendTeleportFailed("Internal error");
                m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent not found in the scene where it is supposed to be");
                return(false);
            }

            GridRegion homeGatekeeper = MakeRegion(aCircuit);

            m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: teleporting user {0} {1} home to {2} via {3}:{4}",
                              aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ServerURI, homeGatekeeper.RegionName);

            DoTeleport(
                sp, homeGatekeeper, finalDestination,
                position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome));
            return(true);
        }
Exemple #2
0
        //protected override bool UpdateAgent(GridRegion reg, GridRegion finalDestination, AgentData agentData, ScenePresence sp)
        //{
        //    int flags = Scene.GridService.GetRegionFlags(Scene.RegionInfo.ScopeID, reg.RegionID);
        //    if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0)
        //    {
        //        // this user is going to another grid
        //        if (m_RestrictAppearanceAbroad && Scene.UserManagementModule.IsLocalGridUser(agentData.AgentID))
        //        {
        //            // We need to strip the agent off its appearance
        //            m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: RestrictAppearanceAbroad is ON. Sending generic appearance");

        //            // Delete existing npc attachments
        //            Scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, false);

        //            // XXX: We can't just use IAvatarFactoryModule.SetAppearance() yet since it doesn't transfer attachments
        //            AvatarAppearance newAppearance = new AvatarAppearance(ExportedAppearance, true);
        //            sp.Appearance = newAppearance;

        //            // Rez needed npc attachments
        //            Scene.AttachmentsModule.RezAttachments(sp);


        //            IAvatarFactoryModule module = Scene.RequestModuleInterface<IAvatarFactoryModule>();
        //            //module.SendAppearance(sp.UUID);
        //            module.RequestRebake(sp, false);

        //            Scene.AttachmentsModule.CopyAttachments(sp, agentData);
        //            agentData.Appearance = sp.Appearance;
        //        }
        //    }

        //    foreach (AvatarAttachment a in agentData.Appearance.GetAttachments())
        //        m_log.DebugFormat("[XXX]: {0}-{1}", a.ItemID, a.AssetID);


        //    return base.UpdateAgent(reg, finalDestination, agentData, sp);
        //}


        public override bool TeleportHome(UUID id, IClientAPI client)
        {
            // Let's find out if this is a foreign user or a local user
            IUserManagement uMan = Scene.RequestModuleInterface <IUserManagement>();

            if (uMan != null && uMan.IsLocalGridUser(id))
            {
                // local grid user
                return(base.TeleportHome(id, client));
            }

            bool notsame = false;

            if (client == null)
            {
                m_log.DebugFormat(
                    "[HG ENTITY TRANSFER MODULE]: Request to teleport {0} home", id);
            }
            else
            {
                if (id == client.AgentId)
                {
                    m_log.DebugFormat(
                        "[HG ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.Name, id);
                }
                else
                {
                    notsame = true;
                    m_log.DebugFormat(
                        "[HG ENTITY TRANSFER MODULE]: Request to teleport {0} home by {1} {2}", id, client.Name, client.AgentId);
                }
            }

            ScenePresence sp = ((Scene)(client.Scene)).GetScenePresence(id);

            if (sp == null || sp.IsDeleted || sp.IsChildAgent || sp.ControllingClient == null || !sp.ControllingClient.IsActive)
            {
                if (notsame)
                {
                    client.SendAlertMessage("TeleportHome: Agent not found in the scene");
                }
                m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent not found in the scene");
                return(false);
            }

            IClientAPI targetClient = sp.ControllingClient;

            if (sp.IsInTransit)
            {
                if (notsame)
                {
                    client.SendAlertMessage("TeleportHome: Agent already processing a teleport");
                }
                targetClient.SendTeleportFailed("Already processing a teleport");
                m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent still in teleport");
                return(false);
            }

            // Foreign user wants to go home
            //
            AgentCircuitData aCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(targetClient.CircuitCode);

            if (aCircuit == null)
            {
                if (notsame)
                {
                    client.SendAlertMessage("TeleportHome: Agent information not found");
                }
                targetClient.SendTeleportFailed("Home information not found");
                m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Unable to locate agent's gateway information");
                return(false);
            }
            if (!aCircuit.ServiceURLs.ContainsKey("HomeURI"))
            {
                if (notsame)
                {
                    client.SendAlertMessage("TeleportHome: Agent home not set");
                }
                targetClient.SendTeleportFailed("Home not set");
                m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent home not set");
                return(false);
            }

            string homeURI = aCircuit.ServiceURLs["HomeURI"].ToString();

            IUserAgentService userAgentService = new UserAgentServiceConnector(homeURI);
            Vector3           position = Vector3.UnitY, lookAt = Vector3.UnitY;

            GridRegion finalDestination = null;

            try
            {
                finalDestination = userAgentService.GetHomeRegion(id, out position, out lookAt);
            }
            catch (Exception e)
            {
                m_log.Debug("[HG ENTITY TRANSFER MODULE]: GetHomeRegion call failed ", e);
            }

            if (finalDestination == null)
            {
                if (notsame)
                {
                    client.SendAlertMessage("TeleportHome: Agent Home region not found");
                }
                targetClient.SendTeleportFailed("Home region not found");
                m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent's home region not found");
                return(false);
            }

            GridRegion homeGatekeeper = MakeGateKeeperRegion(homeURI);

            m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: teleporting user {0} {1} home to {2} via {3}:{4}",
                              aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ServerURI, homeGatekeeper.RegionName);

            DoTeleport(sp, homeGatekeeper, finalDestination, position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome));
            return(true);
        }