* refactor: move saved named prims to xml2 method out into the serialization module

0.6.1-post-fixes
Justin Clarke Casey 2008-12-19 19:47:11 +00:00
parent e62016d2c7
commit aa497a1867
5 changed files with 36 additions and 26 deletions

View File

@ -102,6 +102,8 @@ namespace OpenSim.Region.Environment.Interfaces
/// <param name="min"></param> /// <param name="min"></param>
/// <param name="max"></param> /// <param name="max"></param>
void SavePrimListToXml2(List<EntityBase> entityList, TextWriter stream, Vector3 min, Vector3 max); void SavePrimListToXml2(List<EntityBase> entityList, TextWriter stream, Vector3 min, Vector3 max);
void SaveNamedPrimsToXml2(Scene scene, string primName, string fileName);
/// <summary> /// <summary>
/// Deserializes a scene object from its xml2 representation. This does not load the object into the scene. /// Deserializes a scene object from its xml2 representation. This does not load the object into the scene.

View File

@ -28,10 +28,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
//using System.Reflection; using System.Reflection;
using System.Xml; using System.Xml;
using OpenMetaverse; using OpenMetaverse;
//using log4net; using log4net;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Manager;
@ -42,7 +42,7 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary> /// </summary>
public class SceneXmlLoader public class SceneXmlLoader
{ {
//private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static void LoadPrimsFromXml(Scene scene, string fileName, bool newIDS, Vector3 loadOffset) public static void LoadPrimsFromXml(Scene scene, string fileName, bool newIDS, Vector3 loadOffset)
{ {
@ -213,6 +213,29 @@ namespace OpenSim.Region.Environment.Scenes
SavePrimListToXml2(EntityList, stream, min, max); SavePrimListToXml2(EntityList, stream, min, max);
} }
public static void SaveNamedPrimsToXml2(Scene scene, string primName, string fileName)
{
m_log.InfoFormat(
"[SERIALISER]: Saving prims with name {0} in xml2 format for region {1} to {2}",
primName, scene.RegionInfo.RegionName, fileName);
List<EntityBase> entityList = scene.GetEntities();
List<EntityBase> primList = new List<EntityBase>();
foreach (EntityBase ent in entityList)
{
if (ent is SceneObjectGroup)
{
if (ent.Name == primName)
{
primList.Add(ent);
}
}
}
SavePrimListToXml2(primList, fileName);
}
public static void SavePrimListToXml2(List<EntityBase> entityList, string fileName) public static void SavePrimListToXml2(List<EntityBase> entityList, string fileName)
{ {

View File

@ -116,6 +116,11 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser
{ {
SceneXmlLoader.SavePrimsToXml2(scene, stream, min, max); SceneXmlLoader.SavePrimsToXml2(scene, stream, min, max);
} }
public void SaveNamedPrimsToXml2(Scene scene, string primName, string fileName)
{
SceneXmlLoader.SaveNamedPrimsToXml2(scene, primName, fileName);
}
public SceneObjectGroup DeserializeGroupFromXml2(string xmlString) public SceneObjectGroup DeserializeGroupFromXml2(string xmlString)
{ {

View File

@ -1880,28 +1880,6 @@ namespace OpenSim.Region.Environment.Scenes
return false; return false;
} }
public void SaveNamedPrimsToXml2(string primName, string fileName)
{
m_log.InfoFormat(
"[SCENE]: Saving prims with name {0} in xml2 format for region {1} to {2}", primName, RegionInfo.RegionName, fileName);
List<EntityBase> entityList = GetEntities();
List<EntityBase> primList = new List<EntityBase>();
foreach (EntityBase ent in entityList)
{
if (ent is SceneObjectGroup)
{
if (ent.Name == primName)
{
primList.Add(ent);
}
}
}
m_serialiser.SavePrimListToXml2(primList, fileName);
}
/// <summary> /// <summary>
/// Move the given scene object into a new region depending on which region its absolute position has moved /// Move the given scene object into a new region depending on which region its absolute position has moved
/// into. /// into.

View File

@ -215,7 +215,9 @@ namespace OpenSim.Region.Environment.Scenes
public void SaveNamedPrimsToXml2(string primName, string filename) public void SaveNamedPrimsToXml2(string primName, string filename)
{ {
CurrentOrFirstScene.SaveNamedPrimsToXml2( primName, filename); IRegionSerialiserModule serialiser = CurrentOrFirstScene.RequestModuleInterface<IRegionSerialiserModule>();
if (serialiser != null)
serialiser.SaveNamedPrimsToXml2(CurrentOrFirstScene, primName, filename);
} }
/// <summary> /// <summary>