aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-03-27 18:13:34 +0000
committerJustin Clarke Casey2009-03-27 18:13:34 +0000
commit561f24156476041bdcd2ef2fdccd296a4127d0b0 (patch)
treed06fa3bbff0f6755ff022d4d761ec1acda25b48c /OpenSim/Region
parent* Also temporarily disable T032_CrossAttachments() since this relies on the e... (diff)
downloadopensim-SC-561f24156476041bdcd2ef2fdccd296a4127d0b0.zip
opensim-SC-561f24156476041bdcd2ef2fdccd296a4127d0b0.tar.gz
opensim-SC-561f24156476041bdcd2ef2fdccd296a4127d0b0.tar.bz2
opensim-SC-561f24156476041bdcd2ef2fdccd296a4127d0b0.tar.xz
* minor: move RegionSettingsSerializer into OpenSim.Framework.Serialization
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs1
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs1
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/RegionSettingsSerializer.cs257
3 files changed, 2 insertions, 257 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index 8b603b4..3f6e822 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -36,6 +36,7 @@ using log4net;
36using OpenMetaverse; 36using OpenMetaverse;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Serialization; 38using OpenSim.Framework.Serialization;
39using OpenSim.Framework.Serialization.External;
39using OpenSim.Framework.Communications.Cache; 40using OpenSim.Framework.Communications.Cache;
40using OpenSim.Region.CoreModules.World.Terrain; 41using OpenSim.Region.CoreModules.World.Terrain;
41using OpenSim.Region.Framework.Interfaces; 42using OpenSim.Region.Framework.Interfaces;
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs
index db74564..85391b3 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs
@@ -34,6 +34,7 @@ using log4net;
34using OpenMetaverse; 34using OpenMetaverse;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Framework.Serialization; 36using OpenSim.Framework.Serialization;
37using OpenSim.Framework.Serialization.External;
37using OpenSim.Region.CoreModules.World.Terrain; 38using OpenSim.Region.CoreModules.World.Terrain;
38using OpenSim.Region.Framework.Interfaces; 39using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
diff --git a/OpenSim/Region/CoreModules/World/Archiver/RegionSettingsSerializer.cs b/OpenSim/Region/CoreModules/World/Archiver/RegionSettingsSerializer.cs
deleted file mode 100644
index 799dcb9..0000000
--- a/OpenSim/Region/CoreModules/World/Archiver/RegionSettingsSerializer.cs
+++ /dev/null
@@ -1,257 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.IO;
29using System.Text;
30using System.Xml;
31using OpenMetaverse;
32using OpenSim.Framework;
33
34namespace OpenSim.Region.CoreModules.World.Archiver
35{
36 /// <summary>
37 /// Serialize and deserialize region settings for an archive file format.
38 /// </summary>
39 /// We didn't simply use automatic .NET serializagion for OpenSim.Framework.RegionSettings since this is really
40 /// a file format rather than an object serialization.
41 /// TODO: However, we could still have used separate non-framework classes here to read and write the xml
42 /// automatically rather than laboriously doing it by hand using XmlTextReader and Writer. Should switch to this
43 /// in the future.
44 public class RegionSettingsSerializer
45 {
46 protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
47
48 /// <summary>
49 /// Deserialize region settings
50 /// </summary>
51 /// <param name="serializedSettings"></param>
52 /// <returns></returns>
53 /// <exception cref="System.Xml.XmlException"></exception>
54 public static RegionSettings Deserialize(byte[] serializedSettings)
55 {
56 return Deserialize(m_asciiEncoding.GetString(serializedSettings, 0, serializedSettings.Length));
57 }
58
59 /// <summary>
60 /// Deserialize region settings
61 /// </summary>
62 /// <param name="serializedSettings"></param>
63 /// <returns></returns>
64 /// <exception cref="System.Xml.XmlException"></exception>
65 public static RegionSettings Deserialize(string serializedSettings)
66 {
67 RegionSettings settings = new RegionSettings();
68
69 StringReader sr = new StringReader(serializedSettings);
70 XmlTextReader xtr = new XmlTextReader(sr);
71
72 xtr.ReadStartElement("RegionSettings");
73
74 xtr.ReadStartElement("General");
75
76 while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
77 {
78 switch (xtr.Name)
79 {
80 case "AllowDamage":
81 settings.AllowDamage = bool.Parse(xtr.ReadElementContentAsString());
82 break;
83 case "AllowLandResell":
84 settings.AllowLandResell = bool.Parse(xtr.ReadElementContentAsString());
85 break;
86 case "AllowLandJoinDivide":
87 settings.AllowLandJoinDivide = bool.Parse(xtr.ReadElementContentAsString());
88 break;
89 case "BlockFly":
90 settings.BlockFly = bool.Parse(xtr.ReadElementContentAsString());
91 break;
92 case "BlockLandShowInSearch":
93 settings.BlockShowInSearch = bool.Parse(xtr.ReadElementContentAsString());
94 break;
95 case "BlockTerraform":
96 settings.BlockTerraform = bool.Parse(xtr.ReadElementContentAsString());
97 break;
98 case "DisableCollisions":
99 settings.DisableCollisions = bool.Parse(xtr.ReadElementContentAsString());
100 break;
101 case "DisablePhysics":
102 settings.DisablePhysics = bool.Parse(xtr.ReadElementContentAsString());
103 break;
104 case "DisableScripts":
105 settings.DisableScripts = bool.Parse(xtr.ReadElementContentAsString());
106 break;
107 case "MaturityRating":
108 settings.Maturity = int.Parse(xtr.ReadElementContentAsString());
109 break;
110 case "RestrictPushing":
111 settings.RestrictPushing = bool.Parse(xtr.ReadElementContentAsString());
112 break;
113 case "AgentLimit":
114 settings.AgentLimit = int.Parse(xtr.ReadElementContentAsString());
115 break;
116 case "ObjectBonus":
117 settings.ObjectBonus = double.Parse(xtr.ReadElementContentAsString());
118 break;
119 }
120 }
121
122 xtr.ReadEndElement();
123 xtr.ReadStartElement("GroundTextures");
124
125 while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
126 {
127 switch (xtr.Name)
128 {
129 case "Texture1":
130 settings.TerrainTexture1 = UUID.Parse(xtr.ReadElementContentAsString());
131 break;
132 case "Texture2":
133 settings.TerrainTexture2 = UUID.Parse(xtr.ReadElementContentAsString());
134 break;
135 case "Texture3":
136 settings.TerrainTexture3 = UUID.Parse(xtr.ReadElementContentAsString());
137 break;
138 case "Texture4":
139 settings.TerrainTexture4 = UUID.Parse(xtr.ReadElementContentAsString());
140 break;
141 case "ElevationLowSW":
142 settings.Elevation1SW = double.Parse(xtr.ReadElementContentAsString());
143 break;
144 case "ElevationLowNW":
145 settings.Elevation1NW = double.Parse(xtr.ReadElementContentAsString());
146 break;
147 case "ElevationLowSE":
148 settings.Elevation1SE = double.Parse(xtr.ReadElementContentAsString());
149 break;
150 case "ElevationLowNE":
151 settings.Elevation1NE = double.Parse(xtr.ReadElementContentAsString());
152 break;
153 case "ElevationHighSW":
154 settings.Elevation2SW = double.Parse(xtr.ReadElementContentAsString());
155 break;
156 case "ElevationHighNW":
157 settings.Elevation2NW = double.Parse(xtr.ReadElementContentAsString());
158 break;
159 case "ElevationHighSE":
160 settings.Elevation2SE = double.Parse(xtr.ReadElementContentAsString());
161 break;
162 case "ElevationHighNE":
163 settings.Elevation2NE = double.Parse(xtr.ReadElementContentAsString());
164 break;
165 }
166 }
167
168 xtr.ReadEndElement();
169 xtr.ReadStartElement("Terrain");
170
171 while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
172 {
173 switch (xtr.Name)
174 {
175 case "WaterHeight":
176 settings.WaterHeight = double.Parse(xtr.ReadElementContentAsString());
177 break;
178 case "TerrainRaiseLimit":
179 settings.TerrainRaiseLimit = double.Parse(xtr.ReadElementContentAsString());
180 break;
181 case "TerrainLowerLimit":
182 settings.TerrainLowerLimit = double.Parse(xtr.ReadElementContentAsString());
183 break;
184 case "UseEstateSun":
185 settings.UseEstateSun = bool.Parse(xtr.ReadElementContentAsString());
186 break;
187 case "FixedSun":
188 settings.FixedSun = bool.Parse(xtr.ReadElementContentAsString());
189 break;
190 }
191 }
192
193 xtr.Close();
194 sr.Close();
195
196 return settings;
197 }
198
199 public static string Serialize(RegionSettings settings)
200 {
201 StringWriter sw = new StringWriter();
202 XmlTextWriter xtw = new XmlTextWriter(sw);
203 xtw.Formatting = Formatting.Indented;
204 xtw.WriteStartDocument();
205
206 xtw.WriteStartElement("RegionSettings");
207
208 xtw.WriteStartElement("General");
209 xtw.WriteElementString("AllowDamage", settings.AllowDamage.ToString());
210 xtw.WriteElementString("AllowLandResell", settings.AllowLandResell.ToString());
211 xtw.WriteElementString("AllowLandJoinDivide", settings.AllowLandJoinDivide.ToString());
212 xtw.WriteElementString("BlockFly", settings.BlockFly.ToString());
213 xtw.WriteElementString("BlockLandShowInSearch", settings.BlockShowInSearch.ToString());
214 xtw.WriteElementString("BlockTerraform", settings.BlockTerraform.ToString());
215 xtw.WriteElementString("DisableCollisions", settings.DisableCollisions.ToString());
216 xtw.WriteElementString("DisablePhysics", settings.DisablePhysics.ToString());
217 xtw.WriteElementString("DisableScripts", settings.DisableScripts.ToString());
218 xtw.WriteElementString("MaturityRating", settings.Maturity.ToString());
219 xtw.WriteElementString("RestrictPushing", settings.RestrictPushing.ToString());
220 xtw.WriteElementString("AgentLimit", settings.AgentLimit.ToString());
221 xtw.WriteElementString("ObjectBonus", settings.ObjectBonus.ToString());
222 xtw.WriteEndElement();
223
224 xtw.WriteStartElement("GroundTextures");
225 xtw.WriteElementString("Texture1", settings.TerrainTexture1.ToString());
226 xtw.WriteElementString("Texture2", settings.TerrainTexture2.ToString());
227 xtw.WriteElementString("Texture3", settings.TerrainTexture3.ToString());
228 xtw.WriteElementString("Texture4", settings.TerrainTexture4.ToString());
229 xtw.WriteElementString("ElevationLowSW", settings.Elevation1SW.ToString());
230 xtw.WriteElementString("ElevationLowNW", settings.Elevation1NW.ToString());
231 xtw.WriteElementString("ElevationLowSE", settings.Elevation1SE.ToString());
232 xtw.WriteElementString("ElevationLowNE", settings.Elevation1NE.ToString());
233 xtw.WriteElementString("ElevationHighSW", settings.Elevation2SW.ToString());
234 xtw.WriteElementString("ElevationHighNW", settings.Elevation2NW.ToString());
235 xtw.WriteElementString("ElevationHighSE", settings.Elevation2SE.ToString());
236 xtw.WriteElementString("ElevationHighNE", settings.Elevation2NE.ToString());
237 xtw.WriteEndElement();
238
239 xtw.WriteStartElement("Terrain");
240 xtw.WriteElementString("WaterHeight", settings.WaterHeight.ToString());
241 xtw.WriteElementString("TerrainRaiseLimit", settings.TerrainRaiseLimit.ToString());
242 xtw.WriteElementString("TerrainLowerLimit", settings.TerrainLowerLimit.ToString());
243 xtw.WriteElementString("UseEstateSun", settings.UseEstateSun.ToString());
244 xtw.WriteElementString("FixedSun", settings.FixedSun.ToString());
245 // XXX: Need to expose interface to get sun phase information from sun module
246 // xtw.WriteStartElement("SunPhase",
247 xtw.WriteEndElement();
248
249 xtw.WriteEndElement();
250
251 xtw.Close();
252 sw.Close();
253
254 return sw.ToString();
255 }
256 }
257}