Merge branch 'master' into careminster
commit
597f99bca7
|
@ -41,6 +41,7 @@ using OpenSim.Framework.Serialization.External;
|
||||||
using OpenSim.Region.CoreModules.World.Terrain;
|
using OpenSim.Region.CoreModules.World.Terrain;
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
using OpenSim.Region.Framework.Scenes;
|
using OpenSim.Region.Framework.Scenes;
|
||||||
|
using OpenSim.Region.Framework.Scenes.Serialization;
|
||||||
using OpenSim.Services.Interfaces;
|
using OpenSim.Services.Interfaces;
|
||||||
|
|
||||||
namespace OpenSim.Region.CoreModules.World.Archiver
|
namespace OpenSim.Region.CoreModules.World.Archiver
|
||||||
|
|
|
@ -291,6 +291,59 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
|
||||||
// TODO: Test presence of more files and contents of files.
|
// TODO: Test presence of more files and contents of files.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Test loading an OpenSim Region Archive where the scene object parts are not ordered by link number (e.g.
|
||||||
|
/// 2 can come after 3).
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestLoadOarUnorderedParts()
|
||||||
|
{
|
||||||
|
TestHelpers.InMethod();
|
||||||
|
|
||||||
|
UUID ownerId = TestHelpers.ParseTail(0xaaaa);
|
||||||
|
|
||||||
|
MemoryStream archiveWriteStream = new MemoryStream();
|
||||||
|
TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
|
||||||
|
|
||||||
|
tar.WriteFile(
|
||||||
|
ArchiveConstants.CONTROL_FILE_PATH,
|
||||||
|
new ArchiveWriteRequestPreparation(null, (Stream)null, Guid.Empty).CreateControlFile(new Dictionary<string, Object>()));
|
||||||
|
|
||||||
|
SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, ownerId, "obj1-", 0x11);
|
||||||
|
SceneObjectPart sop2
|
||||||
|
= SceneHelpers.CreateSceneObjectPart("obj1-Part2", TestHelpers.ParseTail(0x12), ownerId);
|
||||||
|
SceneObjectPart sop3
|
||||||
|
= SceneHelpers.CreateSceneObjectPart("obj1-Part3", TestHelpers.ParseTail(0x13), ownerId);
|
||||||
|
|
||||||
|
// Add the parts so they will be written out in reverse order to the oar
|
||||||
|
sog1.AddPart(sop3);
|
||||||
|
sop3.LinkNum = 3;
|
||||||
|
sog1.AddPart(sop2);
|
||||||
|
sop2.LinkNum = 2;
|
||||||
|
|
||||||
|
tar.WriteFile(
|
||||||
|
ArchiveConstants.CreateOarObjectPath(sog1.Name, sog1.UUID, sog1.AbsolutePosition),
|
||||||
|
SceneObjectSerializer.ToXml2Format(sog1));
|
||||||
|
|
||||||
|
tar.Close();
|
||||||
|
|
||||||
|
MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
|
||||||
|
|
||||||
|
lock (this)
|
||||||
|
{
|
||||||
|
m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
|
||||||
|
m_archiverModule.DearchiveRegion(archiveReadStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.That(m_lastErrorMessage, Is.Null);
|
||||||
|
|
||||||
|
SceneObjectPart part2 = m_scene.GetSceneObjectPart("obj1-Part2");
|
||||||
|
Assert.That(part2.LinkNum, Is.EqualTo(2));
|
||||||
|
|
||||||
|
SceneObjectPart part3 = m_scene.GetSceneObjectPart("obj1-Part3");
|
||||||
|
Assert.That(part3.LinkNum, Is.EqualTo(3));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Test loading an OpenSim Region Archive.
|
/// Test loading an OpenSim Region Archive.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -29,8 +29,10 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using log4net;
|
using log4net;
|
||||||
using Mono.Addins;
|
using Mono.Addins;
|
||||||
|
using NDesk.Options;
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
@ -78,23 +80,29 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
|
||||||
m_scene = scene;
|
m_scene = scene;
|
||||||
m_console = MainConsole.Instance;
|
m_console = MainConsole.Instance;
|
||||||
|
|
||||||
m_console.Commands.AddCommand("Objects", false, "delete object owner",
|
m_console.Commands.AddCommand(
|
||||||
|
"Objects", false, "delete object owner",
|
||||||
"delete object owner <UUID>",
|
"delete object owner <UUID>",
|
||||||
"Delete a scene object by owner", HandleDeleteObject);
|
"Delete a scene object by owner", HandleDeleteObject);
|
||||||
|
|
||||||
m_console.Commands.AddCommand("Objects", false, "delete object creator",
|
m_console.Commands.AddCommand(
|
||||||
|
"Objects", false, "delete object creator",
|
||||||
"delete object creator <UUID>",
|
"delete object creator <UUID>",
|
||||||
"Delete a scene object by creator", HandleDeleteObject);
|
"Delete a scene object by creator", HandleDeleteObject);
|
||||||
|
|
||||||
m_console.Commands.AddCommand("Objects", false, "delete object uuid",
|
m_console.Commands.AddCommand(
|
||||||
|
"Objects", false, "delete object uuid",
|
||||||
"delete object uuid <UUID>",
|
"delete object uuid <UUID>",
|
||||||
"Delete a scene object by uuid", HandleDeleteObject);
|
"Delete a scene object by uuid", HandleDeleteObject);
|
||||||
|
|
||||||
m_console.Commands.AddCommand("Objects", false, "delete object name",
|
m_console.Commands.AddCommand(
|
||||||
"delete object name <name>",
|
"Objects", false, "delete object name",
|
||||||
"Delete a scene object by name", HandleDeleteObject);
|
"delete object name [--regex] <name>",
|
||||||
|
"Delete a scene object by name.\nIf --regex is specified then the name is treatead as a regular expression",
|
||||||
|
HandleDeleteObject);
|
||||||
|
|
||||||
m_console.Commands.AddCommand("Objects", false, "delete object outside",
|
m_console.Commands.AddCommand(
|
||||||
|
"Objects", false, "delete object outside",
|
||||||
"delete object outside",
|
"delete object outside",
|
||||||
"Delete all scene objects outside region boundaries", HandleDeleteObject);
|
"Delete all scene objects outside region boundaries", HandleDeleteObject);
|
||||||
|
|
||||||
|
@ -109,8 +117,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
|
||||||
"Objects",
|
"Objects",
|
||||||
false,
|
false,
|
||||||
"show object name",
|
"show object name",
|
||||||
"show object name <name>",
|
"show object name [--regex] <name>",
|
||||||
"Show details of scene objects with the given name", HandleShowObjectByName);
|
"Show details of scene objects with the given name.\nIf --regex is specified then the name is treatead as a regular expression",
|
||||||
|
HandleShowObjectByName);
|
||||||
|
|
||||||
m_console.Commands.AddCommand(
|
m_console.Commands.AddCommand(
|
||||||
"Objects",
|
"Objects",
|
||||||
|
@ -123,8 +132,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
|
||||||
"Objects",
|
"Objects",
|
||||||
false,
|
false,
|
||||||
"show part name",
|
"show part name",
|
||||||
"show part name <name>",
|
"show part name [--regex] <name>",
|
||||||
"Show details of scene object parts with the given name", HandleShowPartByName);
|
"Show details of scene object parts with the given name.\nIf --regex is specified then the name is treatead as a regular expression",
|
||||||
|
HandleShowPartByName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveRegion(Scene scene)
|
public void RemoveRegion(Scene scene)
|
||||||
|
@ -169,22 +179,38 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
|
||||||
m_console.OutputFormat(sb.ToString());
|
m_console.OutputFormat(sb.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleShowObjectByName(string module, string[] cmd)
|
private void HandleShowObjectByName(string module, string[] cmdparams)
|
||||||
{
|
{
|
||||||
if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
|
if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (cmd.Length < 4)
|
bool useRegex = false;
|
||||||
|
OptionSet options = new OptionSet().Add("regex", v=> useRegex = v != null );
|
||||||
|
|
||||||
|
List<string> mainParams = options.Parse(cmdparams);
|
||||||
|
|
||||||
|
if (mainParams.Count < 4)
|
||||||
{
|
{
|
||||||
m_console.OutputFormat("Usage: show object name <name>");
|
m_console.OutputFormat("Usage: show object name [--regex] <name>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string name = cmd[3];
|
string name = mainParams[3];
|
||||||
|
|
||||||
List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
|
List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
|
||||||
|
Action<SceneObjectGroup> searchAction;
|
||||||
|
|
||||||
m_scene.ForEachSOG(so => { if (so.Name == name) { sceneObjects.Add(so); }});
|
if (useRegex)
|
||||||
|
{
|
||||||
|
Regex nameRegex = new Regex(name);
|
||||||
|
searchAction = so => { if (nameRegex.IsMatch(so.Name)) { sceneObjects.Add(so); }};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
searchAction = so => { if (so.Name == name) { sceneObjects.Add(so); }};
|
||||||
|
}
|
||||||
|
|
||||||
|
m_scene.ForEachSOG(searchAction);
|
||||||
|
|
||||||
if (sceneObjects.Count == 0)
|
if (sceneObjects.Count == 0)
|
||||||
{
|
{
|
||||||
|
@ -235,22 +261,39 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
|
||||||
m_console.OutputFormat(sb.ToString());
|
m_console.OutputFormat(sb.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleShowPartByName(string module, string[] cmd)
|
private void HandleShowPartByName(string module, string[] cmdparams)
|
||||||
{
|
{
|
||||||
if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
|
if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (cmd.Length < 4)
|
bool useRegex = false;
|
||||||
|
OptionSet options = new OptionSet().Add("regex", v=> useRegex = v != null );
|
||||||
|
|
||||||
|
List<string> mainParams = options.Parse(cmdparams);
|
||||||
|
|
||||||
|
if (mainParams.Count < 4)
|
||||||
{
|
{
|
||||||
m_console.OutputFormat("Usage: show part name <name>");
|
m_console.OutputFormat("Usage: show part name [--regex] <name>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string name = cmd[3];
|
string name = mainParams[3];
|
||||||
|
|
||||||
List<SceneObjectPart> parts = new List<SceneObjectPart>();
|
List<SceneObjectPart> parts = new List<SceneObjectPart>();
|
||||||
|
|
||||||
m_scene.ForEachSOG(so => so.ForEachPart(sop => { if (sop.Name == name) { parts.Add(sop); } }));
|
Action<SceneObjectGroup> searchAction;
|
||||||
|
|
||||||
|
if (useRegex)
|
||||||
|
{
|
||||||
|
Regex nameRegex = new Regex(name);
|
||||||
|
searchAction = so => so.ForEachPart(sop => { if (nameRegex.IsMatch(sop.Name)) { parts.Add(sop); } });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
searchAction = so => so.ForEachPart(sop => { if (sop.Name == name) { parts.Add(sop); } });
|
||||||
|
}
|
||||||
|
|
||||||
|
m_scene.ForEachSOG(searchAction);
|
||||||
|
|
||||||
if (parts.Count == 0)
|
if (parts.Count == 0)
|
||||||
{
|
{
|
||||||
|
@ -312,9 +355,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
|
||||||
o = cmd[3];
|
o = cmd[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
List<SceneObjectGroup> deletes = new List<SceneObjectGroup>();
|
List<SceneObjectGroup> deletes = null;
|
||||||
|
|
||||||
UUID match;
|
UUID match;
|
||||||
|
bool requireConfirmation = true;
|
||||||
|
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
|
@ -322,6 +365,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
|
||||||
if (!UUID.TryParse(o, out match))
|
if (!UUID.TryParse(o, out match))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
deletes = new List<SceneObjectGroup>();
|
||||||
|
|
||||||
m_scene.ForEachSOG(delegate (SceneObjectGroup g)
|
m_scene.ForEachSOG(delegate (SceneObjectGroup g)
|
||||||
{
|
{
|
||||||
if (g.OwnerID == match && !g.IsAttachment)
|
if (g.OwnerID == match && !g.IsAttachment)
|
||||||
|
@ -337,6 +382,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
|
||||||
if (!UUID.TryParse(o, out match))
|
if (!UUID.TryParse(o, out match))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
deletes = new List<SceneObjectGroup>();
|
||||||
|
|
||||||
m_scene.ForEachSOG(delegate (SceneObjectGroup g)
|
m_scene.ForEachSOG(delegate (SceneObjectGroup g)
|
||||||
{
|
{
|
||||||
if (g.RootPart.CreatorID == match && !g.IsAttachment)
|
if (g.RootPart.CreatorID == match && !g.IsAttachment)
|
||||||
|
@ -352,6 +399,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
|
||||||
if (!UUID.TryParse(o, out match))
|
if (!UUID.TryParse(o, out match))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
requireConfirmation = false;
|
||||||
|
deletes = new List<SceneObjectGroup>();
|
||||||
|
|
||||||
m_scene.ForEachSOG(delegate (SceneObjectGroup g)
|
m_scene.ForEachSOG(delegate (SceneObjectGroup g)
|
||||||
{
|
{
|
||||||
if (g.UUID == match && !g.IsAttachment)
|
if (g.UUID == match && !g.IsAttachment)
|
||||||
|
@ -364,18 +414,12 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "name":
|
case "name":
|
||||||
m_scene.ForEachSOG(delegate (SceneObjectGroup g)
|
deletes = GetDeleteCandidatesByName(module, cmd);
|
||||||
{
|
|
||||||
if (g.RootPart.Name == o && !g.IsAttachment)
|
|
||||||
deletes.Add(g);
|
|
||||||
});
|
|
||||||
|
|
||||||
// if (deletes.Count == 0)
|
|
||||||
// m_console.OutputFormat("No objects were found with name {0}", o);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "outside":
|
case "outside":
|
||||||
|
deletes = new List<SceneObjectGroup>();
|
||||||
|
|
||||||
m_scene.ForEachSOG(delegate (SceneObjectGroup g)
|
m_scene.ForEachSOG(delegate (SceneObjectGroup g)
|
||||||
{
|
{
|
||||||
SceneObjectPart rootPart = g.RootPart;
|
SceneObjectPart rootPart = g.RootPart;
|
||||||
|
@ -398,10 +442,34 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
|
||||||
deletes.Add(g);
|
deletes.Add(g);
|
||||||
});
|
});
|
||||||
|
|
||||||
// if (deletes.Count == 0)
|
if (deletes.Count == 0)
|
||||||
// m_console.OutputFormat("No objects were found outside region bounds");
|
m_console.OutputFormat("No objects were found outside region bounds");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
m_console.OutputFormat("Unrecognized mode {0}", mode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deletes == null || deletes.Count <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (requireConfirmation)
|
||||||
|
{
|
||||||
|
string response = MainConsole.Instance.CmdPrompt(
|
||||||
|
string.Format(
|
||||||
|
"Are you sure that you want to delete {0} objects from {1}",
|
||||||
|
deletes.Count, m_scene.RegionInfo.RegionName),
|
||||||
|
"n");
|
||||||
|
|
||||||
|
if (response.ToLower() != "y")
|
||||||
|
{
|
||||||
|
MainConsole.Instance.OutputFormat(
|
||||||
|
"Aborting delete of {0} objects from {1}", deletes.Count, m_scene.RegionInfo.RegionName);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_console.OutputFormat("Deleting {0} objects in {1}", deletes.Count, m_scene.RegionInfo.RegionName);
|
m_console.OutputFormat("Deleting {0} objects in {1}", deletes.Count, m_scene.RegionInfo.RegionName);
|
||||||
|
@ -412,5 +480,44 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
|
||||||
m_scene.DeleteSceneObject(g, false);
|
m_scene.DeleteSceneObject(g, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<SceneObjectGroup> GetDeleteCandidatesByName(string module, string[] cmdparams)
|
||||||
|
{
|
||||||
|
if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
bool useRegex = false;
|
||||||
|
OptionSet options = new OptionSet().Add("regex", v=> useRegex = v != null );
|
||||||
|
|
||||||
|
List<string> mainParams = options.Parse(cmdparams);
|
||||||
|
|
||||||
|
if (mainParams.Count < 4)
|
||||||
|
{
|
||||||
|
m_console.OutputFormat("Usage: delete object name [--regex] <name>");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
string name = mainParams[3];
|
||||||
|
|
||||||
|
List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
|
||||||
|
Action<SceneObjectGroup> searchAction;
|
||||||
|
|
||||||
|
if (useRegex)
|
||||||
|
{
|
||||||
|
Regex nameRegex = new Regex(name);
|
||||||
|
searchAction = so => { if (nameRegex.IsMatch(so.Name)) { sceneObjects.Add(so); }};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
searchAction = so => { if (so.Name == name) { sceneObjects.Add(so); }};
|
||||||
|
}
|
||||||
|
|
||||||
|
m_scene.ForEachSOG(searchAction);
|
||||||
|
|
||||||
|
if (sceneObjects.Count == 0)
|
||||||
|
m_console.OutputFormat("No objects with name {0} found in {1}", name, m_scene.RegionInfo.RegionName);
|
||||||
|
|
||||||
|
return sceneObjects;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1010,7 +1010,18 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
public int LinkNum
|
public int LinkNum
|
||||||
{
|
{
|
||||||
get { return m_linkNum; }
|
get { return m_linkNum; }
|
||||||
set { m_linkNum = value; }
|
set
|
||||||
|
{
|
||||||
|
// if (ParentGroup != null)
|
||||||
|
// {
|
||||||
|
// m_log.DebugFormat(
|
||||||
|
// "[SCENE OBJECT PART]: Setting linknum of {0}@{1} to {2} from {3}",
|
||||||
|
// Name, AbsolutePosition, value, m_linkNum);
|
||||||
|
// Util.PrintCallStack();
|
||||||
|
// }
|
||||||
|
|
||||||
|
m_linkNum = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte ClickAction
|
public byte ClickAction
|
||||||
|
|
|
@ -1538,51 +1538,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////// Read /////////
|
|
||||||
public static bool Xml2ToSOG(XmlTextReader reader, SceneObjectGroup sog)
|
|
||||||
{
|
|
||||||
reader.Read();
|
|
||||||
reader.ReadStartElement("SceneObjectGroup");
|
|
||||||
SceneObjectPart root = Xml2ToSOP(reader);
|
|
||||||
if (root != null)
|
|
||||||
sog.SetRootPart(root);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sog.UUID == UUID.Zero)
|
|
||||||
sog.UUID = sog.RootPart.UUID;
|
|
||||||
|
|
||||||
reader.Read(); // OtherParts
|
|
||||||
|
|
||||||
while (!reader.EOF)
|
|
||||||
{
|
|
||||||
switch (reader.NodeType)
|
|
||||||
{
|
|
||||||
case XmlNodeType.Element:
|
|
||||||
if (reader.Name == "SceneObjectPart")
|
|
||||||
{
|
|
||||||
SceneObjectPart child = Xml2ToSOP(reader);
|
|
||||||
if (child != null)
|
|
||||||
sog.AddPart(child);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//Logger.Log("Found unexpected prim XML element " + reader.Name, Helpers.LogLevel.Debug);
|
|
||||||
reader.Read();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case XmlNodeType.EndElement:
|
|
||||||
default:
|
|
||||||
reader.Read();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SceneObjectPart Xml2ToSOP(XmlTextReader reader)
|
public static SceneObjectPart Xml2ToSOP(XmlTextReader reader)
|
||||||
{
|
{
|
||||||
SceneObjectPart obj = new SceneObjectPart();
|
SceneObjectPart obj = new SceneObjectPart();
|
||||||
|
|
|
@ -223,50 +223,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
||||||
|
|
||||||
public static SceneObjectGroup DeserializeGroupFromXml2(string xmlString)
|
public static SceneObjectGroup DeserializeGroupFromXml2(string xmlString)
|
||||||
{
|
{
|
||||||
XmlDocument doc = new XmlDocument();
|
return SceneObjectSerializer.FromXml2Format(xmlString);
|
||||||
XmlNode rootNode;
|
|
||||||
|
|
||||||
XmlTextReader reader = new XmlTextReader(new StringReader(xmlString));
|
|
||||||
reader.WhitespaceHandling = WhitespaceHandling.None;
|
|
||||||
doc.Load(reader);
|
|
||||||
reader.Close();
|
|
||||||
rootNode = doc.FirstChild;
|
|
||||||
|
|
||||||
// This is to deal with neighbouring regions that are still surrounding the group xml with the <scene>
|
|
||||||
// tag. It should be possible to remove the first part of this if statement once we go past 0.5.9 (or
|
|
||||||
// when some other changes forces all regions to upgrade).
|
|
||||||
// This might seem rather pointless since prim crossing from this revision to an earlier revision remains
|
|
||||||
// broken. But it isn't much work to accomodate the old format here.
|
|
||||||
if (rootNode.LocalName.Equals("scene"))
|
|
||||||
{
|
|
||||||
foreach (XmlNode aPrimNode in rootNode.ChildNodes)
|
|
||||||
{
|
|
||||||
// There is only ever one prim. This oddity should be removeable post 0.5.9
|
|
||||||
//return SceneObjectSerializer.FromXml2Format(aPrimNode.OuterXml);
|
|
||||||
using (reader = new XmlTextReader(new StringReader(aPrimNode.OuterXml)))
|
|
||||||
{
|
|
||||||
SceneObjectGroup obj = new SceneObjectGroup();
|
|
||||||
if (SceneObjectSerializer.Xml2ToSOG(reader, obj))
|
|
||||||
return obj;
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//return SceneObjectSerializer.FromXml2Format(rootNode.OuterXml);
|
|
||||||
using (reader = new XmlTextReader(new StringReader(rootNode.OuterXml)))
|
|
||||||
{
|
|
||||||
SceneObjectGroup obj = new SceneObjectGroup();
|
|
||||||
if (SceneObjectSerializer.Xml2ToSOG(reader, obj))
|
|
||||||
return obj;
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -307,8 +264,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
||||||
ICollection<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
|
ICollection<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
|
||||||
foreach (XmlNode aPrimNode in rootNode.ChildNodes)
|
foreach (XmlNode aPrimNode in rootNode.ChildNodes)
|
||||||
{
|
{
|
||||||
SceneObjectGroup obj = CreatePrimFromXml2(scene, aPrimNode.OuterXml);
|
SceneObjectGroup obj = DeserializeGroupFromXml2(aPrimNode.OuterXml);
|
||||||
if (obj != null && startScripts)
|
if (startScripts)
|
||||||
sceneObjects.Add(obj);
|
sceneObjects.Add(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,27 +276,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Create a prim from the xml2 representation.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="scene"></param>
|
|
||||||
/// <param name="xmlData"></param>
|
|
||||||
/// <returns>The scene object created. null if the scene object already existed</returns>
|
|
||||||
protected static SceneObjectGroup CreatePrimFromXml2(Scene scene, string xmlData)
|
|
||||||
{
|
|
||||||
//SceneObjectGroup obj = SceneObjectSerializer.FromXml2Format(xmlData);
|
|
||||||
using (XmlTextReader reader = new XmlTextReader(new StringReader(xmlData)))
|
|
||||||
{
|
|
||||||
SceneObjectGroup obj = new SceneObjectGroup();
|
|
||||||
SceneObjectSerializer.Xml2ToSOG(reader, obj);
|
|
||||||
|
|
||||||
if (scene.AddRestoredSceneObject(obj, true, false))
|
|
||||||
return obj;
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -624,7 +624,7 @@ namespace OpenSim.Tests.Common
|
||||||
/// <param name="ownerId"></param>
|
/// <param name="ownerId"></param>
|
||||||
/// <param name="partNamePrefix">
|
/// <param name="partNamePrefix">
|
||||||
/// The prefix to be given to part names. This will be suffixed with "Part<part no>"
|
/// The prefix to be given to part names. This will be suffixed with "Part<part no>"
|
||||||
/// (e.g. mynamePart0 for the root part)
|
/// (e.g. mynamePart1 for the root part)
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <param name="uuidTail">
|
/// <param name="uuidTail">
|
||||||
/// The hexadecimal last part of the UUID for parts created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}"
|
/// The hexadecimal last part of the UUID for parts created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}"
|
||||||
|
@ -637,14 +637,14 @@ namespace OpenSim.Tests.Common
|
||||||
|
|
||||||
SceneObjectGroup sog
|
SceneObjectGroup sog
|
||||||
= new SceneObjectGroup(
|
= new SceneObjectGroup(
|
||||||
CreateSceneObjectPart(string.Format("{0}Part0", partNamePrefix), new UUID(rawSogId), ownerId));
|
CreateSceneObjectPart(string.Format("{0}Part1", partNamePrefix), new UUID(rawSogId), ownerId));
|
||||||
|
|
||||||
if (parts > 1)
|
if (parts > 1)
|
||||||
for (int i = 1; i < parts; i++)
|
for (int i = 2; i <= parts; i++)
|
||||||
sog.AddPart(
|
sog.AddPart(
|
||||||
CreateSceneObjectPart(
|
CreateSceneObjectPart(
|
||||||
string.Format("{0}Part{1}", partNamePrefix, i),
|
string.Format("{0}Part{1}", partNamePrefix, i),
|
||||||
new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail + i)),
|
new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail + i - 1)),
|
||||||
ownerId));
|
ownerId));
|
||||||
|
|
||||||
return sog;
|
return sog;
|
||||||
|
|
Loading…
Reference in New Issue