Ejemplo n.º 1
0
        private Hashtable TeleportLocation(Hashtable mDhttpMethod, UUID agentID)
        {
            Hashtable responsedata = new Hashtable();

            responsedata["int_response_code"] = 200; //501; //410; //404;
            responsedata["content_type"]      = "text/plain";
            responsedata["keepalive"]         = false;

            OSDMap  rm       = (OSDMap)OSDParser.DeserializeLLSDXml((string)mDhttpMethod["requestbody"]);
            OSDMap  pos      = rm["LocationPos"] as OSDMap;
            Vector3 position = new Vector3((float)pos["X"].AsReal(),
                                           (float)pos["Y"].AsReal(),
                                           (float)pos["Z"].AsReal());
            OSDMap lookat = rm["LocationLookAt"] as OSDMap;
            // this vector does not appear to be used
            Vector3 lookAt = new Vector3((float)lookat["X"].AsReal(),
                                         (float)lookat["Y"].AsReal(),
                                         (float)lookat["Z"].AsReal());
            ulong      RegionHandle = rm["RegionHandle"].AsULong();
            const uint tpFlags      = 16;

            OSDMap retVal = new OSDMap();
            string reason = "";
            int    x, y;

            Util.UlongToInts(RegionHandle, out x, out y);
            GridRegion destination = m_service.Registry.RequestModuleInterface <IGridService>().GetRegionByPosition(UUID.Zero,
                                                                                                                    x, y);
            ISimulationService simService  = m_service.Registry.RequestModuleInterface <ISimulationService>();
            AgentData          ad          = new AgentData();
            AgentCircuitData   circuitData = null;

            if (destination != null)
            {
                simService.RetrieveAgent(m_service.Region, m_service.AgentID, true, out ad, out circuitData);
                if (ad != null)
                {
                    ad.Position = position;
                }
            }
            if (destination == null || circuitData == null)
            {
                retVal.Add("reason", "Could not find the destination region.");
                retVal.Add("success", OSD.FromBoolean(false));
                responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(retVal);
                return(responsedata);
            }
            circuitData.reallyischild = false;
            circuitData.child         = false;
            if (m_agentProcessing.TeleportAgent(ref destination, tpFlags, ad == null ? 0 : (int)ad.Far, circuitData, ad,
                                                m_service.AgentID, m_service.RegionHandle, out reason))
            {
                retVal.Add("success", OSD.FromBoolean(true));
                if (m_service.RegionHandle != destination.RegionHandle)
                {
                    simService.MakeChildAgent(m_service.AgentID, m_service.Region);
                }
            }
            else
            {
                simService.FailedToMoveAgentIntoNewRegion(m_service.AgentID, destination.RegionID);
                retVal.Add("reason", reason);
                retVal.Add("success", OSD.FromBoolean(false));
            }

            //Send back data
            responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(retVal);
            return(responsedata);
        }
Ejemplo n.º 2
0
        byte[] TeleportLocation(Stream request, UUID agentID)
        {
            OSDMap retVal = new OSDMap();

            if (_isInTeleportCurrently)
            {
                retVal.Add("reason", "Duplicate teleport request.");
                retVal.Add("success", OSD.FromBoolean(false));
                return(OSDParser.SerializeLLSDXmlBytes(retVal));
            }
            _isInTeleportCurrently = true;

            OSDMap  rm       = (OSDMap)OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request));
            OSDMap  pos      = rm ["LocationPos"] as OSDMap;
            Vector3 position = new Vector3(
                (float)pos ["X"].AsReal(),
                (float)pos ["Y"].AsReal(),
                (float)pos ["Z"].AsReal());

            /*OSDMap lookat = rm["LocationLookAt"] as OSDMap;
             * Vector3 lookAt = new Vector3((float)lookat["X"].AsReal(),
             *  (float)lookat["Y"].AsReal(),
             *  (float)lookat["Z"].AsReal());*/
            ulong      RegionHandle = rm ["RegionHandle"].AsULong();
            const uint tpFlags      = 16;

            if (m_service.ClientCaps.GetRootCapsService().RegionHandle != m_service.RegionHandle)
            {
                retVal.Add("reason", "Contacted by non-root region for teleport. Protocol implementation is wrong.");
                retVal.Add("success", OSD.FromBoolean(false));
                return(OSDParser.SerializeLLSDXmlBytes(retVal));
            }

            string reason = "";
            int    x, y;

            Util.UlongToInts(RegionHandle, out x, out y);
            GridRegion destination = m_service.Registry.RequestModuleInterface <IGridService> ().GetRegionByPosition(
                m_service.ClientCaps.AccountInfo.AllScopeIDs, x, y);
            ISimulationService simService  = m_service.Registry.RequestModuleInterface <ISimulationService> ();
            AgentData          ad          = new AgentData();
            AgentCircuitData   circuitData = null;

            if (destination != null)
            {
                simService.RetrieveAgent(m_service.Region, m_service.AgentID, true, out ad, out circuitData);
                if (ad != null)
                {
                    ad.Position = position;
                    ad.Center   = position;
                    circuitData.StartingPosition = position;
                }
            }
            if (destination == null || circuitData == null)
            {
                retVal.Add("reason", "Could not find the destination region.");
                retVal.Add("success", OSD.FromBoolean(false));
                return(OSDParser.SerializeLLSDXmlBytes(retVal));
            }
            circuitData.IsChildAgent = false;

            if (m_agentProcessing.TeleportAgent(ref destination, tpFlags, circuitData, ad,
                                                m_service.AgentID, m_service.RegionID, out reason) || reason == "")
            {
                retVal.Add("success", OSD.FromBoolean(true));
            }
            else
            {
                if (reason != "Already in a teleport")
                {
                    //If this error occurs... don't kick them out of their current region
                    simService.FailedToMoveAgentIntoNewRegion(m_service.AgentID, destination);
                }
                retVal.Add("reason", reason);
                retVal.Add("success", OSD.FromBoolean(false));
            }

            //Send back data
            _isInTeleportCurrently = false;
            return(OSDParser.SerializeLLSDXmlBytes(retVal));
        }