* refactor: break out sog loading code into two parts so that post-deserialization changes can be carried out before adding it to a scene

0.6.0-stable
Justin Clarke Casey 2008-07-18 14:42:06 +00:00
parent a6e2589537
commit f8721c3c1c
5 changed files with 22 additions and 24 deletions

View File

@ -123,12 +123,8 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
foreach (string serialisedSceneObject in serialisedSceneObjects) 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 // Make the master the owner/creator of everything imported for now
LLUUID masterAvatarId = m_scene.RegionInfo.MasterAvatarAssignedUUID; LLUUID masterAvatarId = m_scene.RegionInfo.MasterAvatarAssignedUUID;
foreach (SceneObjectPart part in sceneObject.Children.Values) foreach (SceneObjectPart part in sceneObject.Children.Values)
@ -138,6 +134,8 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
part.LastOwnerID = masterAvatarId; part.LastOwnerID = masterAvatarId;
} }
if (m_scene.AddRestoredSceneObject(sceneObject, true, false))
{
sceneObjects.Add(sceneObject); sceneObjects.Add(sceneObject);
} }
} }

View File

@ -81,12 +81,11 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser
void SavePrimListToXml2(List<EntityBase> entityList, string fileName); void SavePrimListToXml2(List<EntityBase> entityList, string fileName);
/// <summary> /// <summary>
/// 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.
/// </summary> /// </summary>
/// <param name="scene"></param>
/// <param name="xmlString"></param> /// <param name="xmlString"></param>
/// <returns>The scene object created. null if the scene object already existed</returns> /// <returns>The scene object created. null if the scene object already existed</returns>
SceneObjectGroup LoadGroupFromXml2(Scene scene, string xmlString); SceneObjectGroup DeserializeGroupFromXml2(string xmlString);
/// <summary> /// <summary>
/// Serialize an individual scene object into the xml2 format /// Serialize an individual scene object into the xml2 format

View File

@ -104,7 +104,7 @@ namespace OpenSim.Region.Environment.Scenes
return grp.ToXmlString2(); return grp.ToXmlString2();
} }
public static SceneObjectGroup LoadGroupFromXml2(Scene scene, string xmlString) public static SceneObjectGroup DeserializeGroupFromXml2(string xmlString)
{ {
XmlDocument doc = new XmlDocument(); XmlDocument doc = new XmlDocument();
XmlNode rootNode; XmlNode rootNode;
@ -124,15 +124,15 @@ namespace OpenSim.Region.Environment.Scenes
{ {
foreach (XmlNode aPrimNode in rootNode.ChildNodes) 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; return null;
} }
else else
{ {
return CreatePrimFromXml2(scene, rootNode.OuterXml); return new SceneObjectGroup(rootNode.OuterXml);
} }
} }

View File

@ -112,9 +112,9 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser
SceneXmlLoader.SavePrimsToXml2(scene, fileName); 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) public string SaveGroupToXml2(SceneObjectGroup grp)

View File

@ -1902,7 +1902,8 @@ namespace OpenSim.Region.Environment.Scenes
m_log.Warn("{[INTERREGION]: A new prim arrived from a neighbor"); m_log.Warn("{[INTERREGION]: A new prim arrived from a neighbor");
if (XMLMethod == 0) if (XMLMethod == 0)
{ {
m_serialiser.LoadGroupFromXml2(this, objXMLData); SceneObjectGroup sceneObject = m_serialiser.DeserializeGroupFromXml2(objXMLData);
AddRestoredSceneObject(sceneObject, true, false);
SceneObjectPart RootPrim = GetSceneObjectPart(primID); SceneObjectPart RootPrim = GetSceneObjectPart(primID);
if (RootPrim != null) if (RootPrim != null)