corrade-vassal – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 1 | /* |
2 | * Copyright (c) 2006-2014, openmetaverse.org |
||
3 | * All rights reserved. |
||
4 | * |
||
5 | * - Redistribution and use in source and binary forms, with or without |
||
6 | * modification, are permitted provided that the following conditions are met: |
||
7 | * |
||
8 | * - Redistributions of source code must retain the above copyright notice, this |
||
9 | * list of conditions and the following disclaimer. |
||
10 | * - Neither the name of the openmetaverse.org nor the names |
||
11 | * of its contributors may be used to endorse or promote products derived from |
||
12 | * this software without specific prior written permission. |
||
13 | * |
||
14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||
15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||
16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||
17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
||
18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
||
19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
||
20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
||
21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||
22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||
23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
||
24 | * POSSIBILITY OF SUCH DAMAGE. |
||
25 | */ |
||
26 | using System; |
||
27 | using OpenMetaverse.Packets; |
||
28 | using OpenMetaverse.Interfaces; |
||
29 | using OpenMetaverse.Messages.Linden; |
||
30 | using System.Collections.Generic; |
||
31 | |||
32 | namespace OpenMetaverse |
||
33 | { |
||
34 | /// <summary>Describes tasks returned in LandStatReply</summary> |
||
35 | public class EstateTask |
||
36 | { |
||
37 | public Vector3 Position; |
||
38 | public float Score; |
||
39 | public float MonoScore; |
||
40 | public UUID TaskID; |
||
41 | public uint TaskLocalID; |
||
42 | public string TaskName; |
||
43 | public string OwnerName; |
||
44 | } |
||
45 | |||
46 | /// <summary> |
||
47 | /// Estate level administration and utilities |
||
48 | /// </summary> |
||
49 | public class EstateTools |
||
50 | { |
||
51 | private GridClient Client; |
||
52 | |||
53 | /// <summary>Textures for each of the four terrain height levels</summary> |
||
54 | public GroundTextureSettings GroundTextures; |
||
55 | |||
56 | /// <summary>Upper/lower texture boundaries for each corner of the sim</summary> |
||
57 | public GroundTextureHeightSettings GroundTextureLimits; |
||
58 | |||
59 | /// <summary> |
||
60 | /// Constructor for EstateTools class |
||
61 | /// </summary> |
||
62 | /// <param name="client"></param> |
||
63 | public EstateTools(GridClient client) |
||
64 | { |
||
65 | GroundTextures = new GroundTextureSettings(); |
||
66 | GroundTextureLimits = new GroundTextureHeightSettings(); |
||
67 | |||
68 | Client = client; |
||
69 | Client.Network.RegisterCallback(PacketType.LandStatReply, LandStatReplyHandler); |
||
70 | Client.Network.RegisterCallback(PacketType.EstateOwnerMessage, EstateOwnerMessageHandler); |
||
71 | Client.Network.RegisterCallback(PacketType.EstateCovenantReply, EstateCovenantReplyHandler); |
||
72 | |||
73 | Client.Network.RegisterEventCallback("LandStatReply", new Caps.EventQueueCallback(LandStatCapsReplyHandler)); |
||
74 | } |
||
75 | |||
76 | #region Enums |
||
77 | /// <summary>Used in the ReportType field of a LandStatRequest</summary> |
||
78 | public enum LandStatReportType |
||
79 | { |
||
80 | TopScripts = 0, |
||
81 | TopColliders = 1 |
||
82 | } |
||
83 | |||
84 | /// <summary>Used by EstateOwnerMessage packets</summary> |
||
85 | public enum EstateAccessDelta : uint |
||
86 | { |
||
87 | BanUser = 64, |
||
88 | BanUserAllEstates = 66, |
||
89 | UnbanUser = 128, |
||
90 | UnbanUserAllEstates = 130, |
||
91 | AddManager = 256, |
||
92 | AddManagerAllEstates = 257, |
||
93 | RemoveManager = 512, |
||
94 | RemoveManagerAllEstates = 513, |
||
95 | AddUserAsAllowed = 4, |
||
96 | AddAllowedAllEstates = 6, |
||
97 | RemoveUserAsAllowed = 8, |
||
98 | RemoveUserAllowedAllEstates = 10, |
||
99 | AddGroupAsAllowed = 16, |
||
100 | AddGroupAllowedAllEstates = 18, |
||
101 | RemoveGroupAsAllowed = 32, |
||
102 | RemoveGroupAllowedAllEstates = 34 |
||
103 | } |
||
104 | |||
105 | /// <summary>Used by EstateOwnerMessage packets</summary> |
||
106 | public enum EstateAccessReplyDelta : uint |
||
107 | { |
||
108 | AllowedUsers = 17, |
||
109 | AllowedGroups = 18, |
||
110 | EstateBans = 20, |
||
111 | EstateManagers = 24 |
||
112 | } |
||
113 | |||
114 | /// <summary> |
||
115 | /// |
||
116 | /// </summary> |
||
117 | [Flags] |
||
118 | public enum EstateReturnFlags : uint |
||
119 | { |
||
120 | /// <summary>No flags set</summary> |
||
121 | None = 2, |
||
122 | /// <summary>Only return targets scripted objects</summary> |
||
123 | ReturnScripted = 6, |
||
124 | /// <summary>Only return targets objects if on others land</summary> |
||
125 | ReturnOnOthersLand = 3, |
||
126 | /// <summary>Returns target's scripted objects and objects on other parcels</summary> |
||
127 | ReturnScriptedAndOnOthers = 7 |
||
128 | } |
||
129 | #endregion |
||
130 | #region Structs |
||
131 | /// <summary>Ground texture settings for each corner of the region</summary> |
||
132 | // TODO: maybe move this class to the Simulator object and implement it there too |
||
133 | public struct GroundTextureSettings |
||
134 | { |
||
135 | public UUID Low; |
||
136 | public UUID MidLow; |
||
137 | public UUID MidHigh; |
||
138 | public UUID High; |
||
139 | } |
||
140 | |||
141 | /// <summary>Used by GroundTextureHeightSettings</summary> |
||
142 | public struct GroundTextureHeight |
||
143 | { |
||
144 | public float Low; |
||
145 | public float High; |
||
146 | } |
||
147 | |||
148 | /// <summary>The high and low texture thresholds for each corner of the sim</summary> |
||
149 | public struct GroundTextureHeightSettings |
||
150 | { |
||
151 | public GroundTextureHeight SW; |
||
152 | public GroundTextureHeight NW; |
||
153 | public GroundTextureHeight SE; |
||
154 | public GroundTextureHeight NE; |
||
155 | } |
||
156 | #endregion |
||
157 | |||
158 | #region Event delegates, Raise Events |
||
159 | |||
160 | /// <summary>The event subscribers. null if no subcribers</summary> |
||
161 | private EventHandler<TopCollidersReplyEventArgs> m_TopCollidersReply; |
||
162 | |||
163 | /// <summary>Raises the TopCollidersReply event</summary> |
||
164 | /// <param name="e">A TopCollidersReplyEventArgs object containing the |
||
165 | /// data returned from the data server</param> |
||
166 | protected virtual void OnTopCollidersReply(TopCollidersReplyEventArgs e) |
||
167 | { |
||
168 | EventHandler<TopCollidersReplyEventArgs> handler = m_TopCollidersReply; |
||
169 | if (handler != null) |
||
170 | handler(this, e); |
||
171 | } |
||
172 | |||
173 | /// <summary>Thread sync lock object</summary> |
||
174 | private readonly object m_TopCollidersReply_Lock = new object(); |
||
175 | |||
176 | /// <summary>Raised when the data server responds to a <see cref="LandStatRequest"/> request.</summary> |
||
177 | public event EventHandler<TopCollidersReplyEventArgs> TopCollidersReply |
||
178 | { |
||
179 | add { lock (m_TopCollidersReply_Lock) { m_TopCollidersReply += value; } } |
||
180 | remove { lock (m_TopCollidersReply_Lock) { m_TopCollidersReply -= value; } } |
||
181 | } |
||
182 | |||
183 | /// <summary>The event subscribers. null if no subcribers</summary> |
||
184 | private EventHandler<TopScriptsReplyEventArgs> m_TopScriptsReply; |
||
185 | |||
186 | /// <summary>Raises the TopScriptsReply event</summary> |
||
187 | /// <param name="e">A TopScriptsReplyEventArgs object containing the |
||
188 | /// data returned from the data server</param> |
||
189 | protected virtual void OnTopScriptsReply(TopScriptsReplyEventArgs e) |
||
190 | { |
||
191 | EventHandler<TopScriptsReplyEventArgs> handler = m_TopScriptsReply; |
||
192 | if (handler != null) |
||
193 | handler(this, e); |
||
194 | } |
||
195 | |||
196 | /// <summary>Thread sync lock object</summary> |
||
197 | private readonly object m_TopScriptsReply_Lock = new object(); |
||
198 | |||
199 | /// <summary>Raised when the data server responds to a <see cref="LandStatRequest"/> request.</summary> |
||
200 | public event EventHandler<TopScriptsReplyEventArgs> TopScriptsReply |
||
201 | { |
||
202 | add { lock (m_TopScriptsReply_Lock) { m_TopScriptsReply += value; } } |
||
203 | remove { lock (m_TopScriptsReply_Lock) { m_TopScriptsReply -= value; } } |
||
204 | } |
||
205 | |||
206 | |||
207 | /// <summary>The event subscribers. null if no subcribers</summary> |
||
208 | private EventHandler<EstateUsersReplyEventArgs> m_EstateUsersReply; |
||
209 | |||
210 | /// <summary>Raises the EstateUsersReply event</summary> |
||
211 | /// <param name="e">A EstateUsersReplyEventArgs object containing the |
||
212 | /// data returned from the data server</param> |
||
213 | protected virtual void OnEstateUsersReply(EstateUsersReplyEventArgs e) |
||
214 | { |
||
215 | EventHandler<EstateUsersReplyEventArgs> handler = m_EstateUsersReply; |
||
216 | if (handler != null) |
||
217 | handler(this, e); |
||
218 | } |
||
219 | |||
220 | /// <summary>Thread sync lock object</summary> |
||
221 | private readonly object m_EstateUsersReply_Lock = new object(); |
||
222 | |||
223 | /// <summary>Raised when the data server responds to a <see cref="LandStatRequest"/> request.</summary> |
||
224 | public event EventHandler<EstateUsersReplyEventArgs> EstateUsersReply |
||
225 | { |
||
226 | add { lock (m_EstateUsersReply_Lock) { m_EstateUsersReply += value; } } |
||
227 | remove { lock (m_EstateUsersReply_Lock) { m_EstateUsersReply -= value; } } |
||
228 | } |
||
229 | |||
230 | |||
231 | /// <summary>The event subscribers. null if no subcribers</summary> |
||
232 | private EventHandler<EstateGroupsReplyEventArgs> m_EstateGroupsReply; |
||
233 | |||
234 | /// <summary>Raises the EstateGroupsReply event</summary> |
||
235 | /// <param name="e">A EstateGroupsReplyEventArgs object containing the |
||
236 | /// data returned from the data server</param> |
||
237 | protected virtual void OnEstateGroupsReply(EstateGroupsReplyEventArgs e) |
||
238 | { |
||
239 | EventHandler<EstateGroupsReplyEventArgs> handler = m_EstateGroupsReply; |
||
240 | if (handler != null) |
||
241 | handler(this, e); |
||
242 | } |
||
243 | |||
244 | /// <summary>Thread sync lock object</summary> |
||
245 | private readonly object m_EstateGroupsReply_Lock = new object(); |
||
246 | |||
247 | /// <summary>Raised when the data server responds to a <see cref="LandStatRequest"/> request.</summary> |
||
248 | public event EventHandler<EstateGroupsReplyEventArgs> EstateGroupsReply |
||
249 | { |
||
250 | add { lock (m_EstateGroupsReply_Lock) { m_EstateGroupsReply += value; } } |
||
251 | remove { lock (m_EstateGroupsReply_Lock) { m_EstateGroupsReply -= value; } } |
||
252 | } |
||
253 | |||
254 | /// <summary>The event subscribers. null if no subcribers</summary> |
||
255 | private EventHandler<EstateManagersReplyEventArgs> m_EstateManagersReply; |
||
256 | |||
257 | /// <summary>Raises the EstateManagersReply event</summary> |
||
258 | /// <param name="e">A EstateManagersReplyEventArgs object containing the |
||
259 | /// data returned from the data server</param> |
||
260 | protected virtual void OnEstateManagersReply(EstateManagersReplyEventArgs e) |
||
261 | { |
||
262 | EventHandler<EstateManagersReplyEventArgs> handler = m_EstateManagersReply; |
||
263 | if (handler != null) |
||
264 | handler(this, e); |
||
265 | } |
||
266 | |||
267 | /// <summary>Thread sync lock object</summary> |
||
268 | private readonly object m_EstateManagersReply_Lock = new object(); |
||
269 | |||
270 | /// <summary>Raised when the data server responds to a <see cref="LandStatRequest"/> request.</summary> |
||
271 | public event EventHandler<EstateManagersReplyEventArgs> EstateManagersReply |
||
272 | { |
||
273 | add { lock (m_EstateManagersReply_Lock) { m_EstateManagersReply += value; } } |
||
274 | remove { lock (m_EstateManagersReply_Lock) { m_EstateManagersReply -= value; } } |
||
275 | } |
||
276 | |||
277 | /// <summary>The event subscribers. null if no subcribers</summary> |
||
278 | private EventHandler<EstateBansReplyEventArgs> m_EstateBansReply; |
||
279 | |||
280 | /// <summary>Raises the EstateBansReply event</summary> |
||
281 | /// <param name="e">A EstateBansReplyEventArgs object containing the |
||
282 | /// data returned from the data server</param> |
||
283 | protected virtual void OnEstateBansReply(EstateBansReplyEventArgs e) |
||
284 | { |
||
285 | EventHandler<EstateBansReplyEventArgs> handler = m_EstateBansReply; |
||
286 | if (handler != null) |
||
287 | handler(this, e); |
||
288 | } |
||
289 | |||
290 | /// <summary>Thread sync lock object</summary> |
||
291 | private readonly object m_EstateBansReply_Lock = new object(); |
||
292 | |||
293 | /// <summary>Raised when the data server responds to a <see cref="LandStatRequest"/> request.</summary> |
||
294 | public event EventHandler<EstateBansReplyEventArgs> EstateBansReply |
||
295 | { |
||
296 | add { lock (m_EstateBansReply_Lock) { m_EstateBansReply += value; } } |
||
297 | remove { lock (m_EstateBansReply_Lock) { m_EstateBansReply -= value; } } |
||
298 | } |
||
299 | |||
300 | /// <summary>The event subscribers. null if no subcribers</summary> |
||
301 | private EventHandler<EstateCovenantReplyEventArgs> m_EstateCovenantReply; |
||
302 | |||
303 | /// <summary>Raises the EstateCovenantReply event</summary> |
||
304 | /// <param name="e">A EstateCovenantReplyEventArgs object containing the |
||
305 | /// data returned from the data server</param> |
||
306 | protected virtual void OnEstateCovenantReply(EstateCovenantReplyEventArgs e) |
||
307 | { |
||
308 | EventHandler<EstateCovenantReplyEventArgs> handler = m_EstateCovenantReply; |
||
309 | if (handler != null) |
||
310 | handler(this, e); |
||
311 | } |
||
312 | |||
313 | /// <summary>Thread sync lock object</summary> |
||
314 | private readonly object m_EstateCovenantReply_Lock = new object(); |
||
315 | |||
316 | /// <summary>Raised when the data server responds to a <see cref="LandStatRequest"/> request.</summary> |
||
317 | public event EventHandler<EstateCovenantReplyEventArgs> EstateCovenantReply |
||
318 | { |
||
319 | add { lock (m_EstateCovenantReply_Lock) { m_EstateCovenantReply += value; } } |
||
320 | remove { lock (m_EstateCovenantReply_Lock) { m_EstateCovenantReply -= value; } } |
||
321 | } |
||
322 | |||
323 | |||
324 | /// <summary>The event subscribers. null if no subcribers</summary> |
||
325 | private EventHandler<EstateUpdateInfoReplyEventArgs> m_EstateUpdateInfoReply; |
||
326 | |||
327 | /// <summary>Raises the EstateUpdateInfoReply event</summary> |
||
328 | /// <param name="e">A EstateUpdateInfoReplyEventArgs object containing the |
||
329 | /// data returned from the data server</param> |
||
330 | protected virtual void OnEstateUpdateInfoReply(EstateUpdateInfoReplyEventArgs e) |
||
331 | { |
||
332 | EventHandler<EstateUpdateInfoReplyEventArgs> handler = m_EstateUpdateInfoReply; |
||
333 | if (handler != null) |
||
334 | handler(this, e); |
||
335 | } |
||
336 | |||
337 | /// <summary>Thread sync lock object</summary> |
||
338 | private readonly object m_EstateUpdateInfoReply_Lock = new object(); |
||
339 | |||
340 | /// <summary>Raised when the data server responds to a <see cref="LandStatRequest"/> request.</summary> |
||
341 | public event EventHandler<EstateUpdateInfoReplyEventArgs> EstateUpdateInfoReply |
||
342 | { |
||
343 | add { lock (m_EstateUpdateInfoReply_Lock) { m_EstateUpdateInfoReply += value; } } |
||
344 | remove { lock (m_EstateUpdateInfoReply_Lock) { m_EstateUpdateInfoReply -= value; } } |
||
345 | } |
||
346 | #endregion |
||
347 | |||
348 | #region Public Methods |
||
349 | /// <summary> |
||
350 | /// Requests estate information such as top scripts and colliders |
||
351 | /// </summary> |
||
352 | /// <param name="parcelLocalID"></param> |
||
353 | /// <param name="reportType"></param> |
||
354 | /// <param name="requestFlags"></param> |
||
355 | /// <param name="filter"></param> |
||
356 | public void LandStatRequest(int parcelLocalID, LandStatReportType reportType, uint requestFlags, string filter) |
||
357 | { |
||
358 | LandStatRequestPacket p = new LandStatRequestPacket(); |
||
359 | p.AgentData.AgentID = Client.Self.AgentID; |
||
360 | p.AgentData.SessionID = Client.Self.SessionID; |
||
361 | p.RequestData.Filter = Utils.StringToBytes(filter); |
||
362 | p.RequestData.ParcelLocalID = parcelLocalID; |
||
363 | p.RequestData.ReportType = (uint)reportType; |
||
364 | p.RequestData.RequestFlags = requestFlags; |
||
365 | Client.Network.SendPacket(p); |
||
366 | } |
||
367 | |||
368 | /// <summary>Requests estate settings, including estate manager and access/ban lists</summary> |
||
369 | public void RequestInfo() |
||
370 | { |
||
371 | EstateOwnerMessage("getinfo", ""); |
||
372 | } |
||
373 | |||
374 | /// <summary>Requests the "Top Scripts" list for the current region</summary> |
||
375 | public void RequestTopScripts() |
||
376 | { |
||
377 | //EstateOwnerMessage("scripts", ""); |
||
378 | LandStatRequest(0, LandStatReportType.TopScripts, 0, ""); |
||
379 | } |
||
380 | |||
381 | /// <summary>Requests the "Top Colliders" list for the current region</summary> |
||
382 | public void RequestTopColliders() |
||
383 | { |
||
384 | //EstateOwnerMessage("colliders", ""); |
||
385 | LandStatRequest(0, LandStatReportType.TopColliders, 0, ""); |
||
386 | } |
||
387 | |||
388 | /// <summary> |
||
389 | /// Set several estate specific configuration variables |
||
390 | /// </summary> |
||
391 | /// <param name="WaterHeight">The Height of the waterlevel over the entire estate. Defaults to 20</param> |
||
392 | /// <param name="TerrainRaiseLimit">The maximum height change allowed above the baked terrain. Defaults to 4</param> |
||
393 | /// <param name="TerrainLowerLimit">The minimum height change allowed below the baked terrain. Defaults to -4</param> |
||
394 | /// <param name="UseEstateSun">true to use</param> |
||
395 | /// <param name="FixedSun">if True forces the sun position to the position in SunPosition</param> |
||
396 | /// <param name="SunPosition">The current position of the sun on the estate, or when FixedSun is true the static position |
||
397 | /// the sun will remain. <remarks>6.0 = Sunrise, 30.0 = Sunset</remarks></param> |
||
398 | public void SetTerrainVariables(float WaterHeight, float TerrainRaiseLimit, |
||
399 | float TerrainLowerLimit, bool UseEstateSun, bool FixedSun, float SunPosition) |
||
400 | { |
||
401 | List<string> simVariables = new List<string>(); |
||
402 | simVariables.Add(WaterHeight.ToString(Utils.EnUsCulture)); |
||
403 | simVariables.Add(TerrainRaiseLimit.ToString(Utils.EnUsCulture)); |
||
404 | simVariables.Add(TerrainLowerLimit.ToString(Utils.EnUsCulture)); |
||
405 | simVariables.Add(UseEstateSun ? "Y" : "N"); |
||
406 | simVariables.Add(FixedSun ? "Y" : "N"); |
||
407 | simVariables.Add(SunPosition.ToString(Utils.EnUsCulture)); |
||
408 | simVariables.Add("Y"); //Not used? |
||
409 | simVariables.Add("N"); //Not used? |
||
410 | simVariables.Add("0.00"); //Also not used? |
||
411 | EstateOwnerMessage("setregionterrain", simVariables); |
||
412 | } |
||
413 | |||
414 | /// <summary> |
||
415 | /// Request return of objects owned by specified avatar |
||
416 | /// </summary> |
||
417 | /// <param name="Target">The Agents <see cref="UUID"/> owning the primitives to return</param> |
||
418 | /// <param name="flag">specify the coverage and type of objects to be included in the return</param> |
||
419 | /// <param name="EstateWide">true to perform return on entire estate</param> |
||
420 | public void SimWideReturn(UUID Target, EstateReturnFlags flag, bool EstateWide) |
||
421 | { |
||
422 | if (EstateWide) |
||
423 | { |
||
424 | List<string> param = new List<string>(); |
||
425 | param.Add(flag.ToString()); |
||
426 | param.Add(Target.ToString()); |
||
427 | EstateOwnerMessage("estateobjectreturn", param); |
||
428 | } |
||
429 | else |
||
430 | { |
||
431 | SimWideDeletesPacket simDelete = new SimWideDeletesPacket(); |
||
432 | simDelete.AgentData.AgentID = Client.Self.AgentID; |
||
433 | simDelete.AgentData.SessionID = Client.Self.SessionID; |
||
434 | simDelete.DataBlock.TargetID = Target; |
||
435 | simDelete.DataBlock.Flags = (uint)flag; |
||
436 | Client.Network.SendPacket(simDelete); |
||
437 | } |
||
438 | } |
||
439 | |||
440 | /// <summary></summary> |
||
441 | /// <param name="method"></param> |
||
442 | /// <param name="param"></param> |
||
443 | public void EstateOwnerMessage(string method, string param) |
||
444 | { |
||
445 | List<string> listParams = new List<string>(); |
||
446 | listParams.Add(param); |
||
447 | EstateOwnerMessage(method, listParams); |
||
448 | } |
||
449 | |||
450 | /// <summary> |
||
451 | /// Used for setting and retrieving various estate panel settings |
||
452 | /// </summary> |
||
453 | /// <param name="method">EstateOwnerMessage Method field</param> |
||
454 | /// <param name="listParams">List of parameters to include</param> |
||
455 | public void EstateOwnerMessage(string method, List<string> listParams) |
||
456 | { |
||
457 | EstateOwnerMessagePacket estate = new EstateOwnerMessagePacket(); |
||
458 | estate.AgentData.AgentID = Client.Self.AgentID; |
||
459 | estate.AgentData.SessionID = Client.Self.SessionID; |
||
460 | estate.AgentData.TransactionID = UUID.Zero; |
||
461 | estate.MethodData.Invoice = UUID.Random(); |
||
462 | estate.MethodData.Method = Utils.StringToBytes(method); |
||
463 | estate.ParamList = new EstateOwnerMessagePacket.ParamListBlock[listParams.Count]; |
||
464 | for (int i = 0; i < listParams.Count; i++) |
||
465 | { |
||
466 | estate.ParamList[i] = new EstateOwnerMessagePacket.ParamListBlock(); |
||
467 | estate.ParamList[i].Parameter = Utils.StringToBytes(listParams[i]); |
||
468 | } |
||
469 | Client.Network.SendPacket((Packet)estate); |
||
470 | } |
||
471 | |||
472 | /// <summary> |
||
473 | /// Kick an avatar from an estate |
||
474 | /// </summary> |
||
475 | /// <param name="userID">Key of Agent to remove</param> |
||
476 | public void KickUser(UUID userID) |
||
477 | { |
||
478 | EstateOwnerMessage("kickestate", userID.ToString()); |
||
479 | } |
||
480 | |||
481 | /// <summary> |
||
482 | /// Ban an avatar from an estate</summary> |
||
483 | /// <param name="userID">Key of Agent to remove</param> |
||
484 | /// <param name="allEstates">Ban user from this estate and all others owned by the estate owner</param> |
||
485 | public void BanUser(UUID userID, bool allEstates) |
||
486 | { |
||
487 | List<string> listParams = new List<string>(); |
||
488 | uint flag = allEstates ? (uint)EstateAccessDelta.BanUserAllEstates : (uint)EstateAccessDelta.BanUser; |
||
489 | listParams.Add(Client.Self.AgentID.ToString()); |
||
490 | listParams.Add(flag.ToString()); |
||
491 | listParams.Add(userID.ToString()); |
||
492 | EstateOwnerMessage("estateaccessdelta", listParams); |
||
493 | } |
||
494 | |||
495 | /// <summary>Unban an avatar from an estate</summary> |
||
496 | /// <param name="userID">Key of Agent to remove</param> |
||
497 | /// /// <param name="allEstates">Unban user from this estate and all others owned by the estate owner</param> |
||
498 | public void UnbanUser(UUID userID, bool allEstates) |
||
499 | { |
||
500 | List<string> listParams = new List<string>(); |
||
501 | uint flag = allEstates ? (uint)EstateAccessDelta.UnbanUserAllEstates : (uint)EstateAccessDelta.UnbanUser; |
||
502 | listParams.Add(Client.Self.AgentID.ToString()); |
||
503 | listParams.Add(flag.ToString()); |
||
504 | listParams.Add(userID.ToString()); |
||
505 | EstateOwnerMessage("estateaccessdelta", listParams); |
||
506 | } |
||
507 | |||
508 | /// <summary> |
||
509 | /// Send a message dialog to everyone in an entire estate |
||
510 | /// </summary> |
||
511 | /// <param name="message">Message to send all users in the estate</param> |
||
512 | public void EstateMessage(string message) |
||
513 | { |
||
514 | List<string> listParams = new List<string>(); |
||
515 | listParams.Add(Client.Self.FirstName + " " + Client.Self.LastName); |
||
516 | listParams.Add(message); |
||
517 | EstateOwnerMessage("instantmessage", listParams); |
||
518 | } |
||
519 | |||
520 | /// <summary> |
||
521 | /// Send a message dialog to everyone in a simulator |
||
522 | /// </summary> |
||
523 | /// <param name="message">Message to send all users in the simulator</param> |
||
524 | public void SimulatorMessage(string message) |
||
525 | { |
||
526 | List<string> listParams = new List<string>(); |
||
527 | listParams.Add("-1"); |
||
528 | listParams.Add("-1"); |
||
529 | listParams.Add(Client.Self.AgentID.ToString()); |
||
530 | listParams.Add(Client.Self.FirstName + " " + Client.Self.LastName); |
||
531 | listParams.Add(message); |
||
532 | EstateOwnerMessage("simulatormessage", listParams); |
||
533 | } |
||
534 | |||
535 | /// <summary> |
||
536 | /// Send an avatar back to their home location |
||
537 | /// </summary> |
||
538 | /// <param name="pest">Key of avatar to send home</param> |
||
539 | public void TeleportHomeUser(UUID pest) |
||
540 | { |
||
541 | List<string> listParams = new List<string>(); |
||
542 | listParams.Add(Client.Self.AgentID.ToString()); |
||
543 | listParams.Add(pest.ToString()); |
||
544 | EstateOwnerMessage("teleporthomeuser", listParams); |
||
545 | } |
||
546 | |||
547 | /// <summary> |
||
548 | /// Begin the region restart process |
||
549 | /// </summary> |
||
550 | public void RestartRegion() |
||
551 | { |
||
552 | EstateOwnerMessage("restart", "120"); |
||
553 | } |
||
554 | |||
555 | /// <summary> |
||
556 | /// Cancels a region restart |
||
557 | /// </summary> |
||
558 | public void CancelRestart() |
||
559 | { |
||
560 | EstateOwnerMessage("restart", "-1"); |
||
561 | } |
||
562 | |||
563 | /// <summary>Estate panel "Region" tab settings</summary> |
||
564 | public void SetRegionInfo(bool blockTerraform, bool blockFly, bool allowDamage, bool allowLandResell, bool restrictPushing, bool allowParcelJoinDivide, float agentLimit, float objectBonus, bool mature) |
||
565 | { |
||
566 | List<string> listParams = new List<string>(); |
||
567 | if (blockTerraform) listParams.Add("Y"); else listParams.Add("N"); |
||
568 | if (blockFly) listParams.Add("Y"); else listParams.Add("N"); |
||
569 | if (allowDamage) listParams.Add("Y"); else listParams.Add("N"); |
||
570 | if (allowLandResell) listParams.Add("Y"); else listParams.Add("N"); |
||
571 | listParams.Add(agentLimit.ToString()); |
||
572 | listParams.Add(objectBonus.ToString()); |
||
573 | if (mature) listParams.Add("21"); else listParams.Add("13"); //FIXME - enumerate these settings |
||
574 | if (restrictPushing) listParams.Add("Y"); else listParams.Add("N"); |
||
575 | if (allowParcelJoinDivide) listParams.Add("Y"); else listParams.Add("N"); |
||
576 | EstateOwnerMessage("setregioninfo", listParams); |
||
577 | } |
||
578 | |||
579 | /// <summary>Estate panel "Debug" tab settings</summary> |
||
580 | public void SetRegionDebug(bool disableScripts, bool disableCollisions, bool disablePhysics) |
||
581 | { |
||
582 | List<string> listParams = new List<string>(); |
||
583 | if (disableScripts) listParams.Add("Y"); else listParams.Add("N"); |
||
584 | if (disableCollisions) listParams.Add("Y"); else listParams.Add("N"); |
||
585 | if (disablePhysics) listParams.Add("Y"); else listParams.Add("N"); |
||
586 | EstateOwnerMessage("setregiondebug", listParams); |
||
587 | } |
||
588 | |||
589 | /// <summary>Used for setting the region's terrain textures for its four height levels</summary> |
||
590 | /// <param name="low"></param> |
||
591 | /// <param name="midLow"></param> |
||
592 | /// <param name="midHigh"></param> |
||
593 | /// <param name="high"></param> |
||
594 | public void SetRegionTerrain(UUID low, UUID midLow, UUID midHigh, UUID high) |
||
595 | { |
||
596 | List<string> listParams = new List<string>(); |
||
597 | listParams.Add("0 " + low.ToString()); |
||
598 | listParams.Add("1 " + midLow.ToString()); |
||
599 | listParams.Add("2 " + midHigh.ToString()); |
||
600 | listParams.Add("3 " + high.ToString()); |
||
601 | EstateOwnerMessage("texturedetail", listParams); |
||
602 | EstateOwnerMessage("texturecommit", ""); |
||
603 | } |
||
604 | |||
605 | /// <summary>Used for setting sim terrain texture heights</summary> |
||
606 | public void SetRegionTerrainHeights(float lowSW, float highSW, float lowNW, float highNW, float lowSE, float highSE, float lowNE, float highNE) |
||
607 | { |
||
608 | List<string> listParams = new List<string>(); |
||
609 | listParams.Add("0 " + lowSW.ToString(Utils.EnUsCulture) + " " + highSW.ToString(Utils.EnUsCulture)); //SW low-high |
||
610 | listParams.Add("1 " + lowNW.ToString(Utils.EnUsCulture) + " " + highNW.ToString(Utils.EnUsCulture)); //NW low-high |
||
611 | listParams.Add("2 " + lowSE.ToString(Utils.EnUsCulture) + " " + highSE.ToString(Utils.EnUsCulture)); //SE low-high |
||
612 | listParams.Add("3 " + lowNE.ToString(Utils.EnUsCulture) + " " + highNE.ToString(Utils.EnUsCulture)); //NE low-high |
||
613 | EstateOwnerMessage("textureheights", listParams); |
||
614 | EstateOwnerMessage("texturecommit", ""); |
||
615 | } |
||
616 | |||
617 | /// <summary>Requests the estate covenant</summary> |
||
618 | public void RequestCovenant() |
||
619 | { |
||
620 | EstateCovenantRequestPacket req = new EstateCovenantRequestPacket(); |
||
621 | req.AgentData.AgentID = Client.Self.AgentID; |
||
622 | req.AgentData.SessionID = Client.Self.SessionID; |
||
623 | Client.Network.SendPacket(req); |
||
624 | } |
||
625 | |||
626 | /// <summary> |
||
627 | /// Upload a terrain RAW file |
||
628 | /// </summary> |
||
629 | /// <param name="fileData">A byte array containing the encoded terrain data</param> |
||
630 | /// <param name="fileName">The name of the file being uploaded</param> |
||
631 | /// <returns>The Id of the transfer request</returns> |
||
632 | public UUID UploadTerrain(byte[] fileData, string fileName) |
||
633 | { |
||
634 | AssetUpload upload = new AssetUpload(); |
||
635 | upload.AssetData = fileData; |
||
636 | upload.AssetType = AssetType.Unknown; |
||
637 | upload.Size = fileData.Length; |
||
638 | upload.ID = UUID.Random(); |
||
639 | |||
640 | // Tell the library we have a pending file to upload |
||
641 | Client.Assets.SetPendingAssetUploadData(upload); |
||
642 | |||
643 | // Create and populate a list with commands specific to uploading a raw terrain file |
||
644 | List<String> paramList = new List<string>(); |
||
645 | paramList.Add("upload filename"); |
||
646 | paramList.Add(fileName); |
||
647 | |||
648 | // Tell the simulator we have a new raw file to upload |
||
649 | Client.Estate.EstateOwnerMessage("terrain", paramList); |
||
650 | |||
651 | return upload.ID; |
||
652 | } |
||
653 | |||
654 | /// <summary> |
||
655 | /// Teleports all users home in current Estate |
||
656 | /// </summary> |
||
657 | public void TeleportHomeAllUsers() |
||
658 | { |
||
659 | List<string> Params = new List<string>(); |
||
660 | Params.Add(Client.Self.AgentID.ToString()); |
||
661 | EstateOwnerMessage("teleporthomeallusers", Params); |
||
662 | } |
||
663 | |||
664 | /// <summary> |
||
665 | /// Remove estate manager</summary> |
||
666 | /// <param name="userID">Key of Agent to Remove</param> |
||
667 | /// <param name="allEstates">removes manager to this estate and all others owned by the estate owner</param> |
||
668 | public void RemoveEstateManager(UUID userID, bool allEstates) |
||
669 | { |
||
670 | List<string> listParams = new List<string>(); |
||
671 | uint flag = allEstates ? (uint)EstateAccessDelta.RemoveManagerAllEstates : (uint)EstateAccessDelta.RemoveManager; |
||
672 | listParams.Add(Client.Self.AgentID.ToString()); |
||
673 | listParams.Add(flag.ToString()); |
||
674 | listParams.Add(userID.ToString()); |
||
675 | EstateOwnerMessage("estateaccessdelta", listParams); |
||
676 | } |
||
677 | |||
678 | /// <summary> |
||
679 | /// Add estate manager</summary> |
||
680 | /// <param name="userID">Key of Agent to Add</param> |
||
681 | /// <param name="allEstates">Add agent as manager to this estate and all others owned by the estate owner</param> |
||
682 | public void AddEstateManager(UUID userID, bool allEstates) |
||
683 | { |
||
684 | List<string> listParams = new List<string>(); |
||
685 | uint flag = allEstates ? (uint)EstateAccessDelta.AddManagerAllEstates : (uint)EstateAccessDelta.AddManager; |
||
686 | listParams.Add(Client.Self.AgentID.ToString()); |
||
687 | listParams.Add(flag.ToString()); |
||
688 | listParams.Add(userID.ToString()); |
||
689 | EstateOwnerMessage("estateaccessdelta", listParams); |
||
690 | } |
||
691 | |||
692 | /// <summary> |
||
693 | /// Add's an agent to the estate Allowed list</summary> |
||
694 | /// <param name="userID">Key of Agent to Add</param> |
||
695 | /// <param name="allEstates">Add agent as an allowed reisdent to All estates if true</param> |
||
696 | public void AddAllowedUser(UUID userID, bool allEstates) |
||
697 | { |
||
698 | List<string> listParams = new List<string>(); |
||
699 | uint flag = allEstates ? (uint)EstateAccessDelta.AddAllowedAllEstates : (uint)EstateAccessDelta.AddUserAsAllowed; |
||
700 | listParams.Add(Client.Self.AgentID.ToString()); |
||
701 | listParams.Add(flag.ToString()); |
||
702 | listParams.Add(userID.ToString()); |
||
703 | EstateOwnerMessage("estateaccessdelta", listParams); |
||
704 | } |
||
705 | |||
706 | /// <summary> |
||
707 | /// Removes an agent from the estate Allowed list</summary> |
||
708 | /// <param name="userID">Key of Agent to Remove</param> |
||
709 | /// <param name="allEstates">Removes agent as an allowed reisdent from All estates if true</param> |
||
710 | public void RemoveAllowedUser(UUID userID, bool allEstates) |
||
711 | { |
||
712 | List<string> listParams = new List<string>(); |
||
713 | uint flag = allEstates ? (uint)EstateAccessDelta.RemoveUserAllowedAllEstates : (uint)EstateAccessDelta.RemoveUserAsAllowed; |
||
714 | listParams.Add(Client.Self.AgentID.ToString()); |
||
715 | listParams.Add(flag.ToString()); |
||
716 | listParams.Add(userID.ToString()); |
||
717 | EstateOwnerMessage("estateaccessdelta", listParams); |
||
718 | } |
||
719 | /// |
||
720 | /// <summary> |
||
721 | /// Add's a group to the estate Allowed list</summary> |
||
722 | /// <param name="groupID">Key of Group to Add</param> |
||
723 | /// <param name="allEstates">Add Group as an allowed group to All estates if true</param> |
||
724 | public void AddAllowedGroup(UUID groupID, bool allEstates) |
||
725 | { |
||
726 | List<string> listParams = new List<string>(); |
||
727 | uint flag = allEstates ? (uint)EstateAccessDelta.AddGroupAllowedAllEstates : (uint)EstateAccessDelta.AddGroupAsAllowed; |
||
728 | listParams.Add(Client.Self.AgentID.ToString()); |
||
729 | listParams.Add(flag.ToString()); |
||
730 | listParams.Add(groupID.ToString()); |
||
731 | EstateOwnerMessage("estateaccessdelta", listParams); |
||
732 | } |
||
733 | /// |
||
734 | /// <summary> |
||
735 | /// Removes a group from the estate Allowed list</summary> |
||
736 | /// <param name="groupID">Key of Group to Remove</param> |
||
737 | /// <param name="allEstates">Removes Group as an allowed Group from All estates if true</param> |
||
738 | public void RemoveAllowedGroup(UUID groupID, bool allEstates) |
||
739 | { |
||
740 | List<string> listParams = new List<string>(); |
||
741 | uint flag = allEstates ? (uint)EstateAccessDelta.RemoveGroupAllowedAllEstates : (uint)EstateAccessDelta.RemoveGroupAsAllowed; |
||
742 | listParams.Add(Client.Self.AgentID.ToString()); |
||
743 | listParams.Add(flag.ToString()); |
||
744 | listParams.Add(groupID.ToString()); |
||
745 | EstateOwnerMessage("estateaccessdelta", listParams); |
||
746 | } |
||
747 | #endregion |
||
748 | |||
749 | |||
750 | #region Packet Handlers |
||
751 | |||
752 | /// <summary>Process an incoming packet and raise the appropriate events</summary> |
||
753 | /// <param name="sender">The sender</param> |
||
754 | /// <param name="e">The EventArgs object containing the packet data</param> |
||
755 | protected void EstateCovenantReplyHandler(object sender, PacketReceivedEventArgs e) |
||
756 | { |
||
757 | EstateCovenantReplyPacket reply = (EstateCovenantReplyPacket)e.Packet; |
||
758 | OnEstateCovenantReply(new EstateCovenantReplyEventArgs( |
||
759 | reply.Data.CovenantID, |
||
760 | reply.Data.CovenantTimestamp, |
||
761 | Utils.BytesToString(reply.Data.EstateName), |
||
762 | reply.Data.EstateOwnerID)); |
||
763 | } |
||
764 | |||
765 | /// <summary>Process an incoming packet and raise the appropriate events</summary> |
||
766 | /// <param name="sender">The sender</param> |
||
767 | /// <param name="e">The EventArgs object containing the packet data</param> |
||
768 | protected void EstateOwnerMessageHandler(object sender, PacketReceivedEventArgs e) |
||
769 | { |
||
770 | EstateOwnerMessagePacket message = (EstateOwnerMessagePacket)e.Packet; |
||
771 | uint estateID; |
||
772 | string method = Utils.BytesToString(message.MethodData.Method); |
||
773 | //List<string> parameters = new List<string>(); |
||
774 | |||
775 | if (method == "estateupdateinfo") |
||
776 | { |
||
777 | string estateName = Utils.BytesToString(message.ParamList[0].Parameter); |
||
778 | UUID estateOwner = new UUID(Utils.BytesToString(message.ParamList[1].Parameter)); |
||
779 | estateID = Utils.BytesToUInt(message.ParamList[2].Parameter); |
||
780 | /* |
||
781 | foreach (EstateOwnerMessagePacket.ParamListBlock param in message.ParamList) |
||
782 | { |
||
783 | parameters.Add(Utils.BytesToString(param.Parameter)); |
||
784 | } |
||
785 | */ |
||
786 | bool denyNoPaymentInfo; |
||
787 | if (Utils.BytesToUInt(message.ParamList[8].Parameter) == 0) denyNoPaymentInfo = true; |
||
788 | else denyNoPaymentInfo = false; |
||
789 | |||
790 | OnEstateUpdateInfoReply(new EstateUpdateInfoReplyEventArgs(estateName, estateOwner, estateID, denyNoPaymentInfo)); |
||
791 | } |
||
792 | |||
793 | else if (method == "setaccess") |
||
794 | { |
||
795 | int count; |
||
796 | estateID = Utils.BytesToUInt(message.ParamList[0].Parameter); |
||
797 | if (message.ParamList.Length > 1) |
||
798 | { |
||
799 | //param comes in as a string for some reason |
||
800 | uint param; |
||
801 | if (!uint.TryParse(Utils.BytesToString(message.ParamList[1].Parameter), out param)) return; |
||
802 | |||
803 | EstateAccessReplyDelta accessType = (EstateAccessReplyDelta)param; |
||
804 | |||
805 | switch (accessType) |
||
806 | { |
||
807 | case EstateAccessReplyDelta.EstateManagers: |
||
808 | //if (OnGetEstateManagers != null) |
||
809 | { |
||
810 | if (message.ParamList.Length > 5) |
||
811 | { |
||
812 | if (!int.TryParse(Utils.BytesToString(message.ParamList[5].Parameter), out count)) return; |
||
813 | List<UUID> managers = new List<UUID>(); |
||
814 | for (int i = 6; i < message.ParamList.Length; i++) |
||
815 | { |
||
816 | try |
||
817 | { |
||
818 | UUID managerID = new UUID(message.ParamList[i].Parameter, 0); |
||
819 | managers.Add(managerID); |
||
820 | } |
||
821 | catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, Client, ex); } |
||
822 | } |
||
823 | OnEstateManagersReply(new EstateManagersReplyEventArgs(estateID, count, managers)); |
||
824 | } |
||
825 | } |
||
826 | break; |
||
827 | |||
828 | case EstateAccessReplyDelta.EstateBans: |
||
829 | //if (OnGetEstateBans != null) |
||
830 | { |
||
831 | if (message.ParamList.Length > 5) |
||
832 | { |
||
833 | if (!int.TryParse(Utils.BytesToString(message.ParamList[4].Parameter), out count)) return; |
||
834 | List<UUID> bannedUsers = new List<UUID>(); |
||
835 | for (int i = 6; i < message.ParamList.Length; i++) |
||
836 | { |
||
837 | try |
||
838 | { |
||
839 | UUID bannedID = new UUID(message.ParamList[i].Parameter, 0); |
||
840 | bannedUsers.Add(bannedID); |
||
841 | } |
||
842 | catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, Client, ex); } |
||
843 | } |
||
844 | OnEstateBansReply(new EstateBansReplyEventArgs(estateID, count, bannedUsers)); |
||
845 | } |
||
846 | } |
||
847 | break; |
||
848 | |||
849 | case EstateAccessReplyDelta.AllowedUsers: |
||
850 | //if (OnGetAllowedUsers != null) |
||
851 | { |
||
852 | if (message.ParamList.Length > 5) |
||
853 | { |
||
854 | if (!int.TryParse(Utils.BytesToString(message.ParamList[2].Parameter), out count)) return; |
||
855 | List<UUID> allowedUsers = new List<UUID>(); |
||
856 | for (int i = 6; i < message.ParamList.Length; i++) |
||
857 | { |
||
858 | try |
||
859 | { |
||
860 | UUID allowedID = new UUID(message.ParamList[i].Parameter, 0); |
||
861 | allowedUsers.Add(allowedID); |
||
862 | } |
||
863 | catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, Client, ex); } |
||
864 | } |
||
865 | OnEstateUsersReply(new EstateUsersReplyEventArgs(estateID, count, allowedUsers)); |
||
866 | } |
||
867 | } |
||
868 | break; |
||
869 | |||
870 | case EstateAccessReplyDelta.AllowedGroups: |
||
871 | //if (OnGetAllowedGroups != null) |
||
872 | { |
||
873 | if (message.ParamList.Length > 5) |
||
874 | { |
||
875 | if (!int.TryParse(Utils.BytesToString(message.ParamList[3].Parameter), out count)) return; |
||
876 | List<UUID> allowedGroups = new List<UUID>(); |
||
877 | for (int i = 6; i < message.ParamList.Length; i++) |
||
878 | { |
||
879 | try |
||
880 | { |
||
881 | UUID groupID = new UUID(message.ParamList[i].Parameter, 0); |
||
882 | allowedGroups.Add(groupID); |
||
883 | } |
||
884 | catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, Client, ex); } |
||
885 | } |
||
886 | OnEstateGroupsReply(new EstateGroupsReplyEventArgs(estateID, count, allowedGroups)); |
||
887 | } |
||
888 | } |
||
889 | break; |
||
890 | } |
||
891 | } |
||
892 | } |
||
893 | } |
||
894 | |||
895 | /// <summary>Process an incoming packet and raise the appropriate events</summary> |
||
896 | /// <param name="sender">The sender</param> |
||
897 | /// <param name="e">The EventArgs object containing the packet data</param> |
||
898 | protected void LandStatReplyHandler(object sender, PacketReceivedEventArgs e) |
||
899 | { |
||
900 | //if (OnLandStatReply != null || OnGetTopScripts != null || OnGetTopColliders != null) |
||
901 | //if (OnGetTopScripts != null || OnGetTopColliders != null) |
||
902 | { |
||
903 | LandStatReplyPacket p = (LandStatReplyPacket)e.Packet; |
||
904 | Dictionary<UUID, EstateTask> Tasks = new Dictionary<UUID, EstateTask>(); |
||
905 | |||
906 | foreach (LandStatReplyPacket.ReportDataBlock rep in p.ReportData) |
||
907 | { |
||
908 | EstateTask task = new EstateTask(); |
||
909 | task.Position = new Vector3(rep.LocationX, rep.LocationY, rep.LocationZ); |
||
910 | task.Score = rep.Score; |
||
911 | task.TaskID = rep.TaskID; |
||
912 | task.TaskLocalID = rep.TaskLocalID; |
||
913 | task.TaskName = Utils.BytesToString(rep.TaskName); |
||
914 | task.OwnerName = Utils.BytesToString(rep.OwnerName); |
||
915 | Tasks.Add(task.TaskID, task); |
||
916 | } |
||
917 | |||
918 | LandStatReportType type = (LandStatReportType)p.RequestData.ReportType; |
||
919 | |||
920 | if (type == LandStatReportType.TopScripts) |
||
921 | { |
||
922 | OnTopScriptsReply(new TopScriptsReplyEventArgs((int)p.RequestData.TotalObjectCount, Tasks)); |
||
923 | } |
||
924 | else if (type == LandStatReportType.TopColliders) |
||
925 | { |
||
926 | OnTopCollidersReply(new TopCollidersReplyEventArgs((int) p.RequestData.TotalObjectCount, Tasks)); |
||
927 | } |
||
928 | |||
929 | /* |
||
930 | if (OnGetTopColliders != null) |
||
931 | { |
||
932 | //FIXME - System.UnhandledExceptionEventArgs |
||
933 | OnLandStatReply( |
||
934 | type, |
||
935 | p.RequestData.RequestFlags, |
||
936 | (int)p.RequestData.TotalObjectCount, |
||
937 | Tasks |
||
938 | ); |
||
939 | } |
||
940 | */ |
||
941 | |||
942 | } |
||
943 | } |
||
944 | |||
945 | private void LandStatCapsReplyHandler(string capsKey, IMessage message, Simulator simulator) |
||
946 | { |
||
947 | LandStatReplyMessage m = (LandStatReplyMessage)message; |
||
948 | Dictionary<UUID, EstateTask> Tasks = new Dictionary<UUID, EstateTask>(); |
||
949 | |||
950 | foreach (LandStatReplyMessage.ReportDataBlock rep in m.ReportDataBlocks) |
||
951 | { |
||
952 | EstateTask task = new EstateTask(); |
||
953 | task.Position = rep.Location; |
||
954 | task.Score = rep.Score; |
||
955 | task.MonoScore = rep.MonoScore; |
||
956 | task.TaskID = rep.TaskID; |
||
957 | task.TaskLocalID = rep.TaskLocalID; |
||
958 | task.TaskName = rep.TaskName; |
||
959 | task.OwnerName = rep.OwnerName; |
||
960 | Tasks.Add(task.TaskID, task); |
||
961 | } |
||
962 | |||
963 | LandStatReportType type = (LandStatReportType)m.ReportType; |
||
964 | |||
965 | if (type == LandStatReportType.TopScripts) |
||
966 | { |
||
967 | OnTopScriptsReply(new TopScriptsReplyEventArgs((int)m.TotalObjectCount, Tasks)); |
||
968 | } |
||
969 | else if (type == LandStatReportType.TopColliders) |
||
970 | { |
||
971 | OnTopCollidersReply(new TopCollidersReplyEventArgs((int)m.TotalObjectCount, Tasks)); |
||
972 | } |
||
973 | } |
||
974 | #endregion |
||
975 | } |
||
976 | #region EstateTools EventArgs Classes |
||
977 | |||
978 | /// <summary>Raised on LandStatReply when the report type is for "top colliders"</summary> |
||
979 | public class TopCollidersReplyEventArgs : EventArgs |
||
980 | { |
||
981 | private readonly int m_objectCount; |
||
982 | private readonly Dictionary<UUID, EstateTask> m_Tasks; |
||
983 | |||
984 | /// <summary> |
||
985 | /// The number of returned items in LandStatReply |
||
986 | /// </summary> |
||
987 | public int ObjectCount { get { return m_objectCount; } } |
||
988 | /// <summary> |
||
989 | /// A Dictionary of Object UUIDs to tasks returned in LandStatReply |
||
990 | /// </summary> |
||
991 | public Dictionary<UUID, EstateTask> Tasks { get { return m_Tasks; } } |
||
992 | |||
993 | /// <summary>Construct a new instance of the TopCollidersReplyEventArgs class</summary> |
||
994 | /// <param name="objectCount">The number of returned items in LandStatReply</param> |
||
995 | /// <param name="tasks">Dictionary of Object UUIDs to tasks returned in LandStatReply</param> |
||
996 | public TopCollidersReplyEventArgs(int objectCount, Dictionary<UUID, EstateTask> tasks) |
||
997 | { |
||
998 | this.m_objectCount = objectCount; |
||
999 | this.m_Tasks = tasks; |
||
1000 | } |
||
1001 | } |
||
1002 | |||
1003 | /// <summary>Raised on LandStatReply when the report type is for "top Scripts"</summary> |
||
1004 | public class TopScriptsReplyEventArgs : EventArgs |
||
1005 | { |
||
1006 | private readonly int m_objectCount; |
||
1007 | private readonly Dictionary<UUID, EstateTask> m_Tasks; |
||
1008 | |||
1009 | /// <summary> |
||
1010 | /// The number of scripts returned in LandStatReply |
||
1011 | /// </summary> |
||
1012 | public int ObjectCount { get { return m_objectCount; } } |
||
1013 | /// <summary> |
||
1014 | /// A Dictionary of Object UUIDs to tasks returned in LandStatReply |
||
1015 | /// </summary> |
||
1016 | public Dictionary<UUID, EstateTask> Tasks { get { return m_Tasks; } } |
||
1017 | |||
1018 | /// <summary>Construct a new instance of the TopScriptsReplyEventArgs class</summary> |
||
1019 | /// <param name="objectCount">The number of returned items in LandStatReply</param> |
||
1020 | /// <param name="tasks">Dictionary of Object UUIDs to tasks returned in LandStatReply</param> |
||
1021 | public TopScriptsReplyEventArgs(int objectCount, Dictionary<UUID, EstateTask> tasks) |
||
1022 | { |
||
1023 | this.m_objectCount = objectCount; |
||
1024 | this.m_Tasks = tasks; |
||
1025 | } |
||
1026 | } |
||
1027 | |||
1028 | /// <summary>Returned, along with other info, upon a successful .RequestInfo()</summary> |
||
1029 | public class EstateBansReplyEventArgs : EventArgs |
||
1030 | { |
||
1031 | private readonly uint m_estateID; |
||
1032 | private readonly int m_count; |
||
1033 | private readonly List<UUID> m_banned; |
||
1034 | |||
1035 | /// <summary> |
||
1036 | /// The identifier of the estate |
||
1037 | /// </summary> |
||
1038 | public uint EstateID { get { return m_estateID; } } |
||
1039 | /// <summary> |
||
1040 | /// The number of returned itmes |
||
1041 | /// </summary> |
||
1042 | public int Count { get { return m_count; } } |
||
1043 | /// <summary> |
||
1044 | /// List of UUIDs of Banned Users |
||
1045 | /// </summary> |
||
1046 | public List<UUID> Banned { get { return m_banned; } } |
||
1047 | |||
1048 | /// <summary>Construct a new instance of the EstateBansReplyEventArgs class</summary> |
||
1049 | /// <param name="estateID">The estate's identifier on the grid</param> |
||
1050 | /// <param name="count">The number of returned items in LandStatReply</param> |
||
1051 | /// <param name="banned">User UUIDs banned</param> |
||
1052 | public EstateBansReplyEventArgs(uint estateID, int count, List<UUID> banned) |
||
1053 | { |
||
1054 | this.m_estateID = estateID; |
||
1055 | this.m_count = count; |
||
1056 | this.m_banned = banned; |
||
1057 | } |
||
1058 | } |
||
1059 | |||
1060 | /// <summary>Returned, along with other info, upon a successful .RequestInfo()</summary> |
||
1061 | public class EstateUsersReplyEventArgs : EventArgs |
||
1062 | { |
||
1063 | private readonly uint m_estateID; |
||
1064 | private readonly int m_count; |
||
1065 | private readonly List<UUID> m_allowedUsers; |
||
1066 | |||
1067 | /// <summary> |
||
1068 | /// The identifier of the estate |
||
1069 | /// </summary> |
||
1070 | public uint EstateID { get { return m_estateID; } } |
||
1071 | /// <summary> |
||
1072 | /// The number of returned items |
||
1073 | /// </summary> |
||
1074 | public int Count { get { return m_count; } } |
||
1075 | /// <summary> |
||
1076 | /// List of UUIDs of Allowed Users |
||
1077 | /// </summary> |
||
1078 | public List<UUID> AllowedUsers { get { return m_allowedUsers; } } |
||
1079 | |||
1080 | /// <summary>Construct a new instance of the EstateUsersReplyEventArgs class</summary> |
||
1081 | /// <param name="estateID">The estate's identifier on the grid</param> |
||
1082 | /// <param name="count">The number of users</param> |
||
1083 | /// <param name="allowedUsers">Allowed users UUIDs</param> |
||
1084 | public EstateUsersReplyEventArgs(uint estateID, int count, List<UUID> allowedUsers) |
||
1085 | { |
||
1086 | this.m_estateID = estateID; |
||
1087 | this.m_count = count; |
||
1088 | this.m_allowedUsers = allowedUsers; |
||
1089 | } |
||
1090 | } |
||
1091 | |||
1092 | /// <summary>Returned, along with other info, upon a successful .RequestInfo()</summary> |
||
1093 | public class EstateGroupsReplyEventArgs : EventArgs |
||
1094 | { |
||
1095 | private readonly uint m_estateID; |
||
1096 | private readonly int m_count; |
||
1097 | private readonly List<UUID> m_allowedGroups; |
||
1098 | |||
1099 | /// <summary> |
||
1100 | /// The identifier of the estate |
||
1101 | /// </summary> |
||
1102 | public uint EstateID { get { return m_estateID; } } |
||
1103 | /// <summary> |
||
1104 | /// The number of returned items |
||
1105 | /// </summary> |
||
1106 | public int Count { get { return m_count; } } |
||
1107 | /// <summary> |
||
1108 | /// List of UUIDs of Allowed Groups |
||
1109 | /// </summary> |
||
1110 | public List<UUID> AllowedGroups { get { return m_allowedGroups; } } |
||
1111 | |||
1112 | /// <summary>Construct a new instance of the EstateGroupsReplyEventArgs class</summary> |
||
1113 | /// <param name="estateID">The estate's identifier on the grid</param> |
||
1114 | /// <param name="count">The number of Groups</param> |
||
1115 | /// <param name="allowedGroups">Allowed Groups UUIDs</param> |
||
1116 | public EstateGroupsReplyEventArgs(uint estateID, int count, List<UUID> allowedGroups) |
||
1117 | { |
||
1118 | this.m_estateID = estateID; |
||
1119 | this.m_count = count; |
||
1120 | this.m_allowedGroups = allowedGroups; |
||
1121 | } |
||
1122 | } |
||
1123 | |||
1124 | /// <summary>Returned, along with other info, upon a successful .RequestInfo()</summary> |
||
1125 | public class EstateManagersReplyEventArgs : EventArgs |
||
1126 | { |
||
1127 | private readonly uint m_estateID; |
||
1128 | private readonly int m_count; |
||
1129 | private readonly List<UUID> m_Managers; |
||
1130 | |||
1131 | /// <summary> |
||
1132 | /// The identifier of the estate |
||
1133 | /// </summary> |
||
1134 | public uint EstateID { get { return m_estateID; } } |
||
1135 | /// <summary> |
||
1136 | /// The number of returned items |
||
1137 | /// </summary> |
||
1138 | public int Count { get { return m_count; } } |
||
1139 | /// <summary> |
||
1140 | /// List of UUIDs of the Estate's Managers |
||
1141 | /// </summary> |
||
1142 | public List<UUID> Managers { get { return m_Managers; } } |
||
1143 | |||
1144 | /// <summary>Construct a new instance of the EstateManagersReplyEventArgs class</summary> |
||
1145 | /// <param name="estateID">The estate's identifier on the grid</param> |
||
1146 | /// <param name="count">The number of Managers</param> |
||
1147 | /// <param name="managers"> Managers UUIDs</param> |
||
1148 | public EstateManagersReplyEventArgs(uint estateID, int count, List<UUID> managers) |
||
1149 | { |
||
1150 | this.m_estateID = estateID; |
||
1151 | this.m_count = count; |
||
1152 | this.m_Managers = managers; |
||
1153 | } |
||
1154 | } |
||
1155 | |||
1156 | /// <summary>Returned, along with other info, upon a successful .RequestInfo()</summary> |
||
1157 | public class EstateCovenantReplyEventArgs : EventArgs |
||
1158 | { |
||
1159 | private readonly UUID m_covenantID; |
||
1160 | private readonly long m_timestamp; |
||
1161 | private readonly string m_estateName; |
||
1162 | private readonly UUID m_estateOwnerID; |
||
1163 | |||
1164 | /// <summary> |
||
1165 | /// The Covenant |
||
1166 | /// </summary> |
||
1167 | public UUID CovenantID { get { return m_covenantID; } } |
||
1168 | /// <summary> |
||
1169 | /// The timestamp |
||
1170 | /// </summary> |
||
1171 | public long Timestamp { get { return m_timestamp; } } |
||
1172 | /// <summary> |
||
1173 | /// The Estate name |
||
1174 | /// </summary> |
||
1175 | public String EstateName { get { return m_estateName; } } |
||
1176 | /// <summary> |
||
1177 | /// The Estate Owner's ID (can be a GroupID) |
||
1178 | /// </summary> |
||
1179 | public UUID EstateOwnerID { get { return m_estateOwnerID; } } |
||
1180 | |||
1181 | /// <summary>Construct a new instance of the EstateCovenantReplyEventArgs class</summary> |
||
1182 | /// <param name="covenantID">The Covenant ID</param> |
||
1183 | /// <param name="timestamp">The timestamp</param> |
||
1184 | /// <param name="estateName">The estate's name</param> |
||
1185 | /// <param name="estateOwnerID">The Estate Owner's ID (can be a GroupID)</param> |
||
1186 | public EstateCovenantReplyEventArgs(UUID covenantID, long timestamp, string estateName, UUID estateOwnerID) |
||
1187 | { |
||
1188 | this.m_covenantID = covenantID; |
||
1189 | this.m_timestamp = timestamp; |
||
1190 | this.m_estateName = estateName; |
||
1191 | this.m_estateOwnerID = estateOwnerID; |
||
1192 | |||
1193 | } |
||
1194 | } |
||
1195 | |||
1196 | |||
1197 | /// <summary>Returned, along with other info, upon a successful .RequestInfo()</summary> |
||
1198 | public class EstateUpdateInfoReplyEventArgs : EventArgs |
||
1199 | { |
||
1200 | private readonly uint m_estateID; |
||
1201 | private readonly bool m_denyNoPaymentInfo; |
||
1202 | private readonly string m_estateName; |
||
1203 | private readonly UUID m_estateOwner; |
||
1204 | |||
1205 | /// <summary> |
||
1206 | /// The estate's name |
||
1207 | /// </summary> |
||
1208 | public String EstateName { get { return m_estateName; } } |
||
1209 | /// <summary> |
||
1210 | /// The Estate Owner's ID (can be a GroupID) |
||
1211 | /// </summary> |
||
1212 | public UUID EstateOwner { get { return m_estateOwner; } } |
||
1213 | /// <summary> |
||
1214 | /// The identifier of the estate on the grid |
||
1215 | /// </summary> |
||
1216 | public uint EstateID { get { return m_estateID; } } |
||
1217 | /// <summary></summary> |
||
1218 | public bool DenyNoPaymentInfo { get { return m_denyNoPaymentInfo; } } |
||
1219 | |||
1220 | /// <summary>Construct a new instance of the EstateUpdateInfoReplyEventArgs class</summary> |
||
1221 | /// <param name="estateName">The estate's name</param> |
||
1222 | /// <param name="estateOwner">The Estate Owners ID (can be a GroupID)</param> |
||
1223 | /// <param name="estateID">The estate's identifier on the grid</param> |
||
1224 | /// <param name="denyNoPaymentInfo"></param> |
||
1225 | public EstateUpdateInfoReplyEventArgs(string estateName, UUID estateOwner, uint estateID, bool denyNoPaymentInfo) |
||
1226 | { |
||
1227 | this.m_estateName = estateName; |
||
1228 | this.m_estateOwner = estateOwner; |
||
1229 | this.m_estateID = estateID; |
||
1230 | this.m_denyNoPaymentInfo = denyNoPaymentInfo; |
||
1231 | |||
1232 | } |
||
1233 | } |
||
1234 | #endregion |
||
1235 | } |