aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/ChildAgentDataUpdate.cs250
1 files changed, 236 insertions, 14 deletions
diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs
index f3ac943..dd505ad 100644
--- a/OpenSim/Framework/ChildAgentDataUpdate.cs
+++ b/OpenSim/Framework/ChildAgentDataUpdate.cs
@@ -60,26 +60,150 @@ namespace OpenSim.Framework
60 60
61 public ChildAgentDataUpdate(AgentData agent) 61 public ChildAgentDataUpdate(AgentData agent)
62 { 62 {
63 if (agent.ActiveGroupID != null) 63 ActiveGroupID = agent.ActiveGroupID.Guid;
64 ActiveGroupID = agent.ActiveGroupID.Guid; 64 AgentID = agent.AgentID.Guid;
65 if (agent.AgentID != null)
66 AgentID = agent.AgentID.Guid;
67 alwaysrun = agent.AlwaysRun; 65 alwaysrun = agent.AlwaysRun;
68 if (agent.Size != null) 66 AVHeight = agent.Size.Z;
69 AVHeight = agent.Size.Z; 67 cameraPosition = new sLLVector3(agent.Center);
70 if (agent.Center != null)
71 cameraPosition = new sLLVector3(agent.Center);
72 drawdistance = agent.Far; 68 drawdistance = agent.Far;
73 godlevel = (float)agent.GodLevel; 69 godlevel = (float)agent.GodLevel;
74 if (agent.Groups.Length > 0) 70 if (agent.Groups.Length > 0)
75 GroupAccess = (uint)agent.Groups[0].GroupPowers; 71 GroupAccess = (uint)agent.Groups[0].GroupPowers;
76 if (agent.Position != null) 72 Position = new sLLVector3(agent.Position);
77 Position = new sLLVector3(agent.Position);
78 regionHandle = agent.RegionHandle; 73 regionHandle = agent.RegionHandle;
79 throttles = agent.Throttles; 74 throttles = agent.Throttles;
80 if (agent.Velocity != null) 75 Velocity = new sLLVector3(agent.Velocity);
81 Velocity = new sLLVector3(agent.Velocity);
82 } 76 }
77
78 public ChildAgentDataUpdate(AgentPosition agent)
79 {
80 AgentID = agent.AgentID.Guid;
81 AVHeight = agent.Size.Z;
82 cameraPosition = new sLLVector3(agent.Center);
83 drawdistance = agent.Far;
84 Position = new sLLVector3(agent.Position);
85 regionHandle = agent.RegionHandle;
86 throttles = agent.Throttles;
87 Velocity = new sLLVector3(agent.Velocity);
88 }
89 }
90
91 /// <summary>
92 /// Replacement for ChildAgentDataUpdate. Used over RESTComms and LocalComms.
93 /// </summary>
94 public class AgentPosition
95 {
96 public ulong RegionHandle;
97 public uint CircuitCode;
98 public UUID AgentID;
99 public UUID SessionID;
100
101 public float Far;
102 public Vector3 Position;
103 public Vector3 Velocity;
104 public Vector3 Center;
105 public Vector3 Size;
106 public Vector3 AtAxis;
107 public Vector3 LeftAxis;
108 public Vector3 UpAxis;
109 public bool ChangedGrid;
110
111 // This probably shouldn't be here
112 public byte[] Throttles;
113
114
115 public OSDMap PackUpdateMessage()
116 {
117 OSDMap args = new OSDMap();
118 args["message_type"] = OSD.FromString("AgentPosition");
119
120 args["region_handle"] = OSD.FromString(RegionHandle.ToString());
121 args["circuit_code"] = OSD.FromString(CircuitCode.ToString());
122 args["agent_uuid"] = OSD.FromUUID(AgentID);
123 args["session_uuid"] = OSD.FromUUID(SessionID);
124
125 args["position"] = OSD.FromString(Position.ToString());
126 args["velocity"] = OSD.FromString(Velocity.ToString());
127 args["center"] = OSD.FromString(Center.ToString());
128 args["size"] = OSD.FromString(Size.ToString());
129 args["at_axis"] = OSD.FromString(AtAxis.ToString());
130 args["left_axis"] = OSD.FromString(LeftAxis.ToString());
131 args["up_axis"] = OSD.FromString(UpAxis.ToString());
132
133 args["far"] = OSD.FromReal(Far);
134 args["changed_grid"] = OSD.FromBoolean(ChangedGrid);
135
136 if ((Throttles != null) && (Throttles.Length > 0))
137 args["throttles"] = OSD.FromBinary(Throttles);
138
139 return args;
140 }
141
142 public void UnpackUpdateMessage(OSDMap args)
143 {
144 if (args.ContainsKey("region_handle"))
145 UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle);
146
147 if (args["circuit_code"] != null)
148 UInt32.TryParse((string)args["circuit_code"].AsString(), out CircuitCode);
149
150 if (args["agent_uuid"] != null)
151 AgentID = args["agent_uuid"].AsUUID();
152
153 if (args["session_uuid"] != null)
154 SessionID = args["session_uuid"].AsUUID();
155
156 if (args["position"] != null)
157 Vector3.TryParse(args["position"].AsString(), out Position);
158
159 if (args["velocity"] != null)
160 Vector3.TryParse(args["velocity"].AsString(), out Velocity);
161
162 if (args["center"] != null)
163 Vector3.TryParse(args["center"].AsString(), out Center);
164
165 if (args["size"] != null)
166 Vector3.TryParse(args["size"].AsString(), out Size);
167
168 if (args["at_axis"] != null)
169 Vector3.TryParse(args["at_axis"].AsString(), out AtAxis);
170
171 if (args["left_axis"] != null)
172 Vector3.TryParse(args["left_axis"].AsString(), out AtAxis);
173
174 if (args["up_axis"] != null)
175 Vector3.TryParse(args["up_axis"].AsString(), out AtAxis);
176
177 if (args["changed_grid"] != null)
178 ChangedGrid = args["changed_grid"].AsBoolean();
179
180 if (args["far"] != null)
181 Far = (float)(args["far"].AsReal());
182
183 if (args["throttles"] != null)
184 Throttles = args["throttles"].AsBinary();
185 }
186
187 /// <summary>
188 /// Soon to be decommissioned
189 /// </summary>
190 /// <param name="cAgent"></param>
191 public void CopyFrom(ChildAgentDataUpdate cAgent)
192 {
193 AgentID = new UUID(cAgent.AgentID);
194
195 // next: ???
196 Size = new Vector3();
197 Size.Z = cAgent.AVHeight;
198
199 Center = new Vector3(cAgent.cameraPosition.x, cAgent.cameraPosition.y, cAgent.cameraPosition.z);
200 Far = cAgent.drawdistance;
201 Position = new Vector3(cAgent.Position.x, cAgent.Position.y, cAgent.Position.z);
202 RegionHandle = cAgent.regionHandle;
203 Throttles = cAgent.throttles;
204 Velocity = new Vector3(cAgent.Velocity.x, cAgent.Velocity.y, cAgent.Velocity.z);
205 }
206
83 } 207 }
84 208
85 public class AgentGroupData 209 public class AgentGroupData
@@ -94,12 +218,58 @@ namespace OpenSim.Framework
94 GroupPowers = powers; 218 GroupPowers = powers;
95 AcceptNotices = notices; 219 AcceptNotices = notices;
96 } 220 }
221
222 public AgentGroupData(OSDMap args)
223 {
224 UnpackUpdateMessage(args);
225 }
226
227 public OSDMap PackUpdateMessage()
228 {
229 OSDMap groupdata = new OSDMap();
230 groupdata["group_id"] = OSD.FromUUID(GroupID);
231 groupdata["group_powers"] = OSD.FromString(GroupPowers.ToString());
232 groupdata["accept_notices"] = OSD.FromBoolean(AcceptNotices);
233
234 return groupdata;
235 }
236
237 public void UnpackUpdateMessage(OSDMap args)
238 {
239 if (args["group_id"] != null)
240 GroupID = args["group_id"].AsUUID();
241 if (args["group_powers"] != null)
242 UInt64.TryParse((string)args["group_powers"].AsString(), out GroupPowers);
243 if (args["accept_notices"] != null)
244 AcceptNotices = args["accept_notices"].AsBoolean();
245 }
97 } 246 }
98 247
99 public class AgentAnimationData 248 public class AgentAnimationData
100 { 249 {
101 public UUID Animation; 250 public UUID Animation;
102 public UUID ObjectID; 251 public UUID ObjectID;
252
253 public AgentAnimationData(OSDMap args)
254 {
255 UnpackUpdateMessage(args);
256 }
257
258 public OSDMap PackUpdateMessage()
259 {
260 OSDMap anim = new OSDMap();
261 anim["animation"] = OSD.FromUUID(Animation);
262 anim["object_id"] = OSD.FromUUID(ObjectID);
263 return anim;
264 }
265
266 public void UnpackUpdateMessage(OSDMap args)
267 {
268 if (args["animation"] != null)
269 Animation = args["animation"].AsUUID();
270 if (args["object_id"] != null)
271 ObjectID = args["object_id"].AsUUID();
272 }
103 } 273 }
104 274
105 public class AgentData 275 public class AgentData
@@ -142,13 +312,15 @@ namespace OpenSim.Framework
142 public UUID GranterID; 312 public UUID GranterID;
143 public Dictionary<string, string> NVPairs; 313 public Dictionary<string, string> NVPairs;
144 314
145 byte[] VisualParams; 315 public byte[] VisualParams;
146 316
147 public string CallbackURI; 317 public string CallbackURI;
148 318
149 public OSDMap PackUpdateMessage() 319 public OSDMap PackUpdateMessage()
150 { 320 {
151 OSDMap args = new OSDMap(); 321 OSDMap args = new OSDMap();
322 args["message_type"] = OSD.FromString("AgentData");
323
152 args["region_handle"] = OSD.FromString(RegionHandle.ToString()); 324 args["region_handle"] = OSD.FromString(RegionHandle.ToString());
153 args["circuit_code"] = OSD.FromString(CircuitCode.ToString()); 325 args["circuit_code"] = OSD.FromString(CircuitCode.ToString());
154 args["agent_uuid"] = OSD.FromUUID(AgentID); 326 args["agent_uuid"] = OSD.FromUUID(AgentID);
@@ -190,7 +362,26 @@ namespace OpenSim.Framework
190 362
191 args["active_group_id"] = OSD.FromUUID(ActiveGroupID); 363 args["active_group_id"] = OSD.FromUUID(ActiveGroupID);
192 364
193 // Last few fields are still missing 365 if ((Groups != null) && (Groups.Length > 0))
366 {
367 OSDArray groups = new OSDArray(Groups.Length);
368 foreach (AgentGroupData agd in Groups)
369 groups.Add(agd.PackUpdateMessage());
370 args["groups"] = groups;
371 }
372
373 if ((Anims != null) && (Anims.Length > 0))
374 {
375 OSDArray anims = new OSDArray(Anims.Length);
376 foreach (AgentAnimationData aanim in Anims)
377 anims.Add(aanim.PackUpdateMessage());
378 args["animations"] = anims;
379 }
380
381 if ((VisualParams != null) && (VisualParams.Length > 0))
382 args["visual_params"] = OSD.FromBinary(VisualParams);
383
384 // Last few fields are still missing: granter and NVPais
194 385
195 if ((CallbackURI != null) && (!CallbackURI.Equals(""))) 386 if ((CallbackURI != null) && (!CallbackURI.Equals("")))
196 args["callback_uri"] = OSD.FromString(CallbackURI); 387 args["callback_uri"] = OSD.FromString(CallbackURI);
@@ -289,6 +480,37 @@ namespace OpenSim.Framework
289 if (args["active_group_id"] != null) 480 if (args["active_group_id"] != null)
290 ActiveGroupID = args["active_group_id"].AsUUID(); 481 ActiveGroupID = args["active_group_id"].AsUUID();
291 482
483 if ((args["groups"] != null) && (args["groups"]).Type == OpenMetaverse.StructuredData.OSDType.Array)
484 {
485 OSDArray groups = (OSDArray)(args["groups"]);
486 Groups = new AgentGroupData[groups.Count];
487 int i = 0;
488 foreach (OSD o in groups)
489 {
490 if (o.Type == OpenMetaverse.StructuredData.OSDType.Map)
491 {
492 Groups[i++] = new AgentGroupData((OSDMap)o);
493 }
494 }
495 }
496
497 if ((args["animations"] != null) && (args["animations"]).Type == OpenMetaverse.StructuredData.OSDType.Array)
498 {
499 OSDArray anims = (OSDArray)(args["animations"]);
500 Anims = new AgentAnimationData[anims.Count];
501 int i = 0;
502 foreach (OSD o in anims)
503 {
504 if (o.Type == OpenMetaverse.StructuredData.OSDType.Map)
505 {
506 Anims[i++] = new AgentAnimationData((OSDMap)o);
507 }
508 }
509 }
510
511 if (args["visual_params"] != null)
512 VisualParams = args["visual_params"].AsBinary();
513
292 if (args["callback_uri"] != null) 514 if (args["callback_uri"] != null)
293 CallbackURI = args["callback_uri"].AsString(); 515 CallbackURI = args["callback_uri"].AsString();
294 } 516 }