public static void ProcessParcelEnvironment(LandData ld, XmlReader xtr)
        {
            string senv = xtr.ReadElementString("Environment");

            ld.Environment        = ViewerEnvironment.FromOSDString(senv);
            ld.EnvironmentVersion = ld.Environment.version;
        }
        /// <summary>
        /// Deserialize settings
        /// </summary>
        /// <param name="serializedSettings"></param>
        /// <returns></returns>
        /// <exception cref="System.Xml.XmlException"></exception>
        public static RegionSettings Deserialize(string serializedSettings, out ViewerEnvironment regionEnv)
        {
            RegionSettings settings = new RegionSettings();

            regionEnv = null;

            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"))
            {
                if (xtr.IsEmptyElement)
                {
                    xtr.Read();
                }
                else
                {
                    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.ReadEndElement();
                }
            }

            if (xtr.IsStartElement("Environment"))
            {
                if (xtr.IsEmptyElement)
                {
                    xtr.Read();
                }
                else
                {
                    xtr.ReadStartElement("Environment");
                    while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
                    {
                        switch (xtr.Name)
                        {
                        case "data":
                            regionEnv = ViewerEnvironment.FromOSDString(xtr.ReadElementContentAsString());
                            break;
                        }
                    }
                    xtr.ReadEndElement();
                }
            }

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

            return(settings);
        }