예제 #1
0
        /// <summary>
        /// Load region settings data
        /// </summary>
        /// <param name="settingsPath"></param>
        /// <param name="data"></param>
        /// <returns>
        /// true if settings were loaded successfully, false otherwise
        /// </returns>
        private void LoadRegionSettings(string settingsPath, byte[] data)
        {
            RegionSettings loadedRegionSettings;

            try
            {
                loadedRegionSettings = RegionSettingsSerializer.Deserialize(data);
            }
            catch (Exception e)
            {
                MainConsole.Instance.ErrorFormat(
                    "[ARCHIVER]: Could not parse region settings file {0}.  Ignoring.  Exception was {1}",
                    settingsPath, e);
                return;
            }

            RegionSettings currentRegionSettings = m_scene.RegionInfo.RegionSettings;

            currentRegionSettings.AgentLimit          = loadedRegionSettings.AgentLimit;
            currentRegionSettings.AllowDamage         = loadedRegionSettings.AllowDamage;
            currentRegionSettings.AllowLandJoinDivide = loadedRegionSettings.AllowLandJoinDivide;
            currentRegionSettings.AllowLandResell     = loadedRegionSettings.AllowLandResell;
            currentRegionSettings.BlockFly            = loadedRegionSettings.BlockFly;
            currentRegionSettings.BlockShowInSearch   = loadedRegionSettings.BlockShowInSearch;
            currentRegionSettings.BlockTerraform      = loadedRegionSettings.BlockTerraform;
            currentRegionSettings.DisableCollisions   = loadedRegionSettings.DisableCollisions;
            currentRegionSettings.DisablePhysics      = loadedRegionSettings.DisablePhysics;
            currentRegionSettings.DisableScripts      = loadedRegionSettings.DisableScripts;
            currentRegionSettings.Elevation1NE        = loadedRegionSettings.Elevation1NE;
            currentRegionSettings.Elevation1NW        = loadedRegionSettings.Elevation1NW;
            currentRegionSettings.Elevation1SE        = loadedRegionSettings.Elevation1SE;
            currentRegionSettings.Elevation1SW        = loadedRegionSettings.Elevation1SW;
            currentRegionSettings.Elevation2NE        = loadedRegionSettings.Elevation2NE;
            currentRegionSettings.Elevation2NW        = loadedRegionSettings.Elevation2NW;
            currentRegionSettings.Elevation2SE        = loadedRegionSettings.Elevation2SE;
            currentRegionSettings.Elevation2SW        = loadedRegionSettings.Elevation2SW;
            currentRegionSettings.FixedSun            = loadedRegionSettings.FixedSun;
            currentRegionSettings.ObjectBonus         = loadedRegionSettings.ObjectBonus;
            currentRegionSettings.RestrictPushing     = loadedRegionSettings.RestrictPushing;
            currentRegionSettings.TerrainLowerLimit   = loadedRegionSettings.TerrainLowerLimit;
            currentRegionSettings.TerrainRaiseLimit   = loadedRegionSettings.TerrainRaiseLimit;
            currentRegionSettings.TerrainTexture1     = loadedRegionSettings.TerrainTexture1;
            currentRegionSettings.TerrainTexture2     = loadedRegionSettings.TerrainTexture2;
            currentRegionSettings.TerrainTexture3     = loadedRegionSettings.TerrainTexture3;
            currentRegionSettings.TerrainTexture4     = loadedRegionSettings.TerrainTexture4;
            currentRegionSettings.UseEstateSun        = loadedRegionSettings.UseEstateSun;
            currentRegionSettings.WaterHeight         = loadedRegionSettings.WaterHeight;

            currentRegionSettings.Save();

            IEstateModule estateModule = m_scene.RequestModuleInterface <IEstateModule>();

            if (estateModule != null)
            {
                estateModule.sendRegionHandshakeToAll();
            }

            return;
        }
예제 #2
0
        public void RegionSettingsTest01()
        {
            RegionSettings settings = new RegionSettings();

            settings.OnSave += RegionSaveFired;
            settings.Save();
            settings.OnSave -= RegionSaveFired;

            Assert.That(m_RegionSettingsOnSaveEventFired, "RegionSettings Save Event didn't Fire");
        }
예제 #3
0
        /// <summary>
        /// Load oar control file
        /// </summary>
        /// <param name="path"></param>
        /// <param name="data"></param>
        public void LoadControlFile(string path, byte[] data)
        {
            XmlNamespaceManager nsmgr   = new XmlNamespaceManager(new NameTable());
            XmlParserContext    context = new XmlParserContext(null, nsmgr, null, XmlSpace.None);
            XmlTextReader       xtr     = new XmlTextReader(Encoding.ASCII.GetString(data), XmlNodeType.Document, context);

            RegionSettings currentRegionSettings = m_scene.RegionInfo.RegionSettings;

            // Loaded metadata will empty if no information exists in the archive
            currentRegionSettings.LoadedCreationDateTime = 0;
            currentRegionSettings.LoadedCreationID       = "";

            while (xtr.Read())
            {
                if (xtr.NodeType == XmlNodeType.Element)
                {
                    if (xtr.Name.ToString() == "archive")
                    {
                        int    majorVersion = int.Parse(xtr["major_version"]);
                        int    minorVersion = int.Parse(xtr["minor_version"]);
                        string version      = string.Format("{0}.{1}", majorVersion, minorVersion);

                        if (majorVersion > MAX_MAJOR_VERSION)
                        {
                            throw new Exception(
                                      string.Format(
                                          "The OAR you are trying to load has major version number of {0} but this version of OpenSim can only load OARs with major version number {1} and below",
                                          majorVersion, MAX_MAJOR_VERSION));
                        }

                        m_log.InfoFormat("[ARCHIVER]: Loading OAR with version {0}", version);
                    }
                    if (xtr.Name.ToString() == "datetime")
                    {
                        int value;
                        if (Int32.TryParse(xtr.ReadElementContentAsString(), out value))
                        {
                            currentRegionSettings.LoadedCreationDateTime = value;
                        }
                    }
                    else if (xtr.Name.ToString() == "id")
                    {
                        currentRegionSettings.LoadedCreationID = xtr.ReadElementContentAsString();
                    }
                }
            }

            currentRegionSettings.Save();

            ControlFileLoaded = true;
        }
예제 #4
0
        public void RegionSettingsTest01()
        {
            RegionSettings settings = new RegionSettings();

            settings.OnSave += RegionSaveFired;
            settings.Save();
            settings.OnSave -= RegionSaveFired;

//            string str = settings.LoadedCreationDate;
//            int dt = settings.LoadedCreationDateTime;
//            string id = settings.LoadedCreationID;
//            string time = settings.LoadedCreationTime;

            Assert.That(m_RegionSettingsOnSaveEventFired, "RegionSettings Save Event didn't Fire");
        }
예제 #5
0
        /// <summary>
        /// Load oar control file
        /// </summary>
        /// <param name="data"></param>
        private void LoadControlFile(byte[] data)
        {
            //Create the XmlNamespaceManager.
            NameTable           nt    = new NameTable();
            XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);

            // Create the XmlParserContext.
            XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None);

            XmlTextReader xtr
                = new XmlTextReader(m_asciiEncoding.GetString(data), XmlNodeType.Document, context);

            RegionSettings currentRegionSettings = m_scene.RegionInfo.RegionSettings;

            // Loaded metadata will empty if no information exists in the archive
            currentRegionSettings.LoadedCreationDateTime = 0;
            currentRegionSettings.LoadedCreationID       = "";

            while (xtr.Read())
            {
                if (xtr.NodeType == XmlNodeType.Element)
                {
                    if (xtr.Name == "datetime")
                    {
                        int value;
                        if (Int32.TryParse(xtr.ReadElementContentAsString(), out value))
                        {
                            currentRegionSettings.LoadedCreationDateTime = value;
                        }
                    }
                    else if (xtr.Name == "id")
                    {
                        currentRegionSettings.LoadedCreationID = xtr.ReadElementContentAsString();
                    }
                }
            }

            currentRegionSettings.Save();
        }
예제 #6
0
        /// <summary>
        /// Load region settings data
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="settingsPath"></param>
        /// <param name="data"></param>
        /// <param name="dearchivedScenes"></param>
        /// <returns>
        /// true if settings were loaded successfully, false otherwise
        /// </returns>
        private bool LoadRegionSettings(Scene scene, string settingsPath, byte[] data, DearchiveScenesInfo dearchivedScenes)
        {
            RegionSettings loadedRegionSettings;

            try
            {
                loadedRegionSettings = RegionSettingsSerializer.Deserialize(data);
            }
            catch (Exception e)
            {
                m_log.ErrorFormat(
                    "[ARCHIVER]: Could not parse region settings file {0}.  Ignoring.  Exception was {1}",
                    settingsPath, e);
                return(false);
            }

            RegionSettings currentRegionSettings = scene.RegionInfo.RegionSettings;

            currentRegionSettings.AgentLimit          = loadedRegionSettings.AgentLimit;
            currentRegionSettings.AllowDamage         = loadedRegionSettings.AllowDamage;
            currentRegionSettings.AllowLandJoinDivide = loadedRegionSettings.AllowLandJoinDivide;
            currentRegionSettings.AllowLandResell     = loadedRegionSettings.AllowLandResell;
            currentRegionSettings.BlockFly            = loadedRegionSettings.BlockFly;
            currentRegionSettings.BlockShowInSearch   = loadedRegionSettings.BlockShowInSearch;
            currentRegionSettings.BlockTerraform      = loadedRegionSettings.BlockTerraform;
            currentRegionSettings.DisableCollisions   = loadedRegionSettings.DisableCollisions;
            currentRegionSettings.DisablePhysics      = loadedRegionSettings.DisablePhysics;
            currentRegionSettings.DisableScripts      = loadedRegionSettings.DisableScripts;
            currentRegionSettings.Elevation1NE        = loadedRegionSettings.Elevation1NE;
            currentRegionSettings.Elevation1NW        = loadedRegionSettings.Elevation1NW;
            currentRegionSettings.Elevation1SE        = loadedRegionSettings.Elevation1SE;
            currentRegionSettings.Elevation1SW        = loadedRegionSettings.Elevation1SW;
            currentRegionSettings.Elevation2NE        = loadedRegionSettings.Elevation2NE;
            currentRegionSettings.Elevation2NW        = loadedRegionSettings.Elevation2NW;
            currentRegionSettings.Elevation2SE        = loadedRegionSettings.Elevation2SE;
            currentRegionSettings.Elevation2SW        = loadedRegionSettings.Elevation2SW;
            currentRegionSettings.FixedSun            = loadedRegionSettings.FixedSun;
            currentRegionSettings.SunPosition         = loadedRegionSettings.SunPosition;
            currentRegionSettings.ObjectBonus         = loadedRegionSettings.ObjectBonus;
            currentRegionSettings.RestrictPushing     = loadedRegionSettings.RestrictPushing;
            currentRegionSettings.TerrainLowerLimit   = loadedRegionSettings.TerrainLowerLimit;
            currentRegionSettings.TerrainRaiseLimit   = loadedRegionSettings.TerrainRaiseLimit;
            currentRegionSettings.TerrainTexture1     = loadedRegionSettings.TerrainTexture1;
            currentRegionSettings.TerrainTexture2     = loadedRegionSettings.TerrainTexture2;
            currentRegionSettings.TerrainTexture3     = loadedRegionSettings.TerrainTexture3;
            currentRegionSettings.TerrainTexture4     = loadedRegionSettings.TerrainTexture4;
            currentRegionSettings.UseEstateSun        = loadedRegionSettings.UseEstateSun;
            currentRegionSettings.WaterHeight         = loadedRegionSettings.WaterHeight;
            currentRegionSettings.TelehubObject       = loadedRegionSettings.TelehubObject;
            currentRegionSettings.ClearSpawnPoints();
            foreach (SpawnPoint sp in loadedRegionSettings.SpawnPoints())
            {
                currentRegionSettings.AddSpawnPoint(sp);
            }

            currentRegionSettings.LoadedCreationDateTime = dearchivedScenes.LoadedCreationDateTime;
            currentRegionSettings.LoadedCreationID       = dearchivedScenes.GetOriginalRegionID(scene.RegionInfo.RegionID).ToString();

            currentRegionSettings.Save();

            scene.TriggerEstateSunUpdate();

            IEstateModule estateModule = scene.RequestModuleInterface <IEstateModule>();

            if (estateModule != null)
            {
                estateModule.sendRegionHandshakeToAll();
            }

            return(true);
        }
예제 #7
0
        private void HandleRegionSet(string module, string[] args)
        {
            if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_scene))
            {
                return;
            }

            if (args.Length != 4)
            {
                MainConsole.Instance.OutputFormat("Usage: region set <param> <value>");
                return;
            }

            string param    = args[2];
            string rawValue = args[3];

            if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_scene))
            {
                return;
            }

            RegionInfo     ri = m_scene.RegionInfo;
            RegionSettings rs = ri.RegionSettings;

            if (param == "agent-limit")
            {
                int newValue;

                if (!ConsoleUtil.TryParseConsoleNaturalInt(MainConsole.Instance, rawValue, out newValue))
                {
                    return;
                }

                if (newValue > ri.AgentCapacity)
                {
                    MainConsole.Instance.OutputFormat(
                        "Cannot set {0} to {1} in {2} as max-agent-limit is {3}", "agent-limit",
                        newValue, m_scene.Name, ri.AgentCapacity);
                }
                else
                {
                    rs.AgentLimit = newValue;

                    MainConsole.Instance.OutputFormat(
                        "{0} set to {1} in {2}", "agent-limit", newValue, m_scene.Name);
                }

                rs.Save();
            }
            else if (param == "max-agent-limit")
            {
                int newValue;

                if (!ConsoleUtil.TryParseConsoleNaturalInt(MainConsole.Instance, rawValue, out newValue))
                {
                    return;
                }

                ri.AgentCapacity = newValue;

                MainConsole.Instance.OutputFormat(
                    "{0} set to {1} in {2}", "max-agent-limit", newValue, m_scene.Name);

                if (ri.AgentCapacity < rs.AgentLimit)
                {
                    rs.AgentLimit = ri.AgentCapacity;

                    MainConsole.Instance.OutputFormat(
                        "Reducing {0} to {1} in {2}", "agent-limit", rs.AgentLimit, m_scene.Name);
                }

                rs.Save();
            }
        }