diff options
author | opensim mirror account | 2010-10-15 17:30:05 -0700 |
---|---|---|
committer | opensim mirror account | 2010-10-15 17:30:05 -0700 |
commit | 06b17841e2e8b3677153e3209667ed92fb731260 (patch) | |
tree | e343f5115c50c8dbae730a15c41a0d62f5b9f74d | |
parent | Merge branch 'master' of /var/git/opensim/ (diff) | |
parent | Made OARs use the new serialization procedure. (TPs/crossings still on the ol... (diff) | |
download | opensim-SC-06b17841e2e8b3677153e3209667ed92fb731260.zip opensim-SC-06b17841e2e8b3677153e3209667ed92fb731260.tar.gz opensim-SC-06b17841e2e8b3677153e3209667ed92fb731260.tar.bz2 opensim-SC-06b17841e2e8b3677153e3209667ed92fb731260.tar.xz |
Merge branch 'master' of /var/git/opensim/
11 files changed, 189 insertions, 143 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index bb0a5b5..aeed467 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | |||
@@ -2284,7 +2284,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
2284 | if (archiver != null) | 2284 | if (archiver != null) |
2285 | { | 2285 | { |
2286 | scene.EventManager.OnOarFileSaved += RemoteAdminOarSaveCompleted; | 2286 | scene.EventManager.OnOarFileSaved += RemoteAdminOarSaveCompleted; |
2287 | archiver.ArchiveRegion(filename); | 2287 | archiver.ArchiveRegion(filename, new Dictionary<string, object>()); |
2288 | lock (m_saveOarLock) Monitor.Wait(m_saveOarLock,5000); | 2288 | lock (m_saveOarLock) Monitor.Wait(m_saveOarLock,5000); |
2289 | scene.EventManager.OnOarFileSaved -= RemoteAdminOarSaveCompleted; | 2289 | scene.EventManager.OnOarFileSaved -= RemoteAdminOarSaveCompleted; |
2290 | } | 2290 | } |
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 7a0142f..0c6f476 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs | |||
@@ -264,10 +264,11 @@ namespace OpenSim | |||
264 | LoadOar); | 264 | LoadOar); |
265 | 265 | ||
266 | m_console.Commands.AddCommand("region", false, "save oar", | 266 | m_console.Commands.AddCommand("region", false, "save oar", |
267 | "save oar [<OAR path>]", | 267 | "save oar [--old-guids] [<OAR path>]", |
268 | "Save a region's data to an OAR archive.", | 268 | "Save a region's data to an OAR archive.", |
269 | "The OAR path must be a filesystem path." | 269 | "The OAR path must be a filesystem path." |
270 | + " If this is not given then the oar is saved to region.oar in the current directory.", | 270 | + " If this is not given then the oar is saved to region.oar in the current directory." + Environment.NewLine |
271 | + "--old-guids produces OARs compatible with older (pre 0.7.1) OpenSim versions.", | ||
271 | SaveOar); | 272 | SaveOar); |
272 | 273 | ||
273 | m_console.Commands.AddCommand("region", false, "edit scale", | 274 | m_console.Commands.AddCommand("region", false, "edit scale", |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs index 586d98e..eb9688d 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs | |||
@@ -60,6 +60,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
60 | protected Scene m_scene; | 60 | protected Scene m_scene; |
61 | protected TarArchiveWriter m_archiveWriter; | 61 | protected TarArchiveWriter m_archiveWriter; |
62 | protected Guid m_requestId; | 62 | protected Guid m_requestId; |
63 | protected Dictionary<string, object> m_options; | ||
63 | 64 | ||
64 | public ArchiveWriteRequestExecution( | 65 | public ArchiveWriteRequestExecution( |
65 | List<SceneObjectGroup> sceneObjects, | 66 | List<SceneObjectGroup> sceneObjects, |
@@ -67,7 +68,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
67 | IRegionSerialiserModule serialiser, | 68 | IRegionSerialiserModule serialiser, |
68 | Scene scene, | 69 | Scene scene, |
69 | TarArchiveWriter archiveWriter, | 70 | TarArchiveWriter archiveWriter, |
70 | Guid requestId) | 71 | Guid requestId, |
72 | Dictionary<string, object> options) | ||
71 | { | 73 | { |
72 | m_sceneObjects = sceneObjects; | 74 | m_sceneObjects = sceneObjects; |
73 | m_terrainModule = terrainModule; | 75 | m_terrainModule = terrainModule; |
@@ -75,6 +77,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
75 | m_scene = scene; | 77 | m_scene = scene; |
76 | m_archiveWriter = archiveWriter; | 78 | m_archiveWriter = archiveWriter; |
77 | m_requestId = requestId; | 79 | m_requestId = requestId; |
80 | m_options = options; | ||
78 | } | 81 | } |
79 | 82 | ||
80 | protected internal void ReceivedAllAssets( | 83 | protected internal void ReceivedAllAssets( |
@@ -145,7 +148,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
145 | { | 148 | { |
146 | //m_log.DebugFormat("[ARCHIVER]: Saving {0} {1}, {2}", entity.Name, entity.UUID, entity.GetType()); | 149 | //m_log.DebugFormat("[ARCHIVER]: Saving {0} {1}, {2}", entity.Name, entity.UUID, entity.GetType()); |
147 | 150 | ||
148 | string serializedObject = m_serialiser.SerializeGroupToXml2(sceneObject); | 151 | string serializedObject = m_serialiser.SerializeGroupToXml2(sceneObject, m_options); |
149 | m_archiveWriter.WriteFile(ArchiveHelpers.CreateObjectPath(sceneObject), serializedObject); | 152 | m_archiveWriter.WriteFile(ArchiveHelpers.CreateObjectPath(sceneObject), serializedObject); |
150 | } | 153 | } |
151 | 154 | ||
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs index 283b33b..e9a476c 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs | |||
@@ -98,7 +98,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
98 | /// Archive the region requested. | 98 | /// Archive the region requested. |
99 | /// </summary> | 99 | /// </summary> |
100 | /// <exception cref="System.IO.IOException">if there was an io problem with creating the file</exception> | 100 | /// <exception cref="System.IO.IOException">if there was an io problem with creating the file</exception> |
101 | public void ArchiveRegion() | 101 | public void ArchiveRegion(Dictionary<string, object> options) |
102 | { | 102 | { |
103 | Dictionary<UUID, AssetType> assetUuids = new Dictionary<UUID, AssetType>(); | 103 | Dictionary<UUID, AssetType> assetUuids = new Dictionary<UUID, AssetType>(); |
104 | 104 | ||
@@ -165,7 +165,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
165 | m_scene.RequestModuleInterface<IRegionSerialiserModule>(), | 165 | m_scene.RequestModuleInterface<IRegionSerialiserModule>(), |
166 | m_scene, | 166 | m_scene, |
167 | archiveWriter, | 167 | archiveWriter, |
168 | m_requestId); | 168 | m_requestId, |
169 | options); | ||
169 | 170 | ||
170 | new AssetsRequest( | 171 | new AssetsRequest( |
171 | new AssetsArchiver(archiveWriter), assetUuids, | 172 | new AssetsArchiver(archiveWriter), assetUuids, |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs index 82ede01..98bdcd0 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs | |||
@@ -122,37 +122,44 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
122 | /// <param name="cmdparams"></param> | 122 | /// <param name="cmdparams"></param> |
123 | public void HandleSaveOarConsoleCommand(string module, string[] cmdparams) | 123 | public void HandleSaveOarConsoleCommand(string module, string[] cmdparams) |
124 | { | 124 | { |
125 | Dictionary<string, object> options = new Dictionary<string, object>(); | ||
126 | |||
127 | OptionSet ops = new OptionSet(); | ||
128 | ops.Add("old|old-guids", delegate(string v) { options["old-guids"] = (v != null); }); | ||
129 | |||
130 | List<string> mainParams = ops.Parse(cmdparams); | ||
131 | |||
125 | if (cmdparams.Length > 2) | 132 | if (cmdparams.Length > 2) |
126 | { | 133 | { |
127 | ArchiveRegion(cmdparams[2]); | 134 | ArchiveRegion(mainParams[2], options); |
128 | } | 135 | } |
129 | else | 136 | else |
130 | { | 137 | { |
131 | ArchiveRegion(DEFAULT_OAR_BACKUP_FILENAME); | 138 | ArchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, options); |
132 | } | 139 | } |
133 | } | 140 | } |
134 | 141 | ||
135 | public void ArchiveRegion(string savePath) | 142 | public void ArchiveRegion(string savePath, Dictionary<string, object> options) |
136 | { | 143 | { |
137 | ArchiveRegion(savePath, Guid.Empty); | 144 | ArchiveRegion(savePath, Guid.Empty, options); |
138 | } | 145 | } |
139 | 146 | ||
140 | public void ArchiveRegion(string savePath, Guid requestId) | 147 | public void ArchiveRegion(string savePath, Guid requestId, Dictionary<string, object> options) |
141 | { | 148 | { |
142 | m_log.InfoFormat( | 149 | m_log.InfoFormat( |
143 | "[ARCHIVER]: Writing archive for region {0} to {1}", m_scene.RegionInfo.RegionName, savePath); | 150 | "[ARCHIVER]: Writing archive for region {0} to {1}", m_scene.RegionInfo.RegionName, savePath); |
144 | 151 | ||
145 | new ArchiveWriteRequestPreparation(m_scene, savePath, requestId).ArchiveRegion(); | 152 | new ArchiveWriteRequestPreparation(m_scene, savePath, requestId).ArchiveRegion(options); |
146 | } | 153 | } |
147 | 154 | ||
148 | public void ArchiveRegion(Stream saveStream) | 155 | public void ArchiveRegion(Stream saveStream) |
149 | { | 156 | { |
150 | ArchiveRegion(saveStream, Guid.Empty); | 157 | ArchiveRegion(saveStream, Guid.Empty); |
151 | } | 158 | } |
152 | 159 | ||
153 | public void ArchiveRegion(Stream saveStream, Guid requestId) | 160 | public void ArchiveRegion(Stream saveStream, Guid requestId) |
154 | { | 161 | { |
155 | new ArchiveWriteRequestPreparation(m_scene, saveStream, requestId).ArchiveRegion(); | 162 | new ArchiveWriteRequestPreparation(m_scene, saveStream, requestId).ArchiveRegion(new Dictionary<string, object>()); |
156 | } | 163 | } |
157 | 164 | ||
158 | public void DearchiveRegion(string loadPath) | 165 | public void DearchiveRegion(string loadPath) |
diff --git a/OpenSim/Region/CoreModules/World/Serialiser/SerialiserModule.cs b/OpenSim/Region/CoreModules/World/Serialiser/SerialiserModule.cs index 04062b0..ec97acd 100644 --- a/OpenSim/Region/CoreModules/World/Serialiser/SerialiserModule.cs +++ b/OpenSim/Region/CoreModules/World/Serialiser/SerialiserModule.cs | |||
@@ -160,9 +160,9 @@ namespace OpenSim.Region.CoreModules.World.Serialiser | |||
160 | return SceneXmlLoader.DeserializeGroupFromXml2(xmlString); | 160 | return SceneXmlLoader.DeserializeGroupFromXml2(xmlString); |
161 | } | 161 | } |
162 | 162 | ||
163 | public string SerializeGroupToXml2(SceneObjectGroup grp) | 163 | public string SerializeGroupToXml2(SceneObjectGroup grp, Dictionary<string, object> options) |
164 | { | 164 | { |
165 | return SceneXmlLoader.SaveGroupToXml2(grp); | 165 | return SceneXmlLoader.SaveGroupToXml2(grp, options); |
166 | } | 166 | } |
167 | 167 | ||
168 | public void SavePrimListToXml2(EntityBase[] entityList, string fileName) | 168 | public void SavePrimListToXml2(EntityBase[] entityList, string fileName) |
diff --git a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs index 799a448..49bd466 100644 --- a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs +++ b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs | |||
@@ -369,7 +369,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests | |||
369 | // Need to add the object to the scene so that the request to get script state succeeds | 369 | // Need to add the object to the scene so that the request to get script state succeeds |
370 | m_scene.AddSceneObject(so); | 370 | m_scene.AddSceneObject(so); |
371 | 371 | ||
372 | string xml2 = m_serialiserModule.SerializeGroupToXml2(so); | 372 | string xml2 = m_serialiserModule.SerializeGroupToXml2(so, new System.Collections.Generic.Dictionary<string,object>()); |
373 | 373 | ||
374 | XmlTextReader xtr = new XmlTextReader(new StringReader(xml2)); | 374 | XmlTextReader xtr = new XmlTextReader(new StringReader(xml2)); |
375 | xtr.ReadStartElement("SceneObjectGroup"); | 375 | xtr.ReadStartElement("SceneObjectGroup"); |
diff --git a/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs index 89e59d0..d8229de 100644 --- a/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | using System.IO; | 30 | using System.IO; |
30 | 31 | ||
31 | namespace OpenSim.Region.Framework.Interfaces | 32 | namespace OpenSim.Region.Framework.Interfaces |
@@ -46,7 +47,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
46 | /// the EventManager.OnOarFileSaved event. | 47 | /// the EventManager.OnOarFileSaved event. |
47 | /// | 48 | /// |
48 | /// <param name="savePath"></param> | 49 | /// <param name="savePath"></param> |
49 | void ArchiveRegion(string savePath); | 50 | void ArchiveRegion(string savePath, Dictionary<string, object> options); |
50 | 51 | ||
51 | /// <summary> | 52 | /// <summary> |
52 | /// Archive the region to the given path | 53 | /// Archive the region to the given path |
@@ -57,7 +58,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
57 | /// | 58 | /// |
58 | /// <param name="savePath"></param> | 59 | /// <param name="savePath"></param> |
59 | /// <param name="requestId">If supplied, this request Id is later returned in the saved event</param> | 60 | /// <param name="requestId">If supplied, this request Id is later returned in the saved event</param> |
60 | void ArchiveRegion(string savePath, Guid requestId); | 61 | void ArchiveRegion(string savePath, Guid requestId, Dictionary<string, object> options); |
61 | 62 | ||
62 | /// <summary> | 63 | /// <summary> |
63 | /// Archive the region to a stream. | 64 | /// Archive the region to a stream. |
diff --git a/OpenSim/Region/Framework/Interfaces/IRegionSerialiserModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionSerialiserModule.cs index 18758c8..c5b21a8 100644 --- a/OpenSim/Region/Framework/Interfaces/IRegionSerialiserModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IRegionSerialiserModule.cs | |||
@@ -117,6 +117,6 @@ namespace OpenSim.Region.Framework.Interfaces | |||
117 | /// </summary> | 117 | /// </summary> |
118 | /// <param name="grp"></param> | 118 | /// <param name="grp"></param> |
119 | /// <returns></returns> | 119 | /// <returns></returns> |
120 | string SerializeGroupToXml2(SceneObjectGroup grp); | 120 | string SerializeGroupToXml2(SceneObjectGroup grp, Dictionary<string, object> options); |
121 | } | 121 | } |
122 | } | 122 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 6e3b15a..9a00bea 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | |||
@@ -1075,36 +1075,36 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1075 | 1075 | ||
1076 | ////////// Write ///////// | 1076 | ////////// Write ///////// |
1077 | 1077 | ||
1078 | public static void SOGToXml2(XmlTextWriter writer, SceneObjectGroup sog) | 1078 | public static void SOGToXml2(XmlTextWriter writer, SceneObjectGroup sog, Dictionary<string, object>options) |
1079 | { | 1079 | { |
1080 | writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); | 1080 | writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); |
1081 | SOPToXml2(writer, sog.RootPart, null); | 1081 | SOPToXml2(writer, sog.RootPart, null, options); |
1082 | writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); | 1082 | writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); |
1083 | 1083 | ||
1084 | sog.ForEachPart(delegate(SceneObjectPart sop) | 1084 | sog.ForEachPart(delegate(SceneObjectPart sop) |
1085 | { | 1085 | { |
1086 | if (sop.UUID != sog.RootPart.UUID) | 1086 | if (sop.UUID != sog.RootPart.UUID) |
1087 | SOPToXml2(writer, sop, sog.RootPart); | 1087 | SOPToXml2(writer, sop, sog.RootPart, options); |
1088 | }); | 1088 | }); |
1089 | 1089 | ||
1090 | writer.WriteEndElement(); | 1090 | writer.WriteEndElement(); |
1091 | writer.WriteEndElement(); | 1091 | writer.WriteEndElement(); |
1092 | } | 1092 | } |
1093 | 1093 | ||
1094 | static void SOPToXml2(XmlTextWriter writer, SceneObjectPart sop, SceneObjectPart parent) | 1094 | static void SOPToXml2(XmlTextWriter writer, SceneObjectPart sop, SceneObjectPart parent, Dictionary<string, object> options) |
1095 | { | 1095 | { |
1096 | writer.WriteStartElement("SceneObjectPart"); | 1096 | writer.WriteStartElement("SceneObjectPart"); |
1097 | writer.WriteAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); | 1097 | writer.WriteAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); |
1098 | writer.WriteAttributeString("xmlns:xsd", "http://www.w3.org/2001/XMLSchema"); | 1098 | writer.WriteAttributeString("xmlns:xsd", "http://www.w3.org/2001/XMLSchema"); |
1099 | 1099 | ||
1100 | writer.WriteElementString("AllowedDrop", sop.AllowedDrop.ToString().ToLower()); | 1100 | writer.WriteElementString("AllowedDrop", sop.AllowedDrop.ToString().ToLower()); |
1101 | WriteUUID(writer, "CreatorID", sop.CreatorID); | 1101 | WriteUUID(writer, "CreatorID", sop.CreatorID, options); |
1102 | WriteUUID(writer, "FolderID", sop.FolderID); | 1102 | WriteUUID(writer, "FolderID", sop.FolderID, options); |
1103 | writer.WriteElementString("InventorySerial", sop.InventorySerial.ToString()); | 1103 | writer.WriteElementString("InventorySerial", sop.InventorySerial.ToString()); |
1104 | 1104 | ||
1105 | WriteTaskInventory(writer, sop.TaskInventory); | 1105 | WriteTaskInventory(writer, sop.TaskInventory, options); |
1106 | 1106 | ||
1107 | WriteUUID(writer, "UUID", sop.UUID); | 1107 | WriteUUID(writer, "UUID", sop.UUID, options); |
1108 | writer.WriteElementString("LocalId", sop.LocalId.ToString()); | 1108 | writer.WriteElementString("LocalId", sop.LocalId.ToString()); |
1109 | writer.WriteElementString("Name", sop.Name); | 1109 | writer.WriteElementString("Name", sop.Name); |
1110 | writer.WriteElementString("Material", sop.Material.ToString()); | 1110 | writer.WriteElementString("Material", sop.Material.ToString()); |
@@ -1137,7 +1137,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1137 | writer.WriteElementString("LinkNum", sop.LinkNum.ToString()); | 1137 | writer.WriteElementString("LinkNum", sop.LinkNum.ToString()); |
1138 | writer.WriteElementString("ClickAction", sop.ClickAction.ToString()); | 1138 | writer.WriteElementString("ClickAction", sop.ClickAction.ToString()); |
1139 | 1139 | ||
1140 | WriteShape(writer, sop.Shape); | 1140 | WriteShape(writer, sop.Shape, options); |
1141 | 1141 | ||
1142 | WriteVector(writer, "Scale", sop.Scale); | 1142 | WriteVector(writer, "Scale", sop.Scale); |
1143 | writer.WriteElementString("UpdateFlag", sop.UpdateFlag.ToString()); | 1143 | writer.WriteElementString("UpdateFlag", sop.UpdateFlag.ToString()); |
@@ -1151,16 +1151,16 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1151 | writer.WriteElementString("SalePrice", sop.SalePrice.ToString()); | 1151 | writer.WriteElementString("SalePrice", sop.SalePrice.ToString()); |
1152 | writer.WriteElementString("ObjectSaleType", sop.ObjectSaleType.ToString()); | 1152 | writer.WriteElementString("ObjectSaleType", sop.ObjectSaleType.ToString()); |
1153 | writer.WriteElementString("OwnershipCost", sop.OwnershipCost.ToString()); | 1153 | writer.WriteElementString("OwnershipCost", sop.OwnershipCost.ToString()); |
1154 | WriteUUID(writer, "GroupID", sop.GroupID); | 1154 | WriteUUID(writer, "GroupID", sop.GroupID, options); |
1155 | WriteUUID(writer, "OwnerID", sop.OwnerID); | 1155 | WriteUUID(writer, "OwnerID", sop.OwnerID, options); |
1156 | WriteUUID(writer, "LastOwnerID", sop.LastOwnerID); | 1156 | WriteUUID(writer, "LastOwnerID", sop.LastOwnerID, options); |
1157 | writer.WriteElementString("BaseMask", sop.BaseMask.ToString()); | 1157 | writer.WriteElementString("BaseMask", sop.BaseMask.ToString()); |
1158 | writer.WriteElementString("OwnerMask", sop.OwnerMask.ToString()); | 1158 | writer.WriteElementString("OwnerMask", sop.OwnerMask.ToString()); |
1159 | writer.WriteElementString("GroupMask", sop.GroupMask.ToString()); | 1159 | writer.WriteElementString("GroupMask", sop.GroupMask.ToString()); |
1160 | writer.WriteElementString("EveryoneMask", sop.EveryoneMask.ToString()); | 1160 | writer.WriteElementString("EveryoneMask", sop.EveryoneMask.ToString()); |
1161 | writer.WriteElementString("NextOwnerMask", sop.NextOwnerMask.ToString()); | 1161 | writer.WriteElementString("NextOwnerMask", sop.NextOwnerMask.ToString()); |
1162 | writer.WriteElementString("Flags", sop.Flags.ToString()); | 1162 | writer.WriteElementString("Flags", sop.Flags.ToString()); |
1163 | WriteUUID(writer, "CollisionSound", sop.CollisionSound); | 1163 | WriteUUID(writer, "CollisionSound", sop.CollisionSound, options); |
1164 | writer.WriteElementString("CollisionSoundVolume", sop.CollisionSoundVolume.ToString()); | 1164 | writer.WriteElementString("CollisionSoundVolume", sop.CollisionSoundVolume.ToString()); |
1165 | if (sop.MediaUrl != null) | 1165 | if (sop.MediaUrl != null) |
1166 | writer.WriteElementString("MediaUrl", sop.MediaUrl.ToString()); | 1166 | writer.WriteElementString("MediaUrl", sop.MediaUrl.ToString()); |
@@ -1168,10 +1168,13 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1168 | writer.WriteEndElement(); | 1168 | writer.WriteEndElement(); |
1169 | } | 1169 | } |
1170 | 1170 | ||
1171 | static void WriteUUID(XmlTextWriter writer, string name, UUID id) | 1171 | static void WriteUUID(XmlTextWriter writer, string name, UUID id, Dictionary<string, object> options) |
1172 | { | 1172 | { |
1173 | writer.WriteStartElement(name); | 1173 | writer.WriteStartElement(name); |
1174 | writer.WriteElementString("UUID", id.ToString()); | 1174 | if (options.ContainsKey("old-guids")) |
1175 | writer.WriteElementString("Guid", id.ToString()); | ||
1176 | else | ||
1177 | writer.WriteElementString("UUID", id.ToString()); | ||
1175 | writer.WriteEndElement(); | 1178 | writer.WriteEndElement(); |
1176 | } | 1179 | } |
1177 | 1180 | ||
@@ -1194,7 +1197,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1194 | writer.WriteEndElement(); | 1197 | writer.WriteEndElement(); |
1195 | } | 1198 | } |
1196 | 1199 | ||
1197 | static void WriteTaskInventory(XmlTextWriter writer, TaskInventoryDictionary tinv) | 1200 | static void WriteTaskInventory(XmlTextWriter writer, TaskInventoryDictionary tinv, Dictionary<string, object> options) |
1198 | { | 1201 | { |
1199 | if (tinv.Count > 0) // otherwise skip this | 1202 | if (tinv.Count > 0) // otherwise skip this |
1200 | { | 1203 | { |
@@ -1203,27 +1206,27 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1203 | foreach (TaskInventoryItem item in tinv.Values) | 1206 | foreach (TaskInventoryItem item in tinv.Values) |
1204 | { | 1207 | { |
1205 | writer.WriteStartElement("TaskInventoryItem"); | 1208 | writer.WriteStartElement("TaskInventoryItem"); |
1206 | 1209 | ||
1207 | WriteUUID(writer, "AssetID", item.AssetID); | 1210 | WriteUUID(writer, "AssetID", item.AssetID, options); |
1208 | writer.WriteElementString("BasePermissions", item.BasePermissions.ToString()); | 1211 | writer.WriteElementString("BasePermissions", item.BasePermissions.ToString()); |
1209 | writer.WriteElementString("CreationDate", item.CreationDate.ToString()); | 1212 | writer.WriteElementString("CreationDate", item.CreationDate.ToString()); |
1210 | WriteUUID(writer, "CreatorID", item.CreatorID); | 1213 | WriteUUID(writer, "CreatorID", item.CreatorID, options); |
1211 | writer.WriteElementString("Description", item.Description); | 1214 | writer.WriteElementString("Description", item.Description); |
1212 | writer.WriteElementString("EveryonePermissions", item.EveryonePermissions.ToString()); | 1215 | writer.WriteElementString("EveryonePermissions", item.EveryonePermissions.ToString()); |
1213 | writer.WriteElementString("Flags", item.Flags.ToString()); | 1216 | writer.WriteElementString("Flags", item.Flags.ToString()); |
1214 | WriteUUID(writer, "GroupID", item.GroupID); | 1217 | WriteUUID(writer, "GroupID", item.GroupID, options); |
1215 | writer.WriteElementString("GroupPermissions", item.GroupPermissions.ToString()); | 1218 | writer.WriteElementString("GroupPermissions", item.GroupPermissions.ToString()); |
1216 | writer.WriteElementString("InvType", item.InvType.ToString()); | 1219 | writer.WriteElementString("InvType", item.InvType.ToString()); |
1217 | WriteUUID(writer, "ItemID", item.ItemID); | 1220 | WriteUUID(writer, "ItemID", item.ItemID, options); |
1218 | WriteUUID(writer, "OldItemID", item.OldItemID); | 1221 | WriteUUID(writer, "OldItemID", item.OldItemID, options); |
1219 | WriteUUID(writer, "LastOwnerID", item.LastOwnerID); | 1222 | WriteUUID(writer, "LastOwnerID", item.LastOwnerID, options); |
1220 | writer.WriteElementString("Name", item.Name); | 1223 | writer.WriteElementString("Name", item.Name); |
1221 | writer.WriteElementString("NextPermissions", item.NextPermissions.ToString()); | 1224 | writer.WriteElementString("NextPermissions", item.NextPermissions.ToString()); |
1222 | WriteUUID(writer, "OwnerID", item.OwnerID); | 1225 | WriteUUID(writer, "OwnerID", item.OwnerID, options); |
1223 | writer.WriteElementString("CurrentPermissions", item.CurrentPermissions.ToString()); | 1226 | writer.WriteElementString("CurrentPermissions", item.CurrentPermissions.ToString()); |
1224 | WriteUUID(writer, "ParentID", item.ParentID); | 1227 | WriteUUID(writer, "ParentID", item.ParentID, options); |
1225 | WriteUUID(writer, "ParentPartID", item.ParentPartID); | 1228 | WriteUUID(writer, "ParentPartID", item.ParentPartID, options); |
1226 | WriteUUID(writer, "PermsGranter", item.PermsGranter); | 1229 | WriteUUID(writer, "PermsGranter", item.PermsGranter, options); |
1227 | writer.WriteElementString("PermsMask", item.PermsMask.ToString()); | 1230 | writer.WriteElementString("PermsMask", item.PermsMask.ToString()); |
1228 | writer.WriteElementString("Type", item.Type.ToString()); | 1231 | writer.WriteElementString("Type", item.Type.ToString()); |
1229 | 1232 | ||
@@ -1234,7 +1237,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1234 | } | 1237 | } |
1235 | } | 1238 | } |
1236 | 1239 | ||
1237 | static void WriteShape(XmlTextWriter writer, PrimitiveBaseShape shp) | 1240 | static void WriteShape(XmlTextWriter writer, PrimitiveBaseShape shp, Dictionary<string, object> options) |
1238 | { | 1241 | { |
1239 | if (shp != null) | 1242 | if (shp != null) |
1240 | { | 1243 | { |
@@ -1283,7 +1286,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1283 | writer.WriteElementString("ProfileShape", shp.ProfileShape.ToString()); | 1286 | writer.WriteElementString("ProfileShape", shp.ProfileShape.ToString()); |
1284 | writer.WriteElementString("HollowShape", shp.HollowShape.ToString()); | 1287 | writer.WriteElementString("HollowShape", shp.HollowShape.ToString()); |
1285 | 1288 | ||
1286 | WriteUUID(writer, "SculptTexture", shp.SculptTexture); | 1289 | WriteUUID(writer, "SculptTexture", shp.SculptTexture, options); |
1287 | writer.WriteElementString("SculptType", shp.SculptType.ToString()); | 1290 | writer.WriteElementString("SculptType", shp.SculptType.ToString()); |
1288 | writer.WriteStartElement("SculptData"); | 1291 | writer.WriteStartElement("SculptData"); |
1289 | byte[] sd; | 1292 | byte[] sd; |
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs index c6d4e55..d214eba 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs | |||
@@ -45,6 +45,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
45 | { | 45 | { |
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | 47 | ||
48 | #region old xml format | ||
48 | public static void LoadPrimsFromXml(Scene scene, string fileName, bool newIDS, Vector3 loadOffset) | 49 | public static void LoadPrimsFromXml(Scene scene, string fileName, bool newIDS, Vector3 loadOffset) |
49 | { | 50 | { |
50 | XmlDocument doc = new XmlDocument(); | 51 | XmlDocument doc = new XmlDocument(); |
@@ -98,11 +99,128 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
98 | file.Close(); | 99 | file.Close(); |
99 | } | 100 | } |
100 | 101 | ||
101 | public static string SaveGroupToXml2(SceneObjectGroup grp) | 102 | #endregion |
103 | |||
104 | #region XML2 serialization | ||
105 | |||
106 | // Called by archives (save oar) | ||
107 | public static string SaveGroupToXml2(SceneObjectGroup grp, Dictionary<string, object> options) | ||
108 | { | ||
109 | //return SceneObjectSerializer.ToXml2Format(grp); | ||
110 | using (MemoryStream mem = new MemoryStream()) | ||
111 | { | ||
112 | using (XmlTextWriter writer = new XmlTextWriter(mem, System.Text.Encoding.UTF8)) | ||
113 | { | ||
114 | SceneObjectSerializer.SOGToXml2(writer, grp, options); | ||
115 | writer.Flush(); | ||
116 | |||
117 | using (StreamReader reader = new StreamReader(mem)) | ||
118 | { | ||
119 | mem.Seek(0, SeekOrigin.Begin); | ||
120 | return reader.ReadToEnd(); | ||
121 | } | ||
122 | } | ||
123 | } | ||
124 | } | ||
125 | |||
126 | // Called by scene serializer (save xml2) | ||
127 | public static void SavePrimsToXml2(Scene scene, string fileName) | ||
128 | { | ||
129 | EntityBase[] entityList = scene.GetEntities(); | ||
130 | SavePrimListToXml2(entityList, fileName); | ||
131 | } | ||
132 | |||
133 | // Called by scene serializer (save xml2) | ||
134 | public static void SaveNamedPrimsToXml2(Scene scene, string primName, string fileName) | ||
135 | { | ||
136 | m_log.InfoFormat( | ||
137 | "[SERIALISER]: Saving prims with name {0} in xml2 format for region {1} to {2}", | ||
138 | primName, scene.RegionInfo.RegionName, fileName); | ||
139 | |||
140 | EntityBase[] entityList = scene.GetEntities(); | ||
141 | List<EntityBase> primList = new List<EntityBase>(); | ||
142 | |||
143 | foreach (EntityBase ent in entityList) | ||
144 | { | ||
145 | if (ent is SceneObjectGroup) | ||
146 | { | ||
147 | if (ent.Name == primName) | ||
148 | { | ||
149 | primList.Add(ent); | ||
150 | } | ||
151 | } | ||
152 | } | ||
153 | |||
154 | SavePrimListToXml2(primList.ToArray(), fileName); | ||
155 | } | ||
156 | |||
157 | // Called by REST Application plugin | ||
158 | public static void SavePrimsToXml2(Scene scene, TextWriter stream, Vector3 min, Vector3 max) | ||
159 | { | ||
160 | EntityBase[] entityList = scene.GetEntities(); | ||
161 | SavePrimListToXml2(entityList, stream, min, max); | ||
162 | } | ||
163 | |||
164 | // Called here only. Should be private? | ||
165 | public static void SavePrimListToXml2(EntityBase[] entityList, string fileName) | ||
102 | { | 166 | { |
103 | return SceneObjectSerializer.ToXml2Format(grp); | 167 | FileStream file = new FileStream(fileName, FileMode.Create); |
168 | try | ||
169 | { | ||
170 | StreamWriter stream = new StreamWriter(file); | ||
171 | try | ||
172 | { | ||
173 | SavePrimListToXml2(entityList, stream, Vector3.Zero, Vector3.Zero); | ||
174 | } | ||
175 | finally | ||
176 | { | ||
177 | stream.Close(); | ||
178 | } | ||
179 | } | ||
180 | finally | ||
181 | { | ||
182 | file.Close(); | ||
183 | } | ||
184 | } | ||
185 | |||
186 | // Called here only. Should be private? | ||
187 | public static void SavePrimListToXml2(EntityBase[] entityList, TextWriter stream, Vector3 min, Vector3 max) | ||
188 | { | ||
189 | XmlTextWriter writer = new XmlTextWriter(stream); | ||
190 | |||
191 | int primCount = 0; | ||
192 | stream.WriteLine("<scene>\n"); | ||
193 | |||
194 | foreach (EntityBase ent in entityList) | ||
195 | { | ||
196 | if (ent is SceneObjectGroup) | ||
197 | { | ||
198 | SceneObjectGroup g = (SceneObjectGroup)ent; | ||
199 | if (!min.Equals(Vector3.Zero) || !max.Equals(Vector3.Zero)) | ||
200 | { | ||
201 | Vector3 pos = g.RootPart.GetWorldPosition(); | ||
202 | if (min.X > pos.X || min.Y > pos.Y || min.Z > pos.Z) | ||
203 | continue; | ||
204 | if (max.X < pos.X || max.Y < pos.Y || max.Z < pos.Z) | ||
205 | continue; | ||
206 | } | ||
207 | |||
208 | //stream.WriteLine(SceneObjectSerializer.ToXml2Format(g)); | ||
209 | SceneObjectSerializer.SOGToXml2(writer, (SceneObjectGroup)ent, new Dictionary<string,object>()); | ||
210 | stream.WriteLine(); | ||
211 | |||
212 | primCount++; | ||
213 | } | ||
214 | } | ||
215 | |||
216 | stream.WriteLine("</scene>\n"); | ||
217 | stream.Flush(); | ||
104 | } | 218 | } |
105 | 219 | ||
220 | #endregion | ||
221 | |||
222 | #region XML2 deserialization | ||
223 | |||
106 | public static SceneObjectGroup DeserializeGroupFromXml2(string xmlString) | 224 | public static SceneObjectGroup DeserializeGroupFromXml2(string xmlString) |
107 | { | 225 | { |
108 | XmlDocument doc = new XmlDocument(); | 226 | XmlDocument doc = new XmlDocument(); |
@@ -222,94 +340,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
222 | } | 340 | } |
223 | } | 341 | } |
224 | 342 | ||
225 | public static void SavePrimsToXml2(Scene scene, string fileName) | 343 | #endregion |
226 | { | ||
227 | EntityBase[] entityList = scene.GetEntities(); | ||
228 | SavePrimListToXml2(entityList, fileName); | ||
229 | } | ||
230 | |||
231 | public static void SavePrimsToXml2(Scene scene, TextWriter stream, Vector3 min, Vector3 max) | ||
232 | { | ||
233 | EntityBase[] entityList = scene.GetEntities(); | ||
234 | SavePrimListToXml2(entityList, stream, min, max); | ||
235 | } | ||
236 | |||
237 | public static void SaveNamedPrimsToXml2(Scene scene, string primName, string fileName) | ||
238 | { | ||
239 | m_log.InfoFormat( | ||
240 | "[SERIALISER]: Saving prims with name {0} in xml2 format for region {1} to {2}", | ||
241 | primName, scene.RegionInfo.RegionName, fileName); | ||
242 | |||
243 | EntityBase[] entityList = scene.GetEntities(); | ||
244 | List<EntityBase> primList = new List<EntityBase>(); | ||
245 | |||
246 | foreach (EntityBase ent in entityList) | ||
247 | { | ||
248 | if (ent is SceneObjectGroup) | ||
249 | { | ||
250 | if (ent.Name == primName) | ||
251 | { | ||
252 | primList.Add(ent); | ||
253 | } | ||
254 | } | ||
255 | } | ||
256 | |||
257 | SavePrimListToXml2(primList.ToArray(), fileName); | ||
258 | } | ||
259 | |||
260 | public static void SavePrimListToXml2(EntityBase[] entityList, string fileName) | ||
261 | { | ||
262 | FileStream file = new FileStream(fileName, FileMode.Create); | ||
263 | try | ||
264 | { | ||
265 | StreamWriter stream = new StreamWriter(file); | ||
266 | try | ||
267 | { | ||
268 | SavePrimListToXml2(entityList, stream, Vector3.Zero, Vector3.Zero); | ||
269 | } | ||
270 | finally | ||
271 | { | ||
272 | stream.Close(); | ||
273 | } | ||
274 | } | ||
275 | finally | ||
276 | { | ||
277 | file.Close(); | ||
278 | } | ||
279 | } | ||
280 | |||
281 | public static void SavePrimListToXml2(EntityBase[] entityList, TextWriter stream, Vector3 min, Vector3 max) | ||
282 | { | ||
283 | XmlTextWriter writer = new XmlTextWriter(stream); | ||
284 | |||
285 | int primCount = 0; | ||
286 | stream.WriteLine("<scene>\n"); | ||
287 | |||
288 | foreach (EntityBase ent in entityList) | ||
289 | { | ||
290 | if (ent is SceneObjectGroup) | ||
291 | { | ||
292 | SceneObjectGroup g = (SceneObjectGroup)ent; | ||
293 | if (!min.Equals(Vector3.Zero) || !max.Equals(Vector3.Zero)) | ||
294 | { | ||
295 | Vector3 pos = g.RootPart.GetWorldPosition(); | ||
296 | if (min.X > pos.X || min.Y > pos.Y || min.Z > pos.Z) | ||
297 | continue; | ||
298 | if (max.X < pos.X || max.Y < pos.Y || max.Z < pos.Z) | ||
299 | continue; | ||
300 | } | ||
301 | |||
302 | //stream.WriteLine(SceneObjectSerializer.ToXml2Format(g)); | ||
303 | SceneObjectSerializer.SOGToXml2(writer, (SceneObjectGroup)ent); | ||
304 | stream.WriteLine(); | ||
305 | |||
306 | primCount++; | ||
307 | } | ||
308 | } | ||
309 | |||
310 | stream.WriteLine("</scene>\n"); | ||
311 | stream.Flush(); | ||
312 | } | ||
313 | |||
314 | } | 344 | } |
315 | } | 345 | } |