diff options
author | UbitUmarov | 2012-07-17 00:54:23 +0100 |
---|---|---|
committer | UbitUmarov | 2012-07-17 00:54:23 +0100 |
commit | d5f4fb7b50fb7c594b018f8241399e22f88fc951 (patch) | |
tree | 8f3dab3d170596f02b1d1d836a0bc08a3e6b8ebd /OpenSim/Framework/Serialization | |
parent | UbitOde: remove useless water collider from active code. (diff) | |
parent | Merge branch 'avination' into careminster (diff) | |
download | opensim-SC-d5f4fb7b50fb7c594b018f8241399e22f88fc951.zip opensim-SC-d5f4fb7b50fb7c594b018f8241399e22f88fc951.tar.gz opensim-SC-d5f4fb7b50fb7c594b018f8241399e22f88fc951.tar.bz2 opensim-SC-d5f4fb7b50fb7c594b018f8241399e22f88fc951.tar.xz |
Merge branch 'avination' into ubitwork
Diffstat (limited to '')
6 files changed, 62 insertions, 30 deletions
diff --git a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs index a12877a..a64f01c 100644 --- a/OpenSim/Framework/Serialization/External/LandDataSerializer.cs +++ b/OpenSim/Framework/Serialization/External/LandDataSerializer.cs | |||
@@ -42,9 +42,7 @@ namespace OpenSim.Framework.Serialization.External | |||
42 | /// </summary> | 42 | /// </summary> |
43 | public class LandDataSerializer | 43 | public class LandDataSerializer |
44 | { | 44 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | |||
47 | protected static UTF8Encoding m_utf8Encoding = new UTF8Encoding(); | ||
48 | 46 | ||
49 | private static Dictionary<string, Action<LandData, XmlTextReader>> m_ldProcessors | 47 | private static Dictionary<string, Action<LandData, XmlTextReader>> m_ldProcessors |
50 | = new Dictionary<string, Action<LandData, XmlTextReader>>(); | 48 | = new Dictionary<string, Action<LandData, XmlTextReader>>(); |
@@ -163,7 +161,7 @@ namespace OpenSim.Framework.Serialization.External | |||
163 | /// <exception cref="System.Xml.XmlException"></exception> | 161 | /// <exception cref="System.Xml.XmlException"></exception> |
164 | public static LandData Deserialize(byte[] serializedLandData) | 162 | public static LandData Deserialize(byte[] serializedLandData) |
165 | { | 163 | { |
166 | return Deserialize(m_utf8Encoding.GetString(serializedLandData, 0, serializedLandData.Length)); | 164 | return Deserialize(Encoding.UTF8.GetString(serializedLandData, 0, serializedLandData.Length)); |
167 | } | 165 | } |
168 | 166 | ||
169 | /// <summary> | 167 | /// <summary> |
diff --git a/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs b/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs index 931898c..19468c3 100644 --- a/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs +++ b/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs | |||
@@ -30,6 +30,8 @@ using System.Text; | |||
30 | using System.Xml; | 30 | using System.Xml; |
31 | using OpenMetaverse; | 31 | using OpenMetaverse; |
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using log4net; | ||
34 | using System.Reflection; | ||
33 | 35 | ||
34 | namespace OpenSim.Framework.Serialization.External | 36 | namespace OpenSim.Framework.Serialization.External |
35 | { | 37 | { |
@@ -38,8 +40,6 @@ namespace OpenSim.Framework.Serialization.External | |||
38 | /// </summary> | 40 | /// </summary> |
39 | public class RegionSettingsSerializer | 41 | public class RegionSettingsSerializer |
40 | { | 42 | { |
41 | protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding(); | ||
42 | |||
43 | /// <summary> | 43 | /// <summary> |
44 | /// Deserialize settings | 44 | /// Deserialize settings |
45 | /// </summary> | 45 | /// </summary> |
@@ -48,7 +48,7 @@ namespace OpenSim.Framework.Serialization.External | |||
48 | /// <exception cref="System.Xml.XmlException"></exception> | 48 | /// <exception cref="System.Xml.XmlException"></exception> |
49 | public static RegionSettings Deserialize(byte[] serializedSettings) | 49 | public static RegionSettings Deserialize(byte[] serializedSettings) |
50 | { | 50 | { |
51 | return Deserialize(m_asciiEncoding.GetString(serializedSettings, 0, serializedSettings.Length)); | 51 | return Deserialize(Encoding.ASCII.GetString(serializedSettings, 0, serializedSettings.Length)); |
52 | } | 52 | } |
53 | 53 | ||
54 | /// <summary> | 54 | /// <summary> |
@@ -187,7 +187,29 @@ namespace OpenSim.Framework.Serialization.External | |||
187 | break; | 187 | break; |
188 | } | 188 | } |
189 | } | 189 | } |
190 | 190 | ||
191 | xtr.ReadEndElement(); | ||
192 | |||
193 | if (xtr.IsStartElement("Telehub")) | ||
194 | { | ||
195 | xtr.ReadStartElement("Telehub"); | ||
196 | |||
197 | while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement) | ||
198 | { | ||
199 | switch (xtr.Name) | ||
200 | { | ||
201 | case "TelehubObject": | ||
202 | settings.TelehubObject = UUID.Parse(xtr.ReadElementContentAsString()); | ||
203 | break; | ||
204 | case "SpawnPoint": | ||
205 | string str = xtr.ReadElementContentAsString(); | ||
206 | SpawnPoint sp = SpawnPoint.Parse(str); | ||
207 | settings.AddSpawnPoint(sp); | ||
208 | break; | ||
209 | } | ||
210 | } | ||
211 | } | ||
212 | |||
191 | xtr.Close(); | 213 | xtr.Close(); |
192 | sr.Close(); | 214 | sr.Close(); |
193 | 215 | ||
@@ -243,7 +265,16 @@ namespace OpenSim.Framework.Serialization.External | |||
243 | xtw.WriteElementString("SunPosition", settings.SunPosition.ToString()); | 265 | xtw.WriteElementString("SunPosition", settings.SunPosition.ToString()); |
244 | // Note: 'SunVector' isn't saved because this value is owned by the Sun Module, which | 266 | // Note: 'SunVector' isn't saved because this value is owned by the Sun Module, which |
245 | // calculates it automatically according to the date and other factors. | 267 | // calculates it automatically according to the date and other factors. |
246 | xtw.WriteEndElement(); | 268 | xtw.WriteEndElement(); |
269 | |||
270 | xtw.WriteStartElement("Telehub"); | ||
271 | if (settings.TelehubObject != UUID.Zero) | ||
272 | { | ||
273 | xtw.WriteElementString("TelehubObject", settings.TelehubObject.ToString()); | ||
274 | foreach (SpawnPoint sp in settings.SpawnPoints()) | ||
275 | xtw.WriteElementString("SpawnPoint", sp.ToString()); | ||
276 | } | ||
277 | xtw.WriteEndElement(); | ||
247 | 278 | ||
248 | xtw.WriteEndElement(); | 279 | xtw.WriteEndElement(); |
249 | 280 | ||
diff --git a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs index 57da7ca..88f9581 100644 --- a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs +++ b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs | |||
@@ -44,7 +44,7 @@ namespace OpenSim.Framework.Serialization.External | |||
44 | /// </summary> | 44 | /// </summary> |
45 | public class UserInventoryItemSerializer | 45 | public class UserInventoryItemSerializer |
46 | { | 46 | { |
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
48 | 48 | ||
49 | private static Dictionary<string, Action<InventoryItemBase, XmlTextReader>> m_InventoryItemXmlProcessors | 49 | private static Dictionary<string, Action<InventoryItemBase, XmlTextReader>> m_InventoryItemXmlProcessors |
50 | = new Dictionary<string, Action<InventoryItemBase, XmlTextReader>>(); | 50 | = new Dictionary<string, Action<InventoryItemBase, XmlTextReader>>(); |
diff --git a/OpenSim/Framework/Serialization/TarArchiveReader.cs b/OpenSim/Framework/Serialization/TarArchiveReader.cs index 77c29f8..339a37a 100644 --- a/OpenSim/Framework/Serialization/TarArchiveReader.cs +++ b/OpenSim/Framework/Serialization/TarArchiveReader.cs | |||
@@ -53,8 +53,6 @@ namespace OpenSim.Framework.Serialization | |||
53 | TYPE_CONTIGUOUS_FILE = 8, | 53 | TYPE_CONTIGUOUS_FILE = 8, |
54 | } | 54 | } |
55 | 55 | ||
56 | protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding(); | ||
57 | |||
58 | /// <summary> | 56 | /// <summary> |
59 | /// Binary reader for the underlying stream | 57 | /// Binary reader for the underlying stream |
60 | /// </summary> | 58 | /// </summary> |
@@ -120,13 +118,13 @@ namespace OpenSim.Framework.Serialization | |||
120 | if (header[156] == (byte)'L') | 118 | if (header[156] == (byte)'L') |
121 | { | 119 | { |
122 | int longNameLength = ConvertOctalBytesToDecimal(header, 124, 11); | 120 | int longNameLength = ConvertOctalBytesToDecimal(header, 124, 11); |
123 | tarHeader.FilePath = m_asciiEncoding.GetString(ReadData(longNameLength)); | 121 | tarHeader.FilePath = Encoding.ASCII.GetString(ReadData(longNameLength)); |
124 | //m_log.DebugFormat("[TAR ARCHIVE READER]: Got long file name {0}", tarHeader.FilePath); | 122 | //m_log.DebugFormat("[TAR ARCHIVE READER]: Got long file name {0}", tarHeader.FilePath); |
125 | header = m_br.ReadBytes(512); | 123 | header = m_br.ReadBytes(512); |
126 | } | 124 | } |
127 | else | 125 | else |
128 | { | 126 | { |
129 | tarHeader.FilePath = m_asciiEncoding.GetString(header, 0, 100); | 127 | tarHeader.FilePath = Encoding.ASCII.GetString(header, 0, 100); |
130 | tarHeader.FilePath = tarHeader.FilePath.Trim(m_nullCharArray); | 128 | tarHeader.FilePath = tarHeader.FilePath.Trim(m_nullCharArray); |
131 | //m_log.DebugFormat("[TAR ARCHIVE READER]: Got short file name {0}", tarHeader.FilePath); | 129 | //m_log.DebugFormat("[TAR ARCHIVE READER]: Got short file name {0}", tarHeader.FilePath); |
132 | } | 130 | } |
@@ -205,7 +203,7 @@ namespace OpenSim.Framework.Serialization | |||
205 | { | 203 | { |
206 | // Trim leading white space: ancient tars do that instead | 204 | // Trim leading white space: ancient tars do that instead |
207 | // of leading 0s :-( don't ask. really. | 205 | // of leading 0s :-( don't ask. really. |
208 | string oString = m_asciiEncoding.GetString(bytes, startIndex, count).TrimStart(m_spaceCharArray); | 206 | string oString = Encoding.ASCII.GetString(bytes, startIndex, count).TrimStart(m_spaceCharArray); |
209 | 207 | ||
210 | int d = 0; | 208 | int d = 0; |
211 | 209 | ||
diff --git a/OpenSim/Framework/Serialization/TarArchiveWriter.cs b/OpenSim/Framework/Serialization/TarArchiveWriter.cs index fca909f..2a3bc48 100644 --- a/OpenSim/Framework/Serialization/TarArchiveWriter.cs +++ b/OpenSim/Framework/Serialization/TarArchiveWriter.cs | |||
@@ -41,9 +41,6 @@ namespace OpenSim.Framework.Serialization | |||
41 | { | 41 | { |
42 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 42 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
43 | 43 | ||
44 | protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding(); | ||
45 | protected static UTF8Encoding m_utf8Encoding = new UTF8Encoding(); | ||
46 | |||
47 | /// <summary> | 44 | /// <summary> |
48 | /// Binary writer for the underlying stream | 45 | /// Binary writer for the underlying stream |
49 | /// </summary> | 46 | /// </summary> |
@@ -74,7 +71,7 @@ namespace OpenSim.Framework.Serialization | |||
74 | /// <param name="data"></param> | 71 | /// <param name="data"></param> |
75 | public void WriteFile(string filePath, string data) | 72 | public void WriteFile(string filePath, string data) |
76 | { | 73 | { |
77 | WriteFile(filePath, m_utf8Encoding.GetBytes(data)); | 74 | WriteFile(filePath, Util.UTF8NoBomEncoding.GetBytes(data)); |
78 | } | 75 | } |
79 | 76 | ||
80 | /// <summary> | 77 | /// <summary> |
@@ -85,7 +82,7 @@ namespace OpenSim.Framework.Serialization | |||
85 | public void WriteFile(string filePath, byte[] data) | 82 | public void WriteFile(string filePath, byte[] data) |
86 | { | 83 | { |
87 | if (filePath.Length > 100) | 84 | if (filePath.Length > 100) |
88 | WriteEntry("././@LongLink", m_asciiEncoding.GetBytes(filePath), 'L'); | 85 | WriteEntry("././@LongLink", Encoding.ASCII.GetBytes(filePath), 'L'); |
89 | 86 | ||
90 | char fileType; | 87 | char fileType; |
91 | 88 | ||
@@ -137,7 +134,7 @@ namespace OpenSim.Framework.Serialization | |||
137 | oString = "0" + oString; | 134 | oString = "0" + oString; |
138 | } | 135 | } |
139 | 136 | ||
140 | byte[] oBytes = m_asciiEncoding.GetBytes(oString); | 137 | byte[] oBytes = Encoding.ASCII.GetBytes(oString); |
141 | 138 | ||
142 | return oBytes; | 139 | return oBytes; |
143 | } | 140 | } |
@@ -156,20 +153,20 @@ namespace OpenSim.Framework.Serialization | |||
156 | byte[] header = new byte[512]; | 153 | byte[] header = new byte[512]; |
157 | 154 | ||
158 | // file path field (100) | 155 | // file path field (100) |
159 | byte[] nameBytes = m_asciiEncoding.GetBytes(filePath); | 156 | byte[] nameBytes = Encoding.ASCII.GetBytes(filePath); |
160 | int nameSize = (nameBytes.Length >= 100) ? 100 : nameBytes.Length; | 157 | int nameSize = (nameBytes.Length >= 100) ? 100 : nameBytes.Length; |
161 | Array.Copy(nameBytes, header, nameSize); | 158 | Array.Copy(nameBytes, header, nameSize); |
162 | 159 | ||
163 | // file mode (8) | 160 | // file mode (8) |
164 | byte[] modeBytes = m_asciiEncoding.GetBytes("0000777"); | 161 | byte[] modeBytes = Encoding.ASCII.GetBytes("0000777"); |
165 | Array.Copy(modeBytes, 0, header, 100, 7); | 162 | Array.Copy(modeBytes, 0, header, 100, 7); |
166 | 163 | ||
167 | // owner user id (8) | 164 | // owner user id (8) |
168 | byte[] ownerIdBytes = m_asciiEncoding.GetBytes("0000764"); | 165 | byte[] ownerIdBytes = Encoding.ASCII.GetBytes("0000764"); |
169 | Array.Copy(ownerIdBytes, 0, header, 108, 7); | 166 | Array.Copy(ownerIdBytes, 0, header, 108, 7); |
170 | 167 | ||
171 | // group user id (8) | 168 | // group user id (8) |
172 | byte[] groupIdBytes = m_asciiEncoding.GetBytes("0000764"); | 169 | byte[] groupIdBytes = Encoding.ASCII.GetBytes("0000764"); |
173 | Array.Copy(groupIdBytes, 0, header, 116, 7); | 170 | Array.Copy(groupIdBytes, 0, header, 116, 7); |
174 | 171 | ||
175 | // file size in bytes (12) | 172 | // file size in bytes (12) |
@@ -181,17 +178,17 @@ namespace OpenSim.Framework.Serialization | |||
181 | Array.Copy(fileSizeBytes, 0, header, 124, 11); | 178 | Array.Copy(fileSizeBytes, 0, header, 124, 11); |
182 | 179 | ||
183 | // last modification time (12) | 180 | // last modification time (12) |
184 | byte[] lastModTimeBytes = m_asciiEncoding.GetBytes("11017037332"); | 181 | byte[] lastModTimeBytes = Encoding.ASCII.GetBytes("11017037332"); |
185 | Array.Copy(lastModTimeBytes, 0, header, 136, 11); | 182 | Array.Copy(lastModTimeBytes, 0, header, 136, 11); |
186 | 183 | ||
187 | // entry type indicator (1) | 184 | // entry type indicator (1) |
188 | header[156] = m_asciiEncoding.GetBytes(new char[] { fileType })[0]; | 185 | header[156] = Encoding.ASCII.GetBytes(new char[] { fileType })[0]; |
189 | 186 | ||
190 | Array.Copy(m_asciiEncoding.GetBytes("0000000"), 0, header, 329, 7); | 187 | Array.Copy(Encoding.ASCII.GetBytes("0000000"), 0, header, 329, 7); |
191 | Array.Copy(m_asciiEncoding.GetBytes("0000000"), 0, header, 337, 7); | 188 | Array.Copy(Encoding.ASCII.GetBytes("0000000"), 0, header, 337, 7); |
192 | 189 | ||
193 | // check sum for header block (8) [calculated last] | 190 | // check sum for header block (8) [calculated last] |
194 | Array.Copy(m_asciiEncoding.GetBytes(" "), 0, header, 148, 8); | 191 | Array.Copy(Encoding.ASCII.GetBytes(" "), 0, header, 148, 8); |
195 | 192 | ||
196 | int checksum = 0; | 193 | int checksum = 0; |
197 | foreach (byte b in header) | 194 | foreach (byte b in header) |
diff --git a/OpenSim/Framework/Serialization/Tests/RegionSettingsSerializerTests.cs b/OpenSim/Framework/Serialization/Tests/RegionSettingsSerializerTests.cs index a61e4af..09b6f6d 100644 --- a/OpenSim/Framework/Serialization/Tests/RegionSettingsSerializerTests.cs +++ b/OpenSim/Framework/Serialization/Tests/RegionSettingsSerializerTests.cs | |||
@@ -78,6 +78,10 @@ namespace OpenSim.Framework.Serialization.Tests | |||
78 | <FixedSun>true</FixedSun> | 78 | <FixedSun>true</FixedSun> |
79 | <SunPosition>12</SunPosition> | 79 | <SunPosition>12</SunPosition> |
80 | </Terrain> | 80 | </Terrain> |
81 | <Telehub> | ||
82 | <TelehubObject>00000000-0000-0000-0000-111111111111</TelehubObject> | ||
83 | <SpawnPoint>1,-2,0.33</SpawnPoint> | ||
84 | </Telehub> | ||
81 | </RegionSettings>"; | 85 | </RegionSettings>"; |
82 | 86 | ||
83 | private RegionSettings m_rs; | 87 | private RegionSettings m_rs; |
@@ -116,6 +120,8 @@ namespace OpenSim.Framework.Serialization.Tests | |||
116 | m_rs.TerrainTexture4 = UUID.Parse("00000000-0000-0000-0000-000000000080"); | 120 | m_rs.TerrainTexture4 = UUID.Parse("00000000-0000-0000-0000-000000000080"); |
117 | m_rs.UseEstateSun = true; | 121 | m_rs.UseEstateSun = true; |
118 | m_rs.WaterHeight = 23; | 122 | m_rs.WaterHeight = 23; |
123 | m_rs.TelehubObject = UUID.Parse("00000000-0000-0000-0000-111111111111"); | ||
124 | m_rs.AddSpawnPoint(SpawnPoint.Parse("1,-2,0.33")); | ||
119 | } | 125 | } |
120 | 126 | ||
121 | [Test] | 127 | [Test] |
@@ -129,6 +135,8 @@ namespace OpenSim.Framework.Serialization.Tests | |||
129 | Assert.That(deserRs.TerrainTexture2, Is.EqualTo(m_rs.TerrainTexture2)); | 135 | Assert.That(deserRs.TerrainTexture2, Is.EqualTo(m_rs.TerrainTexture2)); |
130 | Assert.That(deserRs.DisablePhysics, Is.EqualTo(m_rs.DisablePhysics)); | 136 | Assert.That(deserRs.DisablePhysics, Is.EqualTo(m_rs.DisablePhysics)); |
131 | Assert.That(deserRs.TerrainLowerLimit, Is.EqualTo(m_rs.TerrainLowerLimit)); | 137 | Assert.That(deserRs.TerrainLowerLimit, Is.EqualTo(m_rs.TerrainLowerLimit)); |
138 | Assert.That(deserRs.TelehubObject, Is.EqualTo(m_rs.TelehubObject)); | ||
139 | Assert.That(deserRs.SpawnPoints()[0].ToString(), Is.EqualTo(m_rs.SpawnPoints()[0].ToString())); | ||
132 | } | 140 | } |
133 | } | 141 | } |
134 | } | 142 | } |