mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 08:55:56 +08:00
Merge branch 'master' into careminster-presence-refactor
This commit is contained in:
@@ -1075,36 +1075,36 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
||||
|
||||
////////// Write /////////
|
||||
|
||||
public static void SOGToXml2(XmlTextWriter writer, SceneObjectGroup sog)
|
||||
public static void SOGToXml2(XmlTextWriter writer, SceneObjectGroup sog, Dictionary<string, object>options)
|
||||
{
|
||||
writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty);
|
||||
SOPToXml2(writer, sog.RootPart, null);
|
||||
SOPToXml2(writer, sog.RootPart, null, options);
|
||||
writer.WriteStartElement(String.Empty, "OtherParts", String.Empty);
|
||||
|
||||
sog.ForEachPart(delegate(SceneObjectPart sop)
|
||||
{
|
||||
if (sop.UUID != sog.RootPart.UUID)
|
||||
SOPToXml2(writer, sop, sog.RootPart);
|
||||
SOPToXml2(writer, sop, sog.RootPart, options);
|
||||
});
|
||||
|
||||
writer.WriteEndElement();
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
static void SOPToXml2(XmlTextWriter writer, SceneObjectPart sop, SceneObjectPart parent)
|
||||
static void SOPToXml2(XmlTextWriter writer, SceneObjectPart sop, SceneObjectPart parent, Dictionary<string, object> options)
|
||||
{
|
||||
writer.WriteStartElement("SceneObjectPart");
|
||||
writer.WriteAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
|
||||
writer.WriteAttributeString("xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
|
||||
|
||||
writer.WriteElementString("AllowedDrop", sop.AllowedDrop.ToString().ToLower());
|
||||
WriteUUID(writer, "CreatorID", sop.CreatorID);
|
||||
WriteUUID(writer, "FolderID", sop.FolderID);
|
||||
WriteUUID(writer, "CreatorID", sop.CreatorID, options);
|
||||
WriteUUID(writer, "FolderID", sop.FolderID, options);
|
||||
writer.WriteElementString("InventorySerial", sop.InventorySerial.ToString());
|
||||
|
||||
WriteTaskInventory(writer, sop.TaskInventory);
|
||||
WriteTaskInventory(writer, sop.TaskInventory, options);
|
||||
|
||||
WriteUUID(writer, "UUID", sop.UUID);
|
||||
WriteUUID(writer, "UUID", sop.UUID, options);
|
||||
writer.WriteElementString("LocalId", sop.LocalId.ToString());
|
||||
writer.WriteElementString("Name", sop.Name);
|
||||
writer.WriteElementString("Material", sop.Material.ToString());
|
||||
@@ -1137,7 +1137,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
||||
writer.WriteElementString("LinkNum", sop.LinkNum.ToString());
|
||||
writer.WriteElementString("ClickAction", sop.ClickAction.ToString());
|
||||
|
||||
WriteShape(writer, sop.Shape);
|
||||
WriteShape(writer, sop.Shape, options);
|
||||
|
||||
WriteVector(writer, "Scale", sop.Scale);
|
||||
writer.WriteElementString("UpdateFlag", sop.UpdateFlag.ToString());
|
||||
@@ -1151,16 +1151,16 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
||||
writer.WriteElementString("SalePrice", sop.SalePrice.ToString());
|
||||
writer.WriteElementString("ObjectSaleType", sop.ObjectSaleType.ToString());
|
||||
writer.WriteElementString("OwnershipCost", sop.OwnershipCost.ToString());
|
||||
WriteUUID(writer, "GroupID", sop.GroupID);
|
||||
WriteUUID(writer, "OwnerID", sop.OwnerID);
|
||||
WriteUUID(writer, "LastOwnerID", sop.LastOwnerID);
|
||||
WriteUUID(writer, "GroupID", sop.GroupID, options);
|
||||
WriteUUID(writer, "OwnerID", sop.OwnerID, options);
|
||||
WriteUUID(writer, "LastOwnerID", sop.LastOwnerID, options);
|
||||
writer.WriteElementString("BaseMask", sop.BaseMask.ToString());
|
||||
writer.WriteElementString("OwnerMask", sop.OwnerMask.ToString());
|
||||
writer.WriteElementString("GroupMask", sop.GroupMask.ToString());
|
||||
writer.WriteElementString("EveryoneMask", sop.EveryoneMask.ToString());
|
||||
writer.WriteElementString("NextOwnerMask", sop.NextOwnerMask.ToString());
|
||||
writer.WriteElementString("Flags", sop.Flags.ToString());
|
||||
WriteUUID(writer, "CollisionSound", sop.CollisionSound);
|
||||
WriteUUID(writer, "CollisionSound", sop.CollisionSound, options);
|
||||
writer.WriteElementString("CollisionSoundVolume", sop.CollisionSoundVolume.ToString());
|
||||
if (sop.MediaUrl != null)
|
||||
writer.WriteElementString("MediaUrl", sop.MediaUrl.ToString());
|
||||
@@ -1168,10 +1168,13 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
static void WriteUUID(XmlTextWriter writer, string name, UUID id)
|
||||
static void WriteUUID(XmlTextWriter writer, string name, UUID id, Dictionary<string, object> options)
|
||||
{
|
||||
writer.WriteStartElement(name);
|
||||
writer.WriteElementString("UUID", id.ToString());
|
||||
if (options.ContainsKey("old-guids"))
|
||||
writer.WriteElementString("Guid", id.ToString());
|
||||
else
|
||||
writer.WriteElementString("UUID", id.ToString());
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
@@ -1194,7 +1197,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
static void WriteTaskInventory(XmlTextWriter writer, TaskInventoryDictionary tinv)
|
||||
static void WriteTaskInventory(XmlTextWriter writer, TaskInventoryDictionary tinv, Dictionary<string, object> options)
|
||||
{
|
||||
if (tinv.Count > 0) // otherwise skip this
|
||||
{
|
||||
@@ -1203,27 +1206,27 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
||||
foreach (TaskInventoryItem item in tinv.Values)
|
||||
{
|
||||
writer.WriteStartElement("TaskInventoryItem");
|
||||
|
||||
WriteUUID(writer, "AssetID", item.AssetID);
|
||||
|
||||
WriteUUID(writer, "AssetID", item.AssetID, options);
|
||||
writer.WriteElementString("BasePermissions", item.BasePermissions.ToString());
|
||||
writer.WriteElementString("CreationDate", item.CreationDate.ToString());
|
||||
WriteUUID(writer, "CreatorID", item.CreatorID);
|
||||
WriteUUID(writer, "CreatorID", item.CreatorID, options);
|
||||
writer.WriteElementString("Description", item.Description);
|
||||
writer.WriteElementString("EveryonePermissions", item.EveryonePermissions.ToString());
|
||||
writer.WriteElementString("Flags", item.Flags.ToString());
|
||||
WriteUUID(writer, "GroupID", item.GroupID);
|
||||
WriteUUID(writer, "GroupID", item.GroupID, options);
|
||||
writer.WriteElementString("GroupPermissions", item.GroupPermissions.ToString());
|
||||
writer.WriteElementString("InvType", item.InvType.ToString());
|
||||
WriteUUID(writer, "ItemID", item.ItemID);
|
||||
WriteUUID(writer, "OldItemID", item.OldItemID);
|
||||
WriteUUID(writer, "LastOwnerID", item.LastOwnerID);
|
||||
WriteUUID(writer, "ItemID", item.ItemID, options);
|
||||
WriteUUID(writer, "OldItemID", item.OldItemID, options);
|
||||
WriteUUID(writer, "LastOwnerID", item.LastOwnerID, options);
|
||||
writer.WriteElementString("Name", item.Name);
|
||||
writer.WriteElementString("NextPermissions", item.NextPermissions.ToString());
|
||||
WriteUUID(writer, "OwnerID", item.OwnerID);
|
||||
WriteUUID(writer, "OwnerID", item.OwnerID, options);
|
||||
writer.WriteElementString("CurrentPermissions", item.CurrentPermissions.ToString());
|
||||
WriteUUID(writer, "ParentID", item.ParentID);
|
||||
WriteUUID(writer, "ParentPartID", item.ParentPartID);
|
||||
WriteUUID(writer, "PermsGranter", item.PermsGranter);
|
||||
WriteUUID(writer, "ParentID", item.ParentID, options);
|
||||
WriteUUID(writer, "ParentPartID", item.ParentPartID, options);
|
||||
WriteUUID(writer, "PermsGranter", item.PermsGranter, options);
|
||||
writer.WriteElementString("PermsMask", item.PermsMask.ToString());
|
||||
writer.WriteElementString("Type", item.Type.ToString());
|
||||
|
||||
@@ -1234,7 +1237,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
||||
}
|
||||
}
|
||||
|
||||
static void WriteShape(XmlTextWriter writer, PrimitiveBaseShape shp)
|
||||
static void WriteShape(XmlTextWriter writer, PrimitiveBaseShape shp, Dictionary<string, object> options)
|
||||
{
|
||||
if (shp != null)
|
||||
{
|
||||
@@ -1283,7 +1286,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
||||
writer.WriteElementString("ProfileShape", shp.ProfileShape.ToString());
|
||||
writer.WriteElementString("HollowShape", shp.HollowShape.ToString());
|
||||
|
||||
WriteUUID(writer, "SculptTexture", shp.SculptTexture);
|
||||
WriteUUID(writer, "SculptTexture", shp.SculptTexture, options);
|
||||
writer.WriteElementString("SculptType", shp.SculptType.ToString());
|
||||
writer.WriteStartElement("SculptData");
|
||||
byte[] sd;
|
||||
|
||||
@@ -45,6 +45,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
#region old xml format
|
||||
public static void LoadPrimsFromXml(Scene scene, string fileName, bool newIDS, Vector3 loadOffset)
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
@@ -98,11 +99,128 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
||||
file.Close();
|
||||
}
|
||||
|
||||
public static string SaveGroupToXml2(SceneObjectGroup grp)
|
||||
#endregion
|
||||
|
||||
#region XML2 serialization
|
||||
|
||||
// Called by archives (save oar)
|
||||
public static string SaveGroupToXml2(SceneObjectGroup grp, Dictionary<string, object> options)
|
||||
{
|
||||
return SceneObjectSerializer.ToXml2Format(grp);
|
||||
//return SceneObjectSerializer.ToXml2Format(grp);
|
||||
using (MemoryStream mem = new MemoryStream())
|
||||
{
|
||||
using (XmlTextWriter writer = new XmlTextWriter(mem, System.Text.Encoding.UTF8))
|
||||
{
|
||||
SceneObjectSerializer.SOGToXml2(writer, grp, options);
|
||||
writer.Flush();
|
||||
|
||||
using (StreamReader reader = new StreamReader(mem))
|
||||
{
|
||||
mem.Seek(0, SeekOrigin.Begin);
|
||||
return reader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Called by scene serializer (save xml2)
|
||||
public static void SavePrimsToXml2(Scene scene, string fileName)
|
||||
{
|
||||
EntityBase[] entityList = scene.GetEntities();
|
||||
SavePrimListToXml2(entityList, fileName);
|
||||
}
|
||||
|
||||
// Called by scene serializer (save xml2)
|
||||
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);
|
||||
|
||||
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.ToArray(), fileName);
|
||||
}
|
||||
|
||||
// Called by REST Application plugin
|
||||
public static void SavePrimsToXml2(Scene scene, TextWriter stream, Vector3 min, Vector3 max)
|
||||
{
|
||||
EntityBase[] entityList = scene.GetEntities();
|
||||
SavePrimListToXml2(entityList, stream, min, max);
|
||||
}
|
||||
|
||||
// Called here only. Should be private?
|
||||
public static void SavePrimListToXml2(EntityBase[] entityList, string fileName)
|
||||
{
|
||||
FileStream file = new FileStream(fileName, FileMode.Create);
|
||||
try
|
||||
{
|
||||
StreamWriter stream = new StreamWriter(file);
|
||||
try
|
||||
{
|
||||
SavePrimListToXml2(entityList, stream, Vector3.Zero, Vector3.Zero);
|
||||
}
|
||||
finally
|
||||
{
|
||||
stream.Close();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
file.Close();
|
||||
}
|
||||
}
|
||||
|
||||
// Called here only. Should be private?
|
||||
public static void SavePrimListToXml2(EntityBase[] entityList, TextWriter stream, Vector3 min, Vector3 max)
|
||||
{
|
||||
XmlTextWriter writer = new XmlTextWriter(stream);
|
||||
|
||||
int primCount = 0;
|
||||
stream.WriteLine("<scene>\n");
|
||||
|
||||
foreach (EntityBase ent in entityList)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
SceneObjectGroup g = (SceneObjectGroup)ent;
|
||||
if (!min.Equals(Vector3.Zero) || !max.Equals(Vector3.Zero))
|
||||
{
|
||||
Vector3 pos = g.RootPart.GetWorldPosition();
|
||||
if (min.X > pos.X || min.Y > pos.Y || min.Z > pos.Z)
|
||||
continue;
|
||||
if (max.X < pos.X || max.Y < pos.Y || max.Z < pos.Z)
|
||||
continue;
|
||||
}
|
||||
|
||||
//stream.WriteLine(SceneObjectSerializer.ToXml2Format(g));
|
||||
SceneObjectSerializer.SOGToXml2(writer, (SceneObjectGroup)ent, new Dictionary<string,object>());
|
||||
stream.WriteLine();
|
||||
|
||||
primCount++;
|
||||
}
|
||||
}
|
||||
|
||||
stream.WriteLine("</scene>\n");
|
||||
stream.Flush();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region XML2 deserialization
|
||||
|
||||
public static SceneObjectGroup DeserializeGroupFromXml2(string xmlString)
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
@@ -222,94 +340,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
||||
}
|
||||
}
|
||||
|
||||
public static void SavePrimsToXml2(Scene scene, string fileName)
|
||||
{
|
||||
EntityBase[] entityList = scene.GetEntities();
|
||||
SavePrimListToXml2(entityList, fileName);
|
||||
}
|
||||
|
||||
public static void SavePrimsToXml2(Scene scene, TextWriter stream, Vector3 min, Vector3 max)
|
||||
{
|
||||
EntityBase[] entityList = scene.GetEntities();
|
||||
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);
|
||||
|
||||
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.ToArray(), fileName);
|
||||
}
|
||||
|
||||
public static void SavePrimListToXml2(EntityBase[] entityList, string fileName)
|
||||
{
|
||||
FileStream file = new FileStream(fileName, FileMode.Create);
|
||||
try
|
||||
{
|
||||
StreamWriter stream = new StreamWriter(file);
|
||||
try
|
||||
{
|
||||
SavePrimListToXml2(entityList, stream, Vector3.Zero, Vector3.Zero);
|
||||
}
|
||||
finally
|
||||
{
|
||||
stream.Close();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
file.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public static void SavePrimListToXml2(EntityBase[] entityList, TextWriter stream, Vector3 min, Vector3 max)
|
||||
{
|
||||
XmlTextWriter writer = new XmlTextWriter(stream);
|
||||
|
||||
int primCount = 0;
|
||||
stream.WriteLine("<scene>\n");
|
||||
|
||||
foreach (EntityBase ent in entityList)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
SceneObjectGroup g = (SceneObjectGroup)ent;
|
||||
if (!min.Equals(Vector3.Zero) || !max.Equals(Vector3.Zero))
|
||||
{
|
||||
Vector3 pos = g.RootPart.GetWorldPosition();
|
||||
if (min.X > pos.X || min.Y > pos.Y || min.Z > pos.Z)
|
||||
continue;
|
||||
if (max.X < pos.X || max.Y < pos.Y || max.Z < pos.Z)
|
||||
continue;
|
||||
}
|
||||
|
||||
//stream.WriteLine(SceneObjectSerializer.ToXml2Format(g));
|
||||
SceneObjectSerializer.SOGToXml2(writer, (SceneObjectGroup)ent);
|
||||
stream.WriteLine();
|
||||
|
||||
primCount++;
|
||||
}
|
||||
}
|
||||
|
||||
stream.WriteLine("</scene>\n");
|
||||
stream.Flush();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user