diff options
author | UbitUmarov | 2015-08-24 17:05:16 +0100 |
---|---|---|
committer | UbitUmarov | 2015-08-24 17:05:16 +0100 |
commit | 3829df10595911de9ed1ce2f7b6cdd205828f8d0 (patch) | |
tree | d95d15c35695f6fa4dc4a6623294b307a7aee493 /OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | |
parent | rename ImapTileModule as IMAPImageUploadModule to match core (diff) | |
download | opensim-SC_OLD-3829df10595911de9ed1ce2f7b6cdd205828f8d0.zip opensim-SC_OLD-3829df10595911de9ed1ce2f7b6cdd205828f8d0.tar.gz opensim-SC_OLD-3829df10595911de9ed1ce2f7b6cdd205828f8d0.tar.bz2 opensim-SC_OLD-3829df10595911de9ed1ce2f7b6cdd205828f8d0.tar.xz |
try to implement core load oar options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 40e88f1..3d14943 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | |||
@@ -299,6 +299,71 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
299 | } | 299 | } |
300 | } | 300 | } |
301 | 301 | ||
302 | /// <summary> | ||
303 | /// Modifies a SceneObjectGroup. | ||
304 | /// </summary> | ||
305 | /// <param name="sog">The object</param> | ||
306 | /// <returns>Whether the object was actually modified</returns> | ||
307 | public delegate bool SceneObjectModifier(SceneObjectGroup sog); | ||
308 | |||
309 | /// <summary> | ||
310 | /// Modifies an object by deserializing it; applying 'modifier' to each SceneObjectGroup; and reserializing. | ||
311 | /// </summary> | ||
312 | /// <param name="assetId">The object's UUID</param> | ||
313 | /// <param name="data">Serialized data</param> | ||
314 | /// <param name="modifier">The function to run on each SceneObjectGroup</param> | ||
315 | /// <returns>The new serialized object's data, or null if an error occurred</returns> | ||
316 | public static byte[] ModifySerializedObject(UUID assetId, byte[] data, SceneObjectModifier modifier) | ||
317 | { | ||
318 | List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>(); | ||
319 | CoalescedSceneObjects coa = null; | ||
320 | |||
321 | string xmlData = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(data)); | ||
322 | |||
323 | if (CoalescedSceneObjectsSerializer.TryFromXml(xmlData, out coa)) | ||
324 | { | ||
325 | // m_log.DebugFormat("[SERIALIZER]: Loaded coalescence {0} has {1} objects", assetId, coa.Count); | ||
326 | |||
327 | if (coa.Objects.Count == 0) | ||
328 | { | ||
329 | m_log.WarnFormat("[SERIALIZER]: Aborting load of coalesced object from asset {0} as it has zero loaded components", assetId); | ||
330 | return null; | ||
331 | } | ||
332 | |||
333 | sceneObjects.AddRange(coa.Objects); | ||
334 | } | ||
335 | else | ||
336 | { | ||
337 | SceneObjectGroup deserializedObject = FromOriginalXmlFormat(xmlData); | ||
338 | |||
339 | if (deserializedObject != null) | ||
340 | { | ||
341 | sceneObjects.Add(deserializedObject); | ||
342 | } | ||
343 | else | ||
344 | { | ||
345 | m_log.WarnFormat("[SERIALIZER]: Aborting load of object from asset {0} as deserialization failed", assetId); | ||
346 | return null; | ||
347 | } | ||
348 | } | ||
349 | |||
350 | bool modified = false; | ||
351 | foreach (SceneObjectGroup sog in sceneObjects) | ||
352 | { | ||
353 | if (modifier(sog)) | ||
354 | modified = true; | ||
355 | } | ||
356 | |||
357 | if (modified) | ||
358 | { | ||
359 | if (coa != null) | ||
360 | data = Utils.StringToBytes(CoalescedSceneObjectsSerializer.ToXml(coa)); | ||
361 | else | ||
362 | data = Utils.StringToBytes(ToOriginalXmlFormat(sceneObjects[0])); | ||
363 | } | ||
364 | |||
365 | return data; | ||
366 | } | ||
302 | 367 | ||
303 | #region manual serialization | 368 | #region manual serialization |
304 | 369 | ||