Esempio n. 1
0
        public List <GridRegion> GetRegionsByURI(UUID scopeID, RegionURI nameURI, int maxNumber)
        {
            // m_log.DebugFormat("[GRID SERVICE]: GetRegionsByName {0}", name);
            if (!nameURI.IsValid)
            {
                return(new List <GridRegion>());
            }

            bool localGrid;

            if (nameURI.HasHost)
            {
                if (!nameURI.ResolveDNS())
                {
                    return(new List <GridRegion>());
                }
                localGrid           = m_HypergridLinker.IsLocalGrid(nameURI.HostUrl);
                nameURI.IsLocalGrid = localGrid;
                if (!nameURI.IsValid)
                {
                    return(new List <GridRegion>());
                }
            }
            else
            {
                localGrid = true;
            }

            int count = 0;

            string            mapname = nameURI.RegionHostPortSpaceName;
            List <RegionData> rdatas  = m_Database.Get("%" + Util.EscapeForLike(mapname) + "%", scopeID);
            List <GridRegion> rinfos  = new List <GridRegion>();

            if (localGrid)
            {
                if (!nameURI.HasRegionName)
                {
                    List <GridRegion> dinfos = GetDefaultRegions(scopeID);
                    if (dinfos != null && dinfos.Count > 0)
                    {
                        rinfos.Add(dinfos[0]);
                    }
                }
                else
                {
                    string name = nameURI.RegionName;
                    if (rdatas != null && (rdatas.Count > 0))
                    {
                        //m_log.DebugFormat("[GRID SERVICE]: Found {0} regions", rdatas.Count);
                        foreach (RegionData rdata in rdatas)
                        {
                            if (name.Equals(rdata.RegionName, StringComparison.InvariantCultureIgnoreCase))
                            {
                                rinfos.Insert(0, RegionData2RegionInfo(rdata));
                                if (count == maxNumber)
                                {
                                    rinfos.RemoveAt(count - 1);
                                }
                            }
                            else if (count++ < maxNumber)
                            {
                                rinfos.Add(RegionData2RegionInfo(rdata));
                            }
                        }
                    }
                }
                return(rinfos);
            }

            if (!m_AllowHypergridMapSearch)
            {
                return(rinfos);
            }

            if (rdatas != null && (rdatas.Count > 0))
            {
                bool haveMatch = false;
                // m_log.DebugFormat("[GRID SERVICE]: Found {0} regions", rdatas.Count);
                foreach (RegionData rdata in rdatas)
                {
                    int indx = rdata.RegionName.IndexOf("://");
                    if (indx < 0)
                    {
                        continue;
                    }
                    string rname = rdata.RegionName.Substring(indx + 3);
                    if (mapname.Equals(rname, StringComparison.InvariantCultureIgnoreCase))
                    {
                        haveMatch = true;
                        rinfos.Insert(0, RegionData2RegionInfo(rdata));
                        if (count == maxNumber)
                        {
                            rinfos.RemoveAt(count - 1);
                        }
                    }
                    else if (count++ < maxNumber)
                    {
                        rinfos.Add(RegionData2RegionInfo(rdata));
                    }
                }
                if (haveMatch)
                {
                    return(rinfos);
                }
            }

            GridRegion r = m_HypergridLinker.LinkRegion(scopeID, nameURI);

            if (r != null)
            {
                if (count == maxNumber)
                {
                    rinfos.RemoveAt(count - 1);
                }
                rinfos.Add(r);
            }

            return(rinfos);
        }
Esempio n. 2
0
        public GridRegion GetRegionByURI(UUID scopeID, RegionURI uri)
        {
            if (!uri.IsValid)
            {
                return(null);
            }

            bool localGrid = true;

            if (uri.HasHost)
            {
                if (!uri.ResolveDNS())
                {
                    return(null);
                }
                localGrid       = m_HypergridLinker.IsLocalGrid(uri.HostUrl);
                uri.IsLocalGrid = localGrid;
            }

            if (localGrid)
            {
                if (uri.HasRegionName)
                {
                    RegionData rdata = m_Database.GetSpecific(uri.RegionName, scopeID);
                    if (rdata != null)
                    {
                        return(RegionData2RegionInfo(rdata));
                    }
                }
                else
                {
                    List <GridRegion> defregs = GetDefaultRegions(scopeID);
                    if (defregs != null)
                    {
                        return(defregs[0]);
                    }
                }
                return(null);
            }

            if (!m_AllowHypergridMapSearch)
            {
                return(null);
            }

            string            mapname = uri.RegionHostPortSpaceName;
            List <RegionData> rdatas  = m_Database.Get("%" + Util.EscapeForLike(mapname), scopeID);

            if (rdatas != null && rdatas.Count > 0)
            {
                foreach (RegionData rdata in rdatas)
                {
                    int indx = rdata.RegionName.IndexOf("://");
                    if (indx < 0)
                    {
                        continue;
                    }
                    string rname = rdata.RegionName.Substring(indx + 3);
                    if (mapname.Equals(rname, StringComparison.InvariantCultureIgnoreCase))
                    {
                        return(RegionData2RegionInfo(rdata));
                    }
                }
            }

            GridRegion r = m_HypergridLinker.LinkRegion(scopeID, uri);

            return(r);
        }