public RegionInfo GetRegionInfo(string regionName)
        {
            QueryFilter filter = new QueryFilter();
            filter.andFilters["RegionName"] = regionName.MySqlEscape(50);
            List<string> RetVal = GD.Query(new[] { "RegionInfo" }, "simulator", filter, null, null, null);

            if (RetVal.Count == 0)
            {
                return null;
            }

            RegionInfo replyData = new RegionInfo();
            replyData.UnpackRegionInfoData((OSDMap)OSDParser.DeserializeJson(RetVal[0]));
            return replyData;
        }
        public RegionInfo[] GetRegionInfos(bool nonDisabledOnly)
        {
            QueryFilter filter = new QueryFilter();
            if (nonDisabledOnly)
            {
                filter.andFilters["Disabled"] = 0;
            }

            List<string> RetVal = GD.Query(new[] { "RegionInfo" }, "simulator", filter, null, null, null);

            if (RetVal.Count == 0)
            {
                return new RegionInfo[]{};
            }

            List<RegionInfo> Infos = new List<RegionInfo>();
            foreach (string t in RetVal)
            {
                RegionInfo replyData = new RegionInfo();
                replyData.UnpackRegionInfoData((OSDMap)OSDParser.DeserializeJson(t));
                Infos.Add(replyData);
            }
            //Sort by startup number
            Infos.Sort(RegionInfoStartupSorter);
            return Infos.ToArray();
        }
示例#3
0
 public void LoadModuleFromArchive(byte[] data, string filePath, TarArchiveReader.TarEntryType type, IScene scene)
 {
     if (filePath.StartsWith("estate/"))
     {
         string estateData = Encoding.UTF8.GetString(data);
         EstateSettings settings = new EstateSettings(WebUtils.ParseXmlResponse(estateData));
         scene.RegionInfo.EstateSettings = settings;
     }
     else if (filePath.StartsWith("regioninfo/"))
     {
         string m_merge = MainConsole.Instance.Prompt("Should we load the region information from the archive (region name, region position, etc)?", "false");
         RegionInfo settings = new RegionInfo();
         settings.UnpackRegionInfoData((OSDMap)OSDParser.DeserializeLLSDBinary(data));
         if (m_merge == "false")
         {
             //Still load the region settings though
             scene.RegionInfo.RegionSettings = settings.RegionSettings;
             return;
         }
         settings.RegionSettings = scene.RegionInfo.RegionSettings;
         settings.EstateSettings = scene.RegionInfo.EstateSettings;
         scene.RegionInfo = settings;
     }
 }
        public void UpdateRegionInfo(string oldName, RegionInfo regionInfo)
        {
            IRegionInfoConnector connector = DataManager.RequestPlugin<IRegionInfoConnector>();
            if (connector != null)
            {
                //Make sure we have this region in the database
                if (connector.GetRegionInfo(oldName) == null)
                    return;
                RegionInfo copy = new RegionInfo();
                //Make an exact copy
                copy.UnpackRegionInfoData(regionInfo.PackRegionInfoData(true));

                //Fix the name of the region so we can delete the old one
                copy.RegionName = oldName;
                DeleteRegion(copy);
                //Now add the new one
                connector.UpdateRegionInfo(regionInfo);
            }
        }
        public void LoadFromFile()
        {
            GZipStream m_loadStream = new GZipStream(ArchiveHelpers.GetStream(m_fileName), CompressionMode.Decompress);
            TarArchiveReader reader = new TarArchiveReader(m_loadStream);

            byte[] data;
            string filePath;
            TarArchiveReader.TarEntryType entryType;

            #region Our Region Info

            IParcelServiceConnector parcelService = Aurora.DataManager.DataManager.RequestPlugin<IParcelServiceConnector>();

            SceneManager sceneManager = m_simulationBase.ApplicationRegistry.RequestModuleInterface<SceneManager>();
            RegionInfo regionInfo = new RegionInfo();
            IScene fakeScene = new Scene();
            fakeScene.AddModuleInterfaces(m_simulationBase.ApplicationRegistry.GetInterfaces());

            #endregion

            while ((data = reader.ReadEntry(out filePath, out entryType)) != null)
            {
                if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType)
                    continue;

                if (filePath.StartsWith("estate/"))
                {
                    string estateData = Encoding.UTF8.GetString(data);
                    EstateSettings settings = new EstateSettings(WebUtils.ParseXmlResponse(estateData));
                    regionInfo.EstateSettings = settings;
                }
                else if (filePath.StartsWith("regioninfo/"))
                {
                    regionInfo.UnpackRegionInfoData((OSDMap)OSDParser.DeserializeLLSDBinary(data));
                }
            }

            if (!m_useExistingRegionInfo)
            {
                regionInfo.RegionID = UUID.Random();
                regionInfo.RegionName = MainConsole.Instance.Prompt("Region Name: ", regionInfo.RegionName);
                regionInfo.RegionLocX = int.Parse(MainConsole.Instance.Prompt("Region Position X: ", regionInfo.RegionLocX.ToString()));
                regionInfo.RegionLocY = int.Parse(MainConsole.Instance.Prompt("Region Position Y: ", regionInfo.RegionLocY.ToString()));
                regionInfo.InternalEndPoint.Port = int.Parse(MainConsole.Instance.Prompt("HTTP Port: ", regionInfo.InternalEndPoint.Port.ToString()));
            }

            //ISimulationDataStore simulationStore = sceneManager.SimulationDataService;
            //Hijack the old simulation service and replace it with ours
            sceneManager.SimulationDataService = new OverridenFileBasedSimulationData (m_fileName, m_saveNewArchiveAtClose);

            ///Now load the region!
            sceneManager.AllRegions++;
            sceneManager.StartNewRegion (regionInfo);
        }