예제 #1
0
        private void CloseNeighborAgents(GridRegion oldRegion, GridRegion destination, UUID AgentID)
        {
            Util.FireAndForget(delegate(object o)
            {
                //Sleep for 5 seconds to give the agents a chance to cross and get everything right
                Thread.Sleep(5000);
                //Now do a sanity check on the avatar
                IClientCapsService clientCaps = m_registry.RequestModuleInterface <ICapsService>().GetClientCapsService(AgentID);
                if (clientCaps == null)
                {
                    return;
                }
                IRegionClientCapsService rootRegionCaps = clientCaps.GetRootCapsService();
                if (rootRegionCaps == null)
                {
                    return;
                }
                IRegionClientCapsService ourRegionCaps = clientCaps.GetCapsService(destination.RegionHandle);
                if (ourRegionCaps == null)
                {
                    return;
                }
                //If they handles arn't the same, the agent moved, and we can't be sure that we should close these agents
                if (rootRegionCaps.RegionHandle != ourRegionCaps.RegionHandle)
                {
                    return;
                }

                INeighborService service = m_registry.RequestModuleInterface <INeighborService>();
                if (service != null)
                {
                    List <GridRegion> NeighborsOfOldRegion         = service.GetNeighbors(oldRegion);
                    List <GridRegion> NeighborsOfDestinationRegion = service.GetNeighbors(destination);

                    List <GridRegion> byebyeRegions = new List <GridRegion>(NeighborsOfOldRegion);
                    byebyeRegions.Add(oldRegion); //Add the old region, because it might need closed too

                    byebyeRegions.RemoveAll(delegate(GridRegion r)
                    {
                        if (r.RegionID == destination.RegionID)
                        {
                            return(true);
                        }
                        else if (NeighborsOfDestinationRegion.Contains(r))
                        {
                            return(true);
                        }
                        return(false);
                    });

                    if (byebyeRegions.Count > 0)
                    {
                        m_log.Info("[AgentProcessing]: Closing " + byebyeRegions.Count + " child agents around " + oldRegion.RegionName);
                        SendCloseChildAgent(AgentID, byebyeRegions);
                    }
                }
            });
        }
예제 #2
0
        private byte[] GetNeighbors(Dictionary <string, object> request)
        {
            byte[] result = new byte[0];

            if (!CheckThreatLevel(NeighborThreatLevel.None))
            {
                return(result);
            }

            // retrieve the region
            RegionInfo aRegion = new RegionInfo();

            try
            {
                aRegion.UnpackRegionInfoData(Util.DictionaryToOSD(request));
            }
            catch (Exception)
            {
                return(result);
            }

            // Finally!
            List <GridRegion> thisRegion = m_NeighborService.GetNeighbors(aRegion);

            Dictionary <string, object> resp = new Dictionary <string, object>();

            if (thisRegion.Count != 0)
            {
                resp["success"] = "true";
                int i = 0;
                foreach (GridRegion r in thisRegion)
                {
                    Dictionary <string, object> region = r.ToKeyValuePairs();
                    resp["region" + i] = region;
                    i++;
                }
            }
            else
            {
                resp["success"] = "false";
            }

            string       xmlString = WebUtils.BuildXmlResponse(resp);
            UTF8Encoding encoding  = new UTF8Encoding();

            return(encoding.GetBytes(xmlString));
        }
예제 #3
0
        public bool EnableChildAgentsForRegion(GridRegion requestingRegion)
        {
            int              count           = 0;
            bool             informed        = true;
            INeighborService neighborService = m_registry.RequestModuleInterface <INeighborService>();

            if (neighborService != null)
            {
                List <GridRegion> neighbors = neighborService.GetNeighbors(requestingRegion, 0);

                foreach (GridRegion neighbor in neighbors)
                {
                    //m_log.WarnFormat("--> Going to send child agent to {0}, new agent {1}", neighbour.RegionName, newAgent);

                    IRegionCapsService regionCaps = m_registry.RequestModuleInterface <ICapsService>().GetCapsForRegion(neighbor.RegionHandle);
                    if (regionCaps == null) //If there isn't a region caps, there isn't an agent in this sim
                    {
                        continue;
                    }
                    List <UUID> usersInformed = new List <UUID>();
                    foreach (IRegionClientCapsService regionClientCaps in regionCaps.GetClients())
                    {
                        if (usersInformed.Contains(regionClientCaps.AgentID)) //Only inform agents once
                        {
                            continue;
                        }

                        AgentCircuitData regionCircuitData = regionClientCaps.CircuitData.Copy();
                        regionCircuitData.child = true; //Fix child agent status
                        string reason;                  //Tell the region about it
                        if (!InformClientOfNeighbor(regionClientCaps.AgentID, requestingRegion.RegionHandle,
                                                    regionCircuitData, requestingRegion, (uint)TeleportFlags.Default, null, out reason))
                        {
                            informed = false;
                        }
                        else
                        {
                            usersInformed.Add(regionClientCaps.AgentID);
                        }
                    }
                    count++;
                }
            }
            return(informed);
        }
예제 #4
0
        protected void SendChildAgentUpdateAsync(AgentPosition agentpos, IRegionClientCapsService regionCaps)
        {
            //We need to send this update out to all the child agents this region has
            INeighborService service = m_registry.RequestModuleInterface <INeighborService>();

            if (service != null)
            {
                ISimulationService SimulationService = m_registry.RequestModuleInterface <ISimulationService>();
                if (SimulationService != null)
                {
                    //Set the last location in the database
                    IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService>();
                    if (agentInfoService != null)
                    {
                        //Find the lookAt vector
                        Vector3 lookAt = new Vector3(agentpos.AtAxis.X, agentpos.AtAxis.Y, 0);

                        if (lookAt != Vector3.Zero)
                        {
                            lookAt = Util.GetNormalizedVector(lookAt);
                        }
                        //Update the database
                        agentInfoService.SetLastPosition(regionCaps.AgentID.ToString(), regionCaps.Region.RegionID,
                                                         agentpos.Position, lookAt);
                    }

                    //Also update the service itself
                    regionCaps.LastPosition = agentpos.Position;

                    //Tell all neighbor regions about the new position as well
                    List <GridRegion> ourNeighbors = service.GetNeighbors(regionCaps.Region);
                    foreach (GridRegion region in ourNeighbors)
                    {
                        //Update all the neighbors that we have
                        if (!SimulationService.UpdateAgent(region, agentpos))
                        {
                            m_log.Info("[AgentProcessing]: Failed to inform " + region.RegionName + " about updating agent. ");
                        }
                    }
                }
            }
        }
예제 #5
0
        public bool EnableChildAgents(UUID AgentID, ulong requestingRegion, int DrawDistance, AgentCircuitData circuit)
        {
            int              count           = 0;
            bool             informed        = true;
            INeighborService neighborService = m_registry.RequestModuleInterface <INeighborService>();

            if (neighborService != null)
            {
                int x, y;
                Util.UlongToInts(requestingRegion, out x, out y);
                GridRegion ourRegion = m_registry.RequestModuleInterface <IGridService>().GetRegionByPosition(UUID.Zero, x, y);
                if (ourRegion == null)
                {
                    m_log.Info("[AgentProcessing]: Failed to inform neighbors about new agent, could not find our region.");
                    return(false);
                }
                List <GridRegion> neighbors = neighborService.GetNeighbors(ourRegion, DrawDistance);

                foreach (GridRegion neighbor in neighbors)
                {
                    //m_log.WarnFormat("--> Going to send child agent to {0}, new agent {1}", neighbour.RegionName, newAgent);

                    if (neighbor.RegionHandle != requestingRegion)
                    {
                        string           reason;
                        AgentCircuitData regionCircuitData = circuit.Copy();
                        regionCircuitData.child = true; //Fix child agent status
                        if (!InformClientOfNeighbor(AgentID, requestingRegion, regionCircuitData, neighbor,
                                                    (uint)TeleportFlags.Default, null, out reason))
                        {
                            informed = false;
                        }
                    }
                    count++;
                }
            }
            return(informed);
        }