diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 8dbf72ad5b..88416d3694 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1816,7 +1816,7 @@ namespace OpenSim.Region.Framework.Scenes { UUID assetID = UUID.Zero; - string sceneObjectXml = objectGroup.ToXmlString(); + string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup); // Get the user info of the item destination // @@ -2040,7 +2040,7 @@ namespace OpenSim.Region.Framework.Scenes "[ATTACHMENT]: Updating asset for attachment {0}, attachpoint {1}", grp.UUID, grp.GetAttachmentPoint()); - string sceneObjectXml = objectGroup.ToXmlString(); + string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup); CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(agentID); @@ -2111,7 +2111,7 @@ namespace OpenSim.Region.Framework.Scenes itemID = UUID.Zero; if (grp != null) { - string sceneObjectXml = grp.ToXmlString(); + string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(AgentId); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index a81bd123fb..d1260d4cd5 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -44,6 +44,7 @@ using OpenSim.Framework.Communications.Clients; using OpenSim.Framework.Console; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes.Scripting; +using OpenSim.Region.Framework.Scenes.Serialization; using OpenSim.Region.Physics.Manager; using Timer=System.Timers.Timer; using TPFlags = OpenSim.Framework.Constants.TeleportFlags; @@ -3383,7 +3384,7 @@ namespace OpenSim.Region.Framework.Scenes break; case 2: // Sell a copy - string sceneObjectXml = group.ToXmlString(); + string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(group); CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index b0de4054f3..cceb444113 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -655,50 +655,6 @@ namespace OpenSim.Region.Framework.Scenes #endregion - public string ToXmlString() - { - using (StringWriter sw = new StringWriter()) - { - using (XmlTextWriter writer = new XmlTextWriter(sw)) - { - ToXml(writer); - } - - return sw.ToString(); - } - } - - public void ToXml(XmlTextWriter writer) - { - //m_log.DebugFormat("[SOG]: Starting serialization of {0}", Name); - //int time = System.Environment.TickCount; - - writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); - writer.WriteStartElement(String.Empty, "RootPart", String.Empty); - m_rootPart.ToXml(writer); - writer.WriteEndElement(); - writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); - - lock (m_parts) - { - foreach (SceneObjectPart part in m_parts.Values) - { - if (part.UUID != m_rootPart.UUID) - { - writer.WriteStartElement(String.Empty, "Part", String.Empty); - part.ToXml(writer); - writer.WriteEndElement(); - } - } - } - - writer.WriteEndElement(); // OtherParts - SaveScriptedState(writer); - writer.WriteEndElement(); // SceneObjectGroup - - //m_log.DebugFormat("[SOG]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); - } - public string ToXmlString2() { using (StringWriter sw = new StringWriter()) @@ -714,7 +670,6 @@ namespace OpenSim.Region.Framework.Scenes public void ToXml2(XmlTextWriter writer) { - //m_log.DebugFormat("[SOG]: Starting serialization of SOG {0} to XML2", Name); //int time = System.Environment.TickCount; @@ -738,12 +693,10 @@ namespace OpenSim.Region.Framework.Scenes writer.WriteEndElement(); // End of SceneObjectGroup //m_log.DebugFormat("[SOG]: Finished serialization of SOG {0} to XML2, {1}ms", Name, System.Environment.TickCount - time); - } - private void SaveScriptedState(XmlTextWriter writer) + public void SaveScriptedState(XmlTextWriter writer) { - XmlDocument doc = new XmlDocument(); Dictionary states = new Dictionary(); @@ -774,7 +727,6 @@ namespace OpenSim.Region.Framework.Scenes } writer.WriteEndElement(); // End of GroupScriptStates } - } /// diff --git a/OpenSim/Region/Framework/Scenes/SceneXmlLoader.cs b/OpenSim/Region/Framework/Scenes/SceneXmlLoader.cs index b5f46eebf7..212ca72ee2 100644 --- a/OpenSim/Region/Framework/Scenes/SceneXmlLoader.cs +++ b/OpenSim/Region/Framework/Scenes/SceneXmlLoader.cs @@ -90,7 +90,7 @@ namespace OpenSim.Region.Framework.Scenes { if (ent is SceneObjectGroup) { - stream.WriteLine(((SceneObjectGroup) ent).ToXmlString()); + stream.WriteLine(SceneObjectSerializer.ToOriginalXmlFormat((SceneObjectGroup)ent)); primCount++; } } diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index ebb27c3f06..9eac3be388 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -64,7 +64,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); //int time = System.Environment.TickCount; - SceneObjectGroup so = new SceneObjectGroup(); + SceneObjectGroup sceneObject = new SceneObjectGroup(); // libomv.types changes UUID to Guid serialization = serialization.Replace("", ""); @@ -94,7 +94,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization { sr = new StringReader(parts[0].InnerXml); reader = new XmlTextReader(sr); - so.SetRootPart(SceneObjectPart.FromXml(fromUserInventoryItemID, reader)); + sceneObject.SetRootPart(SceneObjectPart.FromXml(fromUserInventoryItemID, reader)); reader.Close(); sr.Close(); } @@ -107,7 +107,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization reader = new XmlTextReader(sr); SceneObjectPart part = SceneObjectPart.FromXml(reader); linkNum = part.LinkNum; - so.AddPart(part); + sceneObject.AddPart(part); part.LinkNum = linkNum; part.TrimPermissions(); part.StoreUndoState(); @@ -117,7 +117,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization // Script state may, or may not, exist. Not having any, is NOT // ever a problem. - so.LoadScriptState(doc); + sceneObject.LoadScriptState(doc); } catch (Exception e) { @@ -127,7 +127,61 @@ namespace OpenSim.Region.Framework.Scenes.Serialization //m_log.DebugFormat("[SERIALIZER]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); - return so; - } + return sceneObject; + } + + /// + /// Serialize a scene object to the original xml format + /// + /// + /// + public static string ToOriginalXmlFormat(SceneObjectGroup sceneObject) + { + using (StringWriter sw = new StringWriter()) + { + using (XmlTextWriter writer = new XmlTextWriter(sw)) + { + ToOriginalXmlFormat(sceneObject, writer); + } + + return sw.ToString(); + } + } + + /// + /// Serialize a scene object to the original xml format + /// + /// + /// + public static void ToOriginalXmlFormat(SceneObjectGroup sceneObject, XmlTextWriter writer) + { + //m_log.DebugFormat("[SERIALIZER]: Starting serialization of {0}", Name); + //int time = System.Environment.TickCount; + + writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); + writer.WriteStartElement(String.Empty, "RootPart", String.Empty); + sceneObject.RootPart.ToXml(writer); + writer.WriteEndElement(); + writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); + + lock (sceneObject.Children) + { + foreach (SceneObjectPart part in sceneObject.Children.Values) + { + if (part.UUID != sceneObject.RootPart.UUID) + { + writer.WriteStartElement(String.Empty, "Part", String.Empty); + part.ToXml(writer); + writer.WriteEndElement(); + } + } + } + + writer.WriteEndElement(); // OtherParts + sceneObject.SaveScriptedState(writer); + writer.WriteEndElement(); // SceneObjectGroup + + //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); + } } }