aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs
diff options
context:
space:
mode:
authorCharles Krinke2008-05-17 15:47:08 +0000
committerCharles Krinke2008-05-17 15:47:08 +0000
commitf6a4f8844f01fb756bbc26d65c252fc07ab8c2bf (patch)
treeda27e199a03ec4afd829a3ab9b06deab47cd02a3 /OpenSim/Region/DataSnapshot/ObjectSnapshot.cs
parentwhile this doesn't fix the initial no pants issue in grid (which still baffle... (diff)
downloadopensim-SC-f6a4f8844f01fb756bbc26d65c252fc07ab8c2bf.zip
opensim-SC-f6a4f8844f01fb756bbc26d65c252fc07ab8c2bf.tar.gz
opensim-SC-f6a4f8844f01fb756bbc26d65c252fc07ab8c2bf.tar.bz2
opensim-SC-f6a4f8844f01fb756bbc26d65c252fc07ab8c2bf.tar.xz
Thank you very much KMeisthax for DataSnapshot 1.1
to enhance search capability on OpenSim sims using external search engines such as Metaversink.com and others.
Diffstat (limited to 'OpenSim/Region/DataSnapshot/ObjectSnapshot.cs')
-rw-r--r--OpenSim/Region/DataSnapshot/ObjectSnapshot.cs134
1 files changed, 100 insertions, 34 deletions
diff --git a/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs b/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs
index 3270c3a..af73ba0 100644
--- a/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs
+++ b/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs
@@ -25,24 +25,63 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
29using System.Collections.Generic;
28using System.Reflection; 30using System.Reflection;
29using System.Xml; 31using System.Xml;
30using log4net; 32using log4net;
31using OpenSim.Region.DataSnapshot.Interfaces; 33using OpenSim.Region.DataSnapshot.Interfaces;
32using OpenSim.Region.Environment.Scenes; 34using OpenSim.Region.Environment.Scenes;
35using OpenSim.Framework;
36using libsecondlife;
33 37
34namespace OpenSim.Region.DataSnapshot 38namespace OpenSim.Region.DataSnapshot.Providers
35{ 39{
36 public class ObjectSnapshot : IDataSnapshotProvider 40 public class ObjectSnapshot : IDataSnapshotProvider
37 { 41 {
38 private Scene m_scene = null; 42 private Scene m_scene = null;
39 private DataSnapshotManager m_parent = null; 43 private DataSnapshotManager m_parent = null;
40 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 private bool m_stale = true;
41 46
42 public void Initialize(Scene scene, DataSnapshotManager parent) 47 public void Initialize(Scene scene, DataSnapshotManager parent)
43 { 48 {
44 m_scene = scene; 49 m_scene = scene;
45 m_parent = parent; 50 m_parent = parent;
51
52 //To check for staleness, we must catch all incoming client packets.
53 m_scene.EventManager.OnNewClient += OnNewClient;
54 m_scene.EventManager.OnParcelPrimCountAdd += delegate(SceneObjectGroup obj) { this.Stale = true; };
55 }
56
57 public void OnNewClient(IClientAPI client)
58 {
59 //Detect object data changes by hooking into the IClientAPI.
60 //Very dirty, and breaks whenever someone changes the client API.
61
62 client.OnAddPrim += delegate (LLUUID ownerID, LLVector3 RayEnd, LLQuaternion rot,
63 PrimitiveBaseShape shape, byte bypassRaycast, LLVector3 RayStart, LLUUID RayTargetID,
64 byte RayEndIsIntersection) { this.Stale = true; };
65 client.OnLinkObjects += delegate (IClientAPI remoteClient, uint parent, List<uint> children)
66 { this.Stale = true; };
67 client.OnDelinkObjects += delegate(List<uint> primIds) { this.Stale = true; };
68 client.OnGrabUpdate += delegate(LLUUID objectID, LLVector3 offset, LLVector3 grapPos,
69 IClientAPI remoteClient) { this.Stale = true; };
70 client.OnObjectAttach += delegate(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt,
71 LLQuaternion rot) { this.Stale = true; };
72 client.OnObjectDuplicate += delegate(uint localID, LLVector3 offset, uint dupeFlags, LLUUID AgentID,
73 LLUUID GroupID) { this.Stale = true; };
74 client.OnObjectDuplicateOnRay += delegate(uint localID, uint dupeFlags, LLUUID AgentID, LLUUID GroupID,
75 LLUUID RayTargetObj, LLVector3 RayEnd, LLVector3 RayStart, bool BypassRaycast,
76 bool RayEndIsIntersection, bool CopyCenters, bool CopyRotates) { this.Stale = true; };
77 client.OnObjectIncludeInSearch += delegate(IClientAPI remoteClient, bool IncludeInSearch, uint localID)
78 { this.Stale = true; };
79 client.OnObjectPermissions += delegate(IClientAPI controller, LLUUID agentID, LLUUID sessionID,
80 byte field, uint localId, uint mask, byte set) { this.Stale = true; };
81 client.OnRezObject += delegate(IClientAPI remoteClient, LLUUID itemID, LLVector3 RayEnd,
82 LLVector3 RayStart, LLUUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
83 uint EveryoneMask, uint GroupMask, uint NextOwnerMask, uint ItemFlags, bool RezSelected,
84 bool RemoveItem, LLUUID fromTaskID) { this.Stale = true; };
46 } 85 }
47 86
48 public Scene GetParentScene 87 public Scene GetParentScene
@@ -52,56 +91,83 @@ namespace OpenSim.Region.DataSnapshot
52 91
53 public XmlNode RequestSnapshotData(XmlDocument nodeFactory) 92 public XmlNode RequestSnapshotData(XmlDocument nodeFactory)
54 { 93 {
94 m_log.Debug("[DATASNAPSHOT]: Generating object data for scene " + m_scene.RegionInfo.RegionName);
95
55 XmlNode parent = nodeFactory.CreateNode(XmlNodeType.Element, "objectdata", ""); 96 XmlNode parent = nodeFactory.CreateNode(XmlNodeType.Element, "objectdata", "");
56 XmlNode node; 97 XmlNode node;
57#if LIBSL_IS_FIXED 98
58 foreach (EntityBase entity in m_scene.Entities.Values) 99 foreach (EntityBase entity in m_scene.Entities.Values)
59 { 100 {
60 // only objects, not avatars 101 // only objects, not avatars
61 if (entity is SceneObjectGroup) 102 if (entity is SceneObjectGroup)
62 { 103 {
63 SceneObjectGroup obj = (SceneObjectGroup)entity; 104 SceneObjectGroup obj = (SceneObjectGroup)entity;
64 105
65 XmlNode xmlobject = nodeFactory.CreateNode(XmlNodeType.Element, "object", ""); 106 m_log.Debug("[DATASNAPSHOT]: Found object " + obj.Name + " in scene");
66 107
67 node = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", ""); 108 if ((obj.RootPart.Flags & LLObject.ObjectFlags.JointWheel) == LLObject.ObjectFlags.JointWheel) {
68 node.InnerText = obj.UUID.ToString(); 109 XmlNode xmlobject = nodeFactory.CreateNode(XmlNodeType.Element, "object", "");
69 xmlobject.AppendChild(node);
70 110
71 SceneObjectPart m_rootPart = null; 111 node = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", "");
72 try 112 node.InnerText = obj.UUID.ToString();
73 {
74 Type sog = typeof(SceneObjectGroup);
75 FieldInfo rootField = sog.GetField("m_rootPart", BindingFlags.NonPublic | BindingFlags.Instance);
76 if (rootField != null)
77 {
78 m_rootPart = (SceneObjectPart)rootField.GetValue(obj);
79 }
80 }
81 catch (Exception e)
82 {
83 Console.WriteLine("[DATASNAPSHOT] couldn't access field reflectively\n" + e.ToString());
84 }
85 if (m_rootPart != null)
86 {
87 node = nodeFactory.CreateNode(XmlNodeType.Element, "title", "");
88 node.InnerText = m_rootPart.Name;
89 xmlobject.AppendChild(node); 113 xmlobject.AppendChild(node);
90 114
91 node = nodeFactory.CreateNode(XmlNodeType.Element, "description", ""); 115 SceneObjectPart m_rootPart = null;
92 node.InnerText = m_rootPart.Description; 116 try
93 xmlobject.AppendChild(node); 117 {
118 Type sog = typeof(SceneObjectGroup);
119 FieldInfo rootField = sog.GetField("m_rootPart", BindingFlags.NonPublic | BindingFlags.Instance);
120 if (rootField != null)
121 {
122 m_rootPart = (SceneObjectPart)rootField.GetValue(obj);
123 }
124 }
125 catch (Exception e)
126 {
127 Console.WriteLine("[DATASNAPSHOT] couldn't access field reflectively\n" + e.ToString());
128 }
129 if (m_rootPart != null)
130 {
131 node = nodeFactory.CreateNode(XmlNodeType.Element, "title", "");
132 node.InnerText = m_rootPart.Name;
133 xmlobject.AppendChild(node);
94 134
95 node = nodeFactory.CreateNode(XmlNodeType.Element, "flags", ""); 135 node = nodeFactory.CreateNode(XmlNodeType.Element, "description", "");
96 node.InnerText = String.Format("{0:x}", m_rootPart.ObjectFlags); 136 node.InnerText = m_rootPart.Description;
97 xmlobject.AppendChild(node); 137 xmlobject.AppendChild(node);
138
139 node = nodeFactory.CreateNode(XmlNodeType.Element, "flags", "");
140 node.InnerText = String.Format("{0:x}", m_rootPart.ObjectFlags);
141 xmlobject.AppendChild(node);
142 }
143 parent.AppendChild(xmlobject);
98 } 144 }
99 parent.AppendChild(xmlobject);
100 } 145 }
101 } 146 }
102#endif 147 this.Stale = false;
103 return parent; 148 return parent;
149 }
104 150
151 public String Name
152 {
153 get { return "ObjectSnapshot"; }
105 } 154 }
155
156 public bool Stale
157 {
158 get
159 {
160 return m_stale;
161 }
162 set
163 {
164 m_stale = value;
165
166 if (m_stale)
167 OnStale(this);
168 }
169 }
170
171 public event ProviderStale OnStale;
106 } 172 }
107} 173} \ No newline at end of file