SOP to xml: don't waste space with some unset optional parameters.

master
UbitUmarov 2020-05-26 12:48:08 +01:00
parent d460a3fc86
commit 0a48da85a3
1 changed files with 16 additions and 15 deletions

View File

@ -87,10 +87,11 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
if(data[len -1 ] == 0) if(data[len -1 ] == 0)
--len; --len;
MemoryStream ms = new MemoryStream(data,0, len, false); XmlReaderSettings xset = new XmlReaderSettings() { IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment, CloseInput = true };
using(StreamReader sr = new StreamReader(ms, Encoding.UTF8)) XmlParserContext xpc = new XmlParserContext(null, null, null, XmlSpace.None);
{ xpc.Encoding = Util.UTF8NoBomEncoding;
using (XmlReader reader = XmlReader.Create(ms, new XmlReaderSettings() { IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment })) MemoryStream ms = new MemoryStream(data, 0, len, false);
using (XmlReader reader = XmlReader.Create(ms, xset, xpc))
{ {
try try
{ {
@ -103,7 +104,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
} }
} }
} }
}
/// <summary> /// <summary>
/// Deserialize a scene object from the original xml format /// Deserialize a scene object from the original xml format
@ -1572,6 +1572,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
WriteVector(writer, "SitTargetPosition", sop.SitTargetPosition); WriteVector(writer, "SitTargetPosition", sop.SitTargetPosition);
WriteVector(writer, "SitTargetPositionLL", sop.SitTargetPositionLL); WriteVector(writer, "SitTargetPositionLL", sop.SitTargetPositionLL);
WriteQuaternion(writer, "SitTargetOrientationLL", sop.SitTargetOrientationLL); WriteQuaternion(writer, "SitTargetOrientationLL", sop.SitTargetOrientationLL);
if(sop.StandOffset != Vector3.Zero);
WriteVector(writer, "StandTarget", sop.StandOffset); WriteVector(writer, "StandTarget", sop.StandOffset);
writer.WriteElementString("ParentID", sop.ParentID.ToString()); writer.WriteElementString("ParentID", sop.ParentID.ToString());
writer.WriteElementString("CreationDate", sop.CreationDate.ToString()); writer.WriteElementString("CreationDate", sop.CreationDate.ToString());
@ -1661,7 +1662,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
if(data != null && data.Length > 0) if(data != null && data.Length > 0)
writer.WriteElementString("SOPAnims", Convert.ToBase64String(data)); writer.WriteElementString("SOPAnims", Convert.ToBase64String(data));
} }
if(Math.Abs(sop.SitActiveRange) > 1e-5)
writer.WriteElementString("SitActRange", sop.SitActiveRange.ToString(Culture.FormatProvider)); writer.WriteElementString("SitActRange", sop.SitActiveRange.ToString(Culture.FormatProvider));
writer.WriteEndElement(); writer.WriteEndElement();
} }