diff --git a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs index bac78270a7..f10e848f68 100644 --- a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs +++ b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs @@ -303,15 +303,19 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests { case "UUID": xtr.ReadStartElement("UUID"); - uuid = UUID.Parse(xtr.ReadElementString("Guid")); - xtr.ReadEndElement(); + try + { + uuid = UUID.Parse(xtr.ReadElementString("UUID")); + xtr.ReadEndElement(); + } + catch { } // ignore everything but ... break; case "Name": name = xtr.ReadElementContentAsString(); break; case "CreatorID": xtr.ReadStartElement("CreatorID"); - creatorId = UUID.Parse(xtr.ReadElementString("Guid")); + creatorId = UUID.Parse(xtr.ReadElementString("UUID")); xtr.ReadEndElement(); break; } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 39b109ba38..7a6449decf 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -39,6 +39,7 @@ using OpenMetaverse.Packets; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes.Scripting; +using OpenSim.Region.Framework.Scenes.Serialization; using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Framework.Scenes @@ -118,40 +119,36 @@ namespace OpenSim.Region.Framework.Scenes /// /// Is this sop a root part? /// - [XmlIgnore] + public bool IsRoot { get { return ParentGroup.RootPart == this; } } - // use only one serializer to give the runtime a chance to optimize it (it won't do that if you - // use a new instance every time) - private static XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart)); - #region Fields public bool AllowedDrop; - [XmlIgnore] + public bool DIE_AT_EDGE; - [XmlIgnore] + public bool RETURN_AT_EDGE; - [XmlIgnore] + public bool BlockGrab; - [XmlIgnore] + public bool StatusSandbox; - [XmlIgnore] + public Vector3 StatusSandboxPos; // TODO: This needs to be persisted in next XML version update! - [XmlIgnore] + public readonly int[] PayPrice = {-2,-2,-2,-2,-2}; - [XmlIgnore] + public PhysicsActor PhysActor { get { return m_physActor; } @@ -166,43 +163,43 @@ namespace OpenSim.Region.Framework.Scenes // Note: This isn't persisted in the database right now, as the fields for that aren't just there yet. // Not a big problem as long as the script that sets it remains in the prim on startup. // for SL compatibility it should be persisted though (set sound / displaytext / particlesystem, kill script) - [XmlIgnore] + public UUID Sound; - [XmlIgnore] + public byte SoundFlags; - [XmlIgnore] + public double SoundGain; - [XmlIgnore] + public double SoundRadius; - [XmlIgnore] + public uint TimeStampFull; - [XmlIgnore] + public uint TimeStampLastActivity; // Will be used for AutoReturn - [XmlIgnore] + public uint TimeStampTerse; - [XmlIgnore] + public UUID FromItemID; - [XmlIgnore] + public UUID FromFolderID; - [XmlIgnore] + public int STATUS_ROTATE_X; - [XmlIgnore] + public int STATUS_ROTATE_Y; - [XmlIgnore] + public int STATUS_ROTATE_Z; - [XmlIgnore] + private Dictionary m_CollisionFilter = new Dictionary(); /// @@ -211,68 +208,68 @@ namespace OpenSim.Region.Framework.Scenes /// private UUID m_fromUserInventoryItemID; - [XmlIgnore] + public UUID FromUserInventoryItemID { get { return m_fromUserInventoryItemID; } } - [XmlIgnore] + public bool IsAttachment; - [XmlIgnore] + public scriptEvents AggregateScriptEvents; - [XmlIgnore] + public UUID AttachedAvatar; - [XmlIgnore] + public Vector3 AttachedPos; - [XmlIgnore] + public uint AttachmentPoint; - [XmlIgnore] + public Vector3 RotationAxis = Vector3.One; - [XmlIgnore] + public bool VolumeDetectActive; // XmlIgnore set to avoid problems with persistance until I come to care for this // Certainly this must be a persistant setting finally - [XmlIgnore] + public bool IsWaitingForFirstSpinUpdatePacket; - [XmlIgnore] + public Quaternion SpinOldOrientation = Quaternion.Identity; - [XmlIgnore] + public Quaternion m_APIDTarget = Quaternion.Identity; - [XmlIgnore] + public float m_APIDDamp = 0; - [XmlIgnore] + public float m_APIDStrength = 0; /// /// This part's inventory /// - [XmlIgnore] + public IEntityInventory Inventory { get { return m_inventory; } } protected SceneObjectPartInventory m_inventory; - [XmlIgnore] + public bool Undoing; - [XmlIgnore] + public bool IgnoreUndoUpdate = false; - [XmlIgnore] + private PrimFlags LocalFlags; - [XmlIgnore] + private float m_damage = -1.0f; private byte[] m_TextureAnimation; private byte m_clickAction; @@ -280,9 +277,9 @@ namespace OpenSim.Region.Framework.Scenes private string m_description = String.Empty; private readonly List m_lastColliders = new List(); private int m_linkNum; - [XmlIgnore] + private int m_scriptAccessPin; - [XmlIgnore] + private readonly Dictionary m_scriptEvents = new Dictionary(); private string m_sitName = String.Empty; private Quaternion m_sitTargetOrientation = Quaternion.Identity; @@ -548,7 +545,7 @@ namespace OpenSim.Region.Framework.Scenes } - [XmlIgnore] + public Dictionary CollisionFilter { get { return m_CollisionFilter; } @@ -558,21 +555,21 @@ namespace OpenSim.Region.Framework.Scenes } } - [XmlIgnore] + public Quaternion APIDTarget { get { return m_APIDTarget; } set { m_APIDTarget = value; } } - [XmlIgnore] + public float APIDDamp { get { return m_APIDDamp; } set { m_APIDDamp = value; } } - [XmlIgnore] + public float APIDStrength { get { return m_APIDStrength; } @@ -618,35 +615,35 @@ namespace OpenSim.Region.Framework.Scenes set { m_LoopSoundSlavePrims = value; } } - [XmlIgnore] + public Byte[] TextureAnimation { get { return m_TextureAnimation; } set { m_TextureAnimation = value; } } - [XmlIgnore] + public Byte[] ParticleSystem { get { return m_particleSystem; } set { m_particleSystem = value; } } - [XmlIgnore] + public DateTime Expires { get { return m_expires; } set { m_expires = value; } } - [XmlIgnore] + public DateTime Rezzed { get { return m_rezzed; } set { m_rezzed = value; } } - [XmlIgnore] + public float Damage { get { return m_damage; } @@ -1019,7 +1016,7 @@ namespace OpenSim.Region.Framework.Scenes } } - [XmlIgnore] + public bool CreateSelected { get { return m_createSelected; } @@ -1201,14 +1198,14 @@ namespace OpenSim.Region.Framework.Scenes } } - [XmlIgnore] + public UUID SitTargetAvatar { get { return m_sitTargetAvatar; } set { m_sitTargetAvatar = value; } } - [XmlIgnore] + public virtual UUID RegionID { get @@ -1222,7 +1219,7 @@ namespace OpenSim.Region.Framework.Scenes } private UUID _parentUUID = UUID.Zero; - [XmlIgnore] + public UUID ParentUUID { get @@ -1236,7 +1233,7 @@ namespace OpenSim.Region.Framework.Scenes set { _parentUUID = value; } } - [XmlIgnore] + public string SitAnimation { get { return m_sitAnimation; } @@ -1850,7 +1847,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - public static SceneObjectPart FromXml(XmlReader xmlReader) + public static SceneObjectPart FromXml(XmlTextReader xmlReader) { return FromXml(UUID.Zero, xmlReader); } @@ -1861,9 +1858,9 @@ namespace OpenSim.Region.Framework.Scenes /// The inventory id from which this part came, if applicable /// /// - public static SceneObjectPart FromXml(UUID fromUserInventoryItemId, XmlReader xmlReader) + public static SceneObjectPart FromXml(UUID fromUserInventoryItemId, XmlTextReader xmlReader) { - SceneObjectPart part = (SceneObjectPart)serializer.Deserialize(xmlReader); + SceneObjectPart part = SceneObjectSerializer.Xml2ToSOP(xmlReader); part.m_fromUserInventoryItemID = fromUserInventoryItemId; // for tempOnRez objects, we have to fix the Expire date. @@ -4058,9 +4055,9 @@ namespace OpenSim.Region.Framework.Scenes /// Serialize this part to xml. /// /// - public void ToXml(XmlWriter xmlWriter) + public void ToXml(XmlTextWriter xmlWriter) { - serializer.Serialize(xmlWriter, this); + SceneObjectSerializer.SOPToXml2(xmlWriter, this, new Dictionary()); } public void TriggerScriptChangedEvent(Changed val) diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 9a00beaff5..252304b876 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -67,14 +67,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); //int time = System.Environment.TickCount; - // libomv.types changes UUID to Guid - xmlData = xmlData.Replace("", ""); - xmlData = xmlData.Replace("", ""); - - // Handle Nested property - xmlData = xmlData.Replace("", ""); - xmlData = xmlData.Replace("", ""); - try { StringReader sr; @@ -126,6 +118,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization } } + /// /// Serialize a scene object to the original xml format /// @@ -156,7 +149,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); writer.WriteStartElement(String.Empty, "RootPart", String.Empty); - ToOriginalXmlFormat(sceneObject.RootPart, writer); + ToXmlFormat(sceneObject.RootPart, writer); writer.WriteEndElement(); writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); @@ -167,7 +160,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization if (part.UUID != sceneObject.RootPart.UUID) { writer.WriteStartElement(String.Empty, "Part", String.Empty); - ToOriginalXmlFormat(part, writer); + ToXmlFormat(part, writer); writer.WriteEndElement(); } } @@ -179,9 +172,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); } - protected static void ToOriginalXmlFormat(SceneObjectPart part, XmlTextWriter writer) + protected static void ToXmlFormat(SceneObjectPart part, XmlTextWriter writer) { - part.ToXml(writer); + SOPToXml2(writer, part, new Dictionary()); } public static SceneObjectGroup FromXml2Format(string xmlData) @@ -189,14 +182,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); //int time = System.Environment.TickCount; - // libomv.types changes UUID to Guid - xmlData = xmlData.Replace("", ""); - xmlData = xmlData.Replace("", ""); - - // Handle Nested property - xmlData = xmlData.Replace("", ""); - xmlData = xmlData.Replace("", ""); - try { XmlDocument doc = new XmlDocument(); @@ -261,41 +246,13 @@ namespace OpenSim.Region.Framework.Scenes.Serialization { using (XmlTextWriter writer = new XmlTextWriter(sw)) { - ToXml2Format(sceneObject, writer); + SOGToXml2(writer, sceneObject, new Dictionary()); } return sw.ToString(); } } - /// - /// Serialize a scene object to the 'xml2' format. - /// - /// - /// - public static void ToXml2Format(SceneObjectGroup sceneObject, XmlTextWriter writer) - { - //m_log.DebugFormat("[SERIALIZER]: Starting serialization of SOG {0} to XML2", Name); - //int time = System.Environment.TickCount; - - writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); - sceneObject.RootPart.ToXml(writer); - writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); - - SceneObjectPart[] parts = sceneObject.Parts; - for (int i = 0; i < parts.Length; i++) - { - SceneObjectPart part = parts[i]; - if (part.UUID != sceneObject.RootPart.UUID) - part.ToXml(writer); - } - - writer.WriteEndElement(); // End of OtherParts - sceneObject.SaveScriptedState(writer); - writer.WriteEndElement(); // End of SceneObjectGroup - - //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0} to XML2, {1}ms", Name, System.Environment.TickCount - time); - } #region manual serialization @@ -386,6 +343,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization m_TaskInventoryXmlProcessors.Add("PermsGranter", ProcessTIPermsGranter); m_TaskInventoryXmlProcessors.Add("PermsMask", ProcessTIPermsMask); m_TaskInventoryXmlProcessors.Add("Type", ProcessTIType); + m_TaskInventoryXmlProcessors.Add("OwnerChanged", ProcessTIOwnerChanged); + #endregion #region ShapeXmlProcessors initialization @@ -817,6 +776,11 @@ namespace OpenSim.Region.Framework.Scenes.Serialization item.Type = reader.ReadElementContentAsInt("Type", String.Empty); } + private static void ProcessTIOwnerChanged(TaskInventoryItem item, XmlTextReader reader) + { + item.OwnerChanged = reader.ReadElementContentAsBoolean("OwnerChanged", String.Empty); + } + #endregion #region ShapeXmlProcessors @@ -1078,20 +1042,20 @@ namespace OpenSim.Region.Framework.Scenes.Serialization public static void SOGToXml2(XmlTextWriter writer, SceneObjectGroup sog, Dictionaryoptions) { writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); - SOPToXml2(writer, sog.RootPart, null, options); + SOPToXml2(writer, sog.RootPart, options); writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); sog.ForEachPart(delegate(SceneObjectPart sop) { if (sop.UUID != sog.RootPart.UUID) - SOPToXml2(writer, sop, sog.RootPart, options); + SOPToXml2(writer, sop, options); }); writer.WriteEndElement(); writer.WriteEndElement(); } - static void SOPToXml2(XmlTextWriter writer, SceneObjectPart sop, SceneObjectPart parent, Dictionary options) + public static void SOPToXml2(XmlTextWriter writer, SceneObjectPart sop, Dictionary options) { writer.WriteStartElement("SceneObjectPart"); writer.WriteAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); @@ -1229,6 +1193,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization WriteUUID(writer, "PermsGranter", item.PermsGranter, options); writer.WriteElementString("PermsMask", item.PermsMask.ToString()); writer.WriteElementString("Type", item.Type.ToString()); + writer.WriteElementString("OwnerChanged", item.OwnerChanged.ToString().ToLower()); writer.WriteEndElement(); // TaskInventoryItem } @@ -1398,7 +1363,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization } else { - //m_log.DebugFormat("[SceneObjectSerializer]: caught unknown element {0}", nodeName); + m_log.DebugFormat("[SceneObjectSerializer]: caught unknown element {0}", nodeName); reader.ReadOuterXml(); // ignore }