Ejemplo n.º 1
0
        public uint Count(uint estateID, RegionFlags flags)
        {
            IEstateConnector estates = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();

            if (estates == null)
            {
                return(0);
            }

            EstateSettings es = estates.GetEstateIDSettings((int)estateID);

            QueryFilter filter = new QueryFilter();

            filter.andBitfieldAndFilters ["Flags"] = (uint)flags;

            List <GridRegion> query = ParseQuery(null, m_GD.Query(new string [] { "*" }, m_realm, filter, null, null, null));

            uint count = 0;

            query.ForEach(delegate(GridRegion region) {
                if (region.EstateOwner == es.EstateOwner &&
                    estates.GetRegionEstateID(region.RegionID) == es.EstateID)
                {
                    ++count;
                }
            });

            return(count);
        }
Ejemplo n.º 2
0
        public List <GridRegion> GetList(uint start, uint count, uint estateID, RegionFlags flags,
                                         Dictionary <string, bool> sort)
        {
            List <GridRegion> resp    = new List <GridRegion> ();
            IEstateConnector  estates = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();

            if (count == 0 || estates == null)
            {
                return(resp);
            }

            EstateSettings es = estates.GetEstateIDSettings((int)estateID);

            QueryFilter filter = new QueryFilter();

            filter.andBitfieldAndFilters ["Flags"] = (uint)flags;

            while (resp.Count < count)
            {
                uint limit = count - (uint)resp.Count;
                List <GridRegion> query =
                    ParseQuery(null, m_GD.Query(new string [] { "*" }, m_realm, filter, sort, start, count));

                if (query.Count == 0)
                {
                    break;
                }

                query.ForEach(delegate(GridRegion region) {
                    if (region.EstateOwner == es.EstateOwner &&
                        estates.GetRegionEstateID(region.RegionID) == es.EstateID)
                    {
                        resp.Add(region);
                    }
                });

                start += limit;
            }

            return(resp);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Fixes missing region owners command.
        /// </summary>
        /// <param name="scene">Scene.</param>
        /// <param name="cmd">Cmd.</param>
        void FixMissingRegionOwners(IScene scene, string [] cmd)
        {
            QueryFilter filter = new QueryFilter();

            filter.andFilters ["OwnerUUID"] = UUID.Zero;

            List <GridRegion> borked = ParseQuery(null, m_GD.Query(new string [] { "*" }, m_realm, filter, null, null, null));

            if (borked.Count < 1)
            {
                MainConsole.Instance.Info("[LocalGridConnector] No regions found with missing owners.");
                return;
            }

            IEstateConnector estatePlugin = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();

            if (estatePlugin == null)
            {
                MainConsole.Instance.Error("[LocalGridConnector] " + borked.Count +
                                           " regions found with missing owners, but could not get IEstateConnector plugin.");
                return;
            }


            MainConsole.Instance.Error("[LocalGridConnector] " + borked.Count +
                                       " regions found with missing owners, attempting fix.");

            Dictionary <int, List <GridRegion> > borkedByEstate = new Dictionary <int, List <GridRegion> > ();

            foreach (GridRegion region in borked)
            {
                int estateID = estatePlugin.GetRegionEstateID(region.RegionID);
                if (!borkedByEstate.ContainsKey(estateID))
                {
                    borkedByEstate [estateID] = new List <GridRegion> ();
                }
                borkedByEstate [estateID].Add(region);
            }

            Dictionary <int, UUID> estateOwnerIDs = new Dictionary <int, UUID> ();
            uint estateFail = 0;

            foreach (int estateID in borkedByEstate.Keys)
            {
                EstateSettings es = estatePlugin.GetEstateIDSettings(estateID);
                if ((es == null) || (es.EstateID == 0))
                {
                    MainConsole.Instance.Error("[LocalGridConnector] Cannot fix missing owner for regions in Estate " +
                                               estateID + ", could not get estate settings.");
                }
                else if (es.EstateOwner == UUID.Zero)
                {
                    MainConsole.Instance.Error("[LocalGridConnector] Cannot fix missing owner for regions in Estate " +
                                               estateID + ", Estate Owner is also missing.");
                }
                if (es == null || es.EstateOwner == UUID.Zero)
                {
                    ++estateFail;
                    continue;
                }
                estateOwnerIDs [estateID] = es.EstateOwner;
            }

            if (estateFail > 0)
            {
                if (estateFail == borkedByEstate.Count)
                {
                    MainConsole.Instance.Error("[LocalGridConnector] " + borked.Count +
                                               " regions found with missing owners, could not locate any estate settings from IEstateConnector plugin.");
                    return;
                }

                MainConsole.Instance.Error("[LocalGridConnector] " + borked.Count +
                                           " regions found with missing owners, could not locate estate settings for " +
                                           estateFail + " estates.");
            }

            uint storeSuccess = 0;
            uint storeFail    = 0;
            int  borkedCount  = borked.Count;

            foreach (KeyValuePair <int, UUID> kvp in estateOwnerIDs)
            {
                List <GridRegion> regions = borkedByEstate [kvp.Key];
                foreach (GridRegion region in regions)
                {
                    region.EstateOwner = kvp.Value;
                    if (!Store(region))
                    {
                        MainConsole.Instance.Error("[LocalGridConnector] Failed to fix missing region for " +
                                                   region.RegionName + " (" + region.RegionID + ")");
                        ++storeFail;
                    }
                    else
                    {
                        ++storeSuccess;
                        borked.Remove(region);
                    }
                }
            }

            if (storeFail > 0)
            {
                MainConsole.Instance.Error("[LocalGridConnector] " + borkedCount +
                                           " regions found with missing owners, fix failed on " + storeFail +
                                           " regions, fix attempted on " + storeSuccess + " regions.");
            }
            else if (storeSuccess != borked.Count)
            {
                MainConsole.Instance.Error("[LocalGridConnector] " + borkedCount +
                                           " regions found with missing owners, fix attempted on " + storeSuccess +
                                           " regions.");
            }
            else
            {
                MainConsole.Instance.Info(
                    "[LocalGridConnector] All regions found with missing owners should have their owners restored.");
            }
            if (borked.Count > 0)
            {
                List <string> blurbs = new List <string> (borked.Count);
                foreach (GridRegion region in borked)
                {
                    blurbs.Add(region.RegionName + " (" + region.RegionID + ")");
                }
                MainConsole.Instance.Info("[LocalGridConnector] Failed to fix missing region owners for regions " +
                                          string.Join(", ", blurbs.ToArray()));
            }
        }