aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/DataSnapshot/ObjectSnapshot.cs')
-rw-r--r--OpenSim/Region/DataSnapshot/ObjectSnapshot.cs83
1 files changed, 83 insertions, 0 deletions
diff --git a/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs b/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs
new file mode 100644
index 0000000..9222b48
--- /dev/null
+++ b/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs
@@ -0,0 +1,83 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Xml;
5using System.Reflection;
6using OpenSim.Region.Environment.Scenes;
7using OpenSim.Framework;
8using libsecondlife;
9
10namespace OpenSim.Region.DataSnapshot
11{
12 public class ObjectSnapshot : IDataSnapshotProvider
13 {
14 private Scene m_scene = null;
15 private DataSnapshotManager m_parent = null;
16 private log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
17
18 public void Initialize(Scene scene, DataSnapshotManager parent)
19 {
20 m_scene = scene;
21 m_parent = parent;
22 }
23
24 public Scene GetParentScene
25 {
26 get { return m_scene; }
27 }
28
29 public XmlNode RequestSnapshotData(XmlDocument nodeFactory)
30 {
31 XmlNode parent = nodeFactory.CreateNode(XmlNodeType.Element, "objectdata", "");
32 XmlNode node;
33#if LIBSL_IS_FIXED
34 foreach (EntityBase entity in m_scene.Entities.Values)
35 {
36 // only objects, not avatars
37 if (entity is SceneObjectGroup)
38 {
39 SceneObjectGroup obj = (SceneObjectGroup)entity;
40
41 XmlNode xmlobject = nodeFactory.CreateNode(XmlNodeType.Element, "object", "");
42
43 node = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", "");
44 node.InnerText = obj.UUID.ToString();
45 xmlobject.AppendChild(node);
46
47 SceneObjectPart m_rootPart = null;
48 try
49 {
50 Type sog = typeof(SceneObjectGroup);
51 FieldInfo rootField = sog.GetField("m_rootPart", BindingFlags.NonPublic | BindingFlags.Instance);
52 if (rootField != null)
53 {
54 m_rootPart = (SceneObjectPart)rootField.GetValue(obj);
55 }
56 }
57 catch (Exception e)
58 {
59 Console.WriteLine("[DATASNAPSHOT] couldn't access field reflectively\n" + e.ToString());
60 }
61 if (m_rootPart != null)
62 {
63 node = nodeFactory.CreateNode(XmlNodeType.Element, "title", "");
64 node.InnerText = m_rootPart.Name;
65 xmlobject.AppendChild(node);
66
67 node = nodeFactory.CreateNode(XmlNodeType.Element, "description", "");
68 node.InnerText = m_rootPart.Description;
69 xmlobject.AppendChild(node);
70
71 node = nodeFactory.CreateNode(XmlNodeType.Element, "flags", "");
72 node.InnerText = String.Format("{0:x}", m_rootPart.ObjectFlags);
73 xmlobject.AppendChild(node);
74 }
75 parent.AppendChild(xmlobject);
76 }
77 }
78#endif
79 return parent;
80
81 }
82 }
83}