public void Setup()
 {
     m_rs                     = new RegionSettings();
     m_rs.AgentLimit          = 17;
     m_rs.AllowDamage         = true;
     m_rs.AllowLandJoinDivide = true;
     m_rs.AllowLandResell     = true;
     m_rs.BlockFly            = true;
     m_rs.BlockShowInSearch   = true;
     m_rs.BlockTerraform      = true;
     m_rs.DisableCollisions   = true;
     m_rs.DisablePhysics      = true;
     m_rs.DisableScripts      = true;
     m_rs.Elevation1NW        = 15.9;
     m_rs.Elevation1NE        = 45.3;
     m_rs.Elevation1SE        = 49;
     m_rs.Elevation1SW        = 1.9;
     m_rs.Elevation2NW        = 4.5;
     m_rs.Elevation2NE        = 19.2;
     m_rs.Elevation2SE        = 9.2;
     m_rs.Elevation2SW        = 2.1;
     m_rs.FixedSun            = true;
     m_rs.SunPosition         = 12.0;
     m_rs.ObjectBonus         = 1.4;
     m_rs.RestrictPushing     = true;
     m_rs.TerrainLowerLimit   = 0.4;
     m_rs.TerrainRaiseLimit   = 17.9;
     m_rs.TerrainTexture1     = UUID.Parse("00000000-0000-0000-0000-000000000020");
     m_rs.TerrainTexture2     = UUID.Parse("00000000-0000-0000-0000-000000000040");
     m_rs.TerrainTexture3     = UUID.Parse("00000000-0000-0000-0000-000000000060");
     m_rs.TerrainTexture4     = UUID.Parse("00000000-0000-0000-0000-000000000080");
     m_rs.UseEstateSun        = true;
     m_rs.WaterHeight         = 23;
     m_rs.TelehubObject       = UUID.Parse("00000000-0000-0000-0000-111111111111");
     m_rs.AddSpawnPoint(SpawnPoint.Parse("1,-2,0.33"));
 }
Beispiel #2
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);
        }
        /// <summary>
        /// Deserialize settings
        /// </summary>
        /// <param name="serializedSettings"></param>
        /// <returns></returns>
        /// <exception cref="System.Xml.XmlException"></exception>
        public static RegionSettings Deserialize(string serializedSettings)
        {
            RegionSettings settings = new RegionSettings();

            StringReader  sr  = new StringReader(serializedSettings);
            XmlTextReader xtr = new XmlTextReader(sr);

            xtr.ProhibitDtd = true;

            xtr.ReadStartElement("RegionSettings");

            xtr.ReadStartElement("General");

            while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
            {
                switch (xtr.Name)
                {
                case "AllowDamage":
                    settings.AllowDamage = bool.Parse(xtr.ReadElementContentAsString());
                    break;

                case "AllowLandResell":
                    settings.AllowLandResell = bool.Parse(xtr.ReadElementContentAsString());
                    break;

                case "AllowLandJoinDivide":
                    settings.AllowLandJoinDivide = bool.Parse(xtr.ReadElementContentAsString());
                    break;

                case "BlockFly":
                    settings.BlockFly = bool.Parse(xtr.ReadElementContentAsString());
                    break;

                case "BlockLandShowInSearch":
                    settings.BlockShowInSearch = bool.Parse(xtr.ReadElementContentAsString());
                    break;

                case "BlockTerraform":
                    settings.BlockTerraform = bool.Parse(xtr.ReadElementContentAsString());
                    break;

                case "DisableCollisions":
                    settings.DisableCollisions = bool.Parse(xtr.ReadElementContentAsString());
                    break;

                case "DisablePhysics":
                    settings.DisablePhysics = bool.Parse(xtr.ReadElementContentAsString());
                    break;

                case "DisableScripts":
                    settings.DisableScripts = bool.Parse(xtr.ReadElementContentAsString());
                    break;

                case "MaturityRating":
                    settings.Maturity = int.Parse(xtr.ReadElementContentAsString());
                    break;

                case "RestrictPushing":
                    settings.RestrictPushing = bool.Parse(xtr.ReadElementContentAsString());
                    break;

                case "AgentLimit":
                    settings.AgentLimit = int.Parse(xtr.ReadElementContentAsString());
                    break;

                case "ObjectBonus":
                    settings.ObjectBonus = double.Parse(xtr.ReadElementContentAsString(), Culture.NumberFormatInfo);
                    break;
                }
            }

            xtr.ReadEndElement();
            xtr.ReadStartElement("GroundTextures");

            while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
            {
                switch (xtr.Name)
                {
                case "Texture1":
                    settings.TerrainTexture1 = UUID.Parse(xtr.ReadElementContentAsString());
                    break;

                case "Texture2":
                    settings.TerrainTexture2 = UUID.Parse(xtr.ReadElementContentAsString());
                    break;

                case "Texture3":
                    settings.TerrainTexture3 = UUID.Parse(xtr.ReadElementContentAsString());
                    break;

                case "Texture4":
                    settings.TerrainTexture4 = UUID.Parse(xtr.ReadElementContentAsString());
                    break;

                case "ElevationLowSW":
                    settings.Elevation1SW = double.Parse(xtr.ReadElementContentAsString(), Culture.NumberFormatInfo);
                    break;

                case "ElevationLowNW":
                    settings.Elevation1NW = double.Parse(xtr.ReadElementContentAsString(), Culture.NumberFormatInfo);
                    break;

                case "ElevationLowSE":
                    settings.Elevation1SE = double.Parse(xtr.ReadElementContentAsString(), Culture.NumberFormatInfo);
                    break;

                case "ElevationLowNE":
                    settings.Elevation1NE = double.Parse(xtr.ReadElementContentAsString(), Culture.NumberFormatInfo);
                    break;

                case "ElevationHighSW":
                    settings.Elevation2SW = double.Parse(xtr.ReadElementContentAsString(), Culture.NumberFormatInfo);
                    break;

                case "ElevationHighNW":
                    settings.Elevation2NW = double.Parse(xtr.ReadElementContentAsString(), Culture.NumberFormatInfo);
                    break;

                case "ElevationHighSE":
                    settings.Elevation2SE = double.Parse(xtr.ReadElementContentAsString(), Culture.NumberFormatInfo);
                    break;

                case "ElevationHighNE":
                    settings.Elevation2NE = double.Parse(xtr.ReadElementContentAsString(), Culture.NumberFormatInfo);
                    break;
                }
            }

            xtr.ReadEndElement();
            xtr.ReadStartElement("Terrain");

            while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
            {
                switch (xtr.Name)
                {
                case "WaterHeight":
                    settings.WaterHeight = double.Parse(xtr.ReadElementContentAsString(), Culture.NumberFormatInfo);
                    break;

                case "TerrainRaiseLimit":
                    settings.TerrainRaiseLimit = double.Parse(xtr.ReadElementContentAsString(), Culture.NumberFormatInfo);
                    break;

                case "TerrainLowerLimit":
                    settings.TerrainLowerLimit = double.Parse(xtr.ReadElementContentAsString(), Culture.NumberFormatInfo);
                    break;

                case "UseEstateSun":
                    settings.UseEstateSun = bool.Parse(xtr.ReadElementContentAsString());
                    break;

                case "FixedSun":
                    settings.FixedSun = bool.Parse(xtr.ReadElementContentAsString());
                    break;

                case "SunPosition":
                    settings.SunPosition = double.Parse(xtr.ReadElementContentAsString());
                    break;
                }
            }

            xtr.ReadEndElement();

            if (xtr.IsStartElement("Telehub"))
            {
                xtr.ReadStartElement("Telehub");

                while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
                {
                    switch (xtr.Name)
                    {
                    case "TelehubObject":
                        settings.TelehubObject = UUID.Parse(xtr.ReadElementContentAsString());
                        break;

                    case "SpawnPoint":
                        string     str = xtr.ReadElementContentAsString();
                        SpawnPoint sp  = SpawnPoint.Parse(str);
                        settings.AddSpawnPoint(sp);
                        break;
                    }
                }
            }

            xtr.Close();
            sr.Close();

            return(settings);
        }
        /// <summary>
        /// Deserialize settings
        /// </summary>
        /// <param name="serializedSettings"></param>
        /// <returns></returns>
        /// <exception cref="System.Xml.XmlException"></exception>
        public static RegionSettings Deserialize(string serializedSettings)
        {
            RegionSettings settings = new RegionSettings();
            
            StringReader sr = new StringReader(serializedSettings);
            XmlTextReader xtr = new XmlTextReader(sr);
            
            xtr.ReadStartElement("RegionSettings");
         
            xtr.ReadStartElement("General");
           
            while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
            {
                switch (xtr.Name)
                {
                    case "AllowDamage":
                        settings.AllowDamage = bool.Parse(xtr.ReadElementContentAsString());
                        break;
                    case "AllowLandResell":
                        settings.AllowLandResell = bool.Parse(xtr.ReadElementContentAsString());
                        break;
                    case "AllowLandJoinDivide":
                        settings.AllowLandJoinDivide = bool.Parse(xtr.ReadElementContentAsString());
                        break;
                    case "BlockFly":
                        settings.BlockFly = bool.Parse(xtr.ReadElementContentAsString());
                        break;
                    case "BlockLandShowInSearch":
                        settings.BlockShowInSearch = bool.Parse(xtr.ReadElementContentAsString());
                        break;
                    case "BlockTerraform":
                        settings.BlockTerraform = bool.Parse(xtr.ReadElementContentAsString());
                        break;
                    case "DisableCollisions":
                        settings.DisableCollisions = bool.Parse(xtr.ReadElementContentAsString());
                        break;
                    case "DisablePhysics":
                        settings.DisablePhysics = bool.Parse(xtr.ReadElementContentAsString());
                        break;
                    case "DisableScripts":
                        settings.DisableScripts = bool.Parse(xtr.ReadElementContentAsString());
                        break;
                    case "MaturityRating":
                        settings.Maturity = int.Parse(xtr.ReadElementContentAsString());
                        break;
                    case "RestrictPushing":
                        settings.RestrictPushing = bool.Parse(xtr.ReadElementContentAsString());
                        break;
                    case "AgentLimit":
                        settings.AgentLimit = int.Parse(xtr.ReadElementContentAsString());
                        break;
                    case "ObjectBonus":
                        settings.ObjectBonus = double.Parse(xtr.ReadElementContentAsString(), Culture.NumberFormatInfo);
                        break;
                }
            }
            
            xtr.ReadEndElement();
            xtr.ReadStartElement("GroundTextures");
            
            while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
            {
                switch (xtr.Name)
                {
                    case "Texture1":
                        settings.TerrainTexture1 = UUID.Parse(xtr.ReadElementContentAsString());
                        break;
                    case "Texture2":
                        settings.TerrainTexture2 = UUID.Parse(xtr.ReadElementContentAsString());
                        break;
                    case "Texture3":
                        settings.TerrainTexture3 = UUID.Parse(xtr.ReadElementContentAsString());
                        break;
                    case "Texture4":
                        settings.TerrainTexture4 = UUID.Parse(xtr.ReadElementContentAsString());
                        break;
                    case "ElevationLowSW":
                        settings.Elevation1SW = double.Parse(xtr.ReadElementContentAsString(), Culture.NumberFormatInfo);
                        break;
                    case "ElevationLowNW":
                        settings.Elevation1NW = double.Parse(xtr.ReadElementContentAsString(), Culture.NumberFormatInfo);
                        break;
                    case "ElevationLowSE":
                        settings.Elevation1SE = double.Parse(xtr.ReadElementContentAsString(), Culture.NumberFormatInfo);
                        break;
                    case "ElevationLowNE":
                        settings.Elevation1NE = double.Parse(xtr.ReadElementContentAsString(), Culture.NumberFormatInfo);
                        break;
                    case "ElevationHighSW":
                        settings.Elevation2SW = double.Parse(xtr.ReadElementContentAsString(), Culture.NumberFormatInfo);
                        break;
                    case "ElevationHighNW":
                        settings.Elevation2NW = double.Parse(xtr.ReadElementContentAsString(), Culture.NumberFormatInfo);
                        break;
                    case "ElevationHighSE":
                        settings.Elevation2SE = double.Parse(xtr.ReadElementContentAsString(), Culture.NumberFormatInfo);
                        break;
                    case "ElevationHighNE":
                        settings.Elevation2NE = double.Parse(xtr.ReadElementContentAsString(), Culture.NumberFormatInfo);
                        break;
                }
            }
           
            xtr.ReadEndElement();
            xtr.ReadStartElement("Terrain");
            
            while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
            {
                switch (xtr.Name)
                {
                    case "WaterHeight":
                        settings.WaterHeight = double.Parse(xtr.ReadElementContentAsString(), Culture.NumberFormatInfo);
                        break;
                    case "TerrainRaiseLimit":
                        settings.TerrainRaiseLimit = double.Parse(xtr.ReadElementContentAsString(), Culture.NumberFormatInfo);
                        break;
                    case "TerrainLowerLimit":
                        settings.TerrainLowerLimit = double.Parse(xtr.ReadElementContentAsString(), Culture.NumberFormatInfo);
                        break;
                    case "UseEstateSun":
                        settings.UseEstateSun = bool.Parse(xtr.ReadElementContentAsString());
                        break;
                    case "FixedSun":
                        settings.FixedSun = bool.Parse(xtr.ReadElementContentAsString());
                        break;
                    case "SunPosition":
                        settings.SunPosition = double.Parse(xtr.ReadElementContentAsString());
                        break;
                }
            }

            xtr.ReadEndElement();

            if (xtr.IsStartElement("Telehub"))
            {
                xtr.ReadStartElement("Telehub");

                while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
                {
                    switch (xtr.Name)
                    {
                        case "TelehubObject":
                            settings.TelehubObject = UUID.Parse(xtr.ReadElementContentAsString());
                            break;
                        case "SpawnPoint":
                            string str = xtr.ReadElementContentAsString();
                            SpawnPoint sp = SpawnPoint.Parse(str);
                            settings.AddSpawnPoint(sp);
                            break;
                    }
                }
            }

            xtr.Close();
            sr.Close();
            
            return settings;
        }