Added "save-prims-xml2 <PrimName> <FileName>", as we were lacking a method to save a single primitive or small group of them. This command will save all prims in the current scene that name matches the "PrimName" parameter. The saved file is in standard xml2 format, so can be loaded using load-xml2

0.6.0-stable
MW 2008-07-01 19:23:45 +00:00
parent 0aaf0c4565
commit c9fe500212
6 changed files with 58 additions and 4 deletions

View File

@ -401,6 +401,17 @@ namespace OpenSim
}
break;
case "save-prims-xml2":
if (cmdparams.Length > 1)
{
m_sceneManager.SaveNamedPrimsToXml2(cmdparams[0], cmdparams[1]);
}
else
{
m_sceneManager.SaveNamedPrimsToXml2("Primitive", DEFAULT_PRIM_BACKUP_FILENAME);
}
break;
case "load-oar":
m_log.Error("[CONSOLE]: Don't use me - I haven't yet been sufficiently implemented!");

View File

@ -73,6 +73,13 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser
/// <param name="fileName"></param>
void SavePrimsToXml2(Scene scene, string fileName);
/// <summary>
/// Save a set of prims in the xml2 format
/// </summary>
/// <param name="entityList"></param>
/// <param name="fileName"></param>
void SavePrimListToXml2(List<EntityBase> entityList, string fileName);
/// <summary>
/// Load an individual scene object from the xml2 format
/// </summary>

View File

@ -185,19 +185,24 @@ namespace OpenSim.Region.Environment.Scenes
}
public static void SavePrimsToXml2(Scene scene, string fileName)
{
List<EntityBase> EntityList = scene.GetEntities();
SavePrimListToXml2(EntityList, fileName);
}
public static void SavePrimListToXml2(List<EntityBase> entityList, string fileName)
{
FileStream file = new FileStream(fileName, FileMode.Create);
StreamWriter stream = new StreamWriter(file);
int primCount = 0;
stream.WriteLine("<scene>\n");
List<EntityBase> EntityList = scene.GetEntities();
foreach (EntityBase ent in EntityList)
foreach (EntityBase ent in entityList)
{
if (ent is SceneObjectGroup)
{
stream.WriteLine(((SceneObjectGroup) ent).ToXmlString2());
stream.WriteLine(((SceneObjectGroup)ent).ToXmlString2());
primCount++;
}
}

View File

@ -122,6 +122,11 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser
return SceneXmlLoader.SaveGroupToXml2(grp);
}
public void SavePrimListToXml2(List<EntityBase> entityList, string fileName)
{
SceneXmlLoader.SavePrimListToXml2(entityList, fileName);
}
public List<string> SerialiseRegion(Scene scene, string saveDir)
{
List<string> results = new List<string>();

View File

@ -1738,6 +1738,27 @@ namespace OpenSim.Region.Environment.Scenes
m_serialiser.SavePrimsToXml2(this, fileName);
}
public void SaveNamedPrimsToXml2(string primName, string 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>
/// Load a prim archive into the scene. This loads both prims and their assets.
/// </summary>

View File

@ -204,6 +204,11 @@ namespace OpenSim.Region.Environment.Scenes
CurrentOrFirstScene.SavePrimsToXml2(filename);
}
public void SaveNamedPrimsToXml2(string primName, string filename)
{
CurrentOrFirstScene.SaveNamedPrimsToXml2( primName, filename);
}
/// <summary>
/// Load an xml file of prims in OpenSimulator's current 'xml2' file format to the current scene
/// </summary>