From f8721c3c1cd5d4eb2827ea1cfd36e08f3a100345 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 18 Jul 2008 14:42:06 +0000 Subject: * refactor: break out sog loading code into two parts so that post-deserialization changes can be carried out before adding it to a scene --- .../Modules/World/Archiver/ArchiveReadRequest.cs | 24 ++++++++++------------ .../Modules/World/Serialiser/IRegionSerialiser.cs | 5 ++--- .../Modules/World/Serialiser/SceneXmlLoader.cs | 10 ++++----- .../Modules/World/Serialiser/SerialiserModule.cs | 4 ++-- OpenSim/Region/Environment/Scenes/Scene.cs | 3 ++- 5 files changed, 22 insertions(+), 24 deletions(-) diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs index f5496b9..d901b54 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs @@ -123,21 +123,19 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver foreach (string serialisedSceneObject in serialisedSceneObjects) { - SceneObjectGroup sceneObject = serialiser.LoadGroupFromXml2(m_scene, serialisedSceneObject); + SceneObjectGroup sceneObject = serialiser.DeserializeGroupFromXml2(serialisedSceneObject); - // TODO: Change object creator/owner here - - if (null != sceneObject) + // Make the master the owner/creator of everything imported for now + LLUUID masterAvatarId = m_scene.RegionInfo.MasterAvatarAssignedUUID; + foreach (SceneObjectPart part in sceneObject.Children.Values) { - // Make the master the owner/creator of everything imported for now - LLUUID masterAvatarId = m_scene.RegionInfo.MasterAvatarAssignedUUID; - foreach (SceneObjectPart part in sceneObject.Children.Values) - { - part.CreatorID = masterAvatarId; - part.OwnerID = masterAvatarId; - part.LastOwnerID = masterAvatarId; - } - + part.CreatorID = masterAvatarId; + part.OwnerID = masterAvatarId; + part.LastOwnerID = masterAvatarId; + } + + if (m_scene.AddRestoredSceneObject(sceneObject, true, false)) + { sceneObjects.Add(sceneObject); } } diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs index 6e48f8e..8a13f2b 100644 --- a/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs +++ b/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs @@ -81,12 +81,11 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser void SavePrimListToXml2(List entityList, string fileName); /// - /// Load an individual scene object from the xml2 format + /// Deserializes a scene object from its xml2 representation. This does not load the object into the scene. /// - /// /// /// The scene object created. null if the scene object already existed - SceneObjectGroup LoadGroupFromXml2(Scene scene, string xmlString); + SceneObjectGroup DeserializeGroupFromXml2(string xmlString); /// /// Serialize an individual scene object into the xml2 format diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs index 6327d65..cd1fecb 100644 --- a/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs +++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs @@ -104,7 +104,7 @@ namespace OpenSim.Region.Environment.Scenes return grp.ToXmlString2(); } - public static SceneObjectGroup LoadGroupFromXml2(Scene scene, string xmlString) + public static SceneObjectGroup DeserializeGroupFromXml2(string xmlString) { XmlDocument doc = new XmlDocument(); XmlNode rootNode; @@ -124,15 +124,15 @@ namespace OpenSim.Region.Environment.Scenes { foreach (XmlNode aPrimNode in rootNode.ChildNodes) { - CreatePrimFromXml2(scene, aPrimNode.OuterXml); + // There is only ever one prim. This oddity should be removeable post 0.5.9 + return new SceneObjectGroup(aPrimNode.OuterXml); } - - // There is only ever one prim, but it's easiest to return null here since this part should disappear post 0.5.9 anyway + return null; } else { - return CreatePrimFromXml2(scene, rootNode.OuterXml); + return new SceneObjectGroup(rootNode.OuterXml); } } diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs index eb3ab2e..cefd15f 100644 --- a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs @@ -112,9 +112,9 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser SceneXmlLoader.SavePrimsToXml2(scene, fileName); } - public SceneObjectGroup LoadGroupFromXml2(Scene scene, string xmlString) + public SceneObjectGroup DeserializeGroupFromXml2(string xmlString) { - return SceneXmlLoader.LoadGroupFromXml2(scene, xmlString); + return SceneXmlLoader.DeserializeGroupFromXml2(xmlString); } public string SaveGroupToXml2(SceneObjectGroup grp) diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 4aa9cf9..bbb028d 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -1902,7 +1902,8 @@ namespace OpenSim.Region.Environment.Scenes m_log.Warn("{[INTERREGION]: A new prim arrived from a neighbor"); if (XMLMethod == 0) { - m_serialiser.LoadGroupFromXml2(this, objXMLData); + SceneObjectGroup sceneObject = m_serialiser.DeserializeGroupFromXml2(objXMLData); + AddRestoredSceneObject(sceneObject, true, false); SceneObjectPart RootPrim = GetSceneObjectPart(primID); if (RootPrim != null) -- cgit v1.1