EventQueueHelper.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  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. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Net;
  29. using OpenMetaverse;
  30. using OpenMetaverse.Packets;
  31. using OpenMetaverse.StructuredData;
  32. namespace OpenSim.Region.CoreModules.Framework.EventQueue
  33. {
  34. public class EventQueueHelper
  35. {
  36. private EventQueueHelper() {} // no construction possible, it's an utility class
  37. private static byte[] ulongToByteArray(ulong uLongValue)
  38. {
  39. // Reverse endianness of RegionHandle
  40. return new byte[]
  41. {
  42. (byte)((uLongValue >> 56) % 256),
  43. (byte)((uLongValue >> 48) % 256),
  44. (byte)((uLongValue >> 40) % 256),
  45. (byte)((uLongValue >> 32) % 256),
  46. (byte)((uLongValue >> 24) % 256),
  47. (byte)((uLongValue >> 16) % 256),
  48. (byte)((uLongValue >> 8) % 256),
  49. (byte)(uLongValue % 256)
  50. };
  51. }
  52. private static byte[] uintToByteArray(uint uIntValue)
  53. {
  54. byte[] resultbytes = Utils.UIntToBytes(uIntValue);
  55. if (BitConverter.IsLittleEndian)
  56. Array.Reverse(resultbytes);
  57. return resultbytes;
  58. }
  59. public static OSD buildEvent(string eventName, OSD eventBody)
  60. {
  61. OSDMap llsdEvent = new OSDMap(2);
  62. llsdEvent.Add("message", new OSDString(eventName));
  63. llsdEvent.Add("body", eventBody);
  64. return llsdEvent;
  65. }
  66. public static OSD EnableSimulator(ulong handle, IPEndPoint endPoint)
  67. {
  68. OSDMap llsdSimInfo = new OSDMap(3);
  69. llsdSimInfo.Add("Handle", new OSDBinary(ulongToByteArray(handle)));
  70. llsdSimInfo.Add("IP", new OSDBinary(endPoint.Address.GetAddressBytes()));
  71. llsdSimInfo.Add("Port", new OSDInteger(endPoint.Port));
  72. OSDArray arr = new OSDArray(1);
  73. arr.Add(llsdSimInfo);
  74. OSDMap llsdBody = new OSDMap(1);
  75. llsdBody.Add("SimulatorInfo", arr);
  76. return buildEvent("EnableSimulator", llsdBody);
  77. }
  78. public static OSD DisableSimulator(ulong handle)
  79. {
  80. //OSDMap llsdSimInfo = new OSDMap(1);
  81. //llsdSimInfo.Add("Handle", new OSDBinary(regionHandleToByteArray(handle)));
  82. //OSDArray arr = new OSDArray(1);
  83. //arr.Add(llsdSimInfo);
  84. OSDMap llsdBody = new OSDMap(0);
  85. //llsdBody.Add("SimulatorInfo", arr);
  86. return buildEvent("DisableSimulator", llsdBody);
  87. }
  88. public static OSD CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt,
  89. IPEndPoint newRegionExternalEndPoint,
  90. string capsURL, UUID agentID, UUID sessionID)
  91. {
  92. OSDArray lookAtArr = new OSDArray(3);
  93. lookAtArr.Add(OSD.FromReal(lookAt.X));
  94. lookAtArr.Add(OSD.FromReal(lookAt.Y));
  95. lookAtArr.Add(OSD.FromReal(lookAt.Z));
  96. OSDArray positionArr = new OSDArray(3);
  97. positionArr.Add(OSD.FromReal(pos.X));
  98. positionArr.Add(OSD.FromReal(pos.Y));
  99. positionArr.Add(OSD.FromReal(pos.Z));
  100. OSDMap infoMap = new OSDMap(2);
  101. infoMap.Add("LookAt", lookAtArr);
  102. infoMap.Add("Position", positionArr);
  103. OSDArray infoArr = new OSDArray(1);
  104. infoArr.Add(infoMap);
  105. OSDMap agentDataMap = new OSDMap(2);
  106. agentDataMap.Add("AgentID", OSD.FromUUID(agentID));
  107. agentDataMap.Add("SessionID", OSD.FromUUID(sessionID));
  108. OSDArray agentDataArr = new OSDArray(1);
  109. agentDataArr.Add(agentDataMap);
  110. OSDMap regionDataMap = new OSDMap(4);
  111. regionDataMap.Add("RegionHandle", OSD.FromBinary(ulongToByteArray(handle)));
  112. regionDataMap.Add("SeedCapability", OSD.FromString(capsURL));
  113. regionDataMap.Add("SimIP", OSD.FromBinary(newRegionExternalEndPoint.Address.GetAddressBytes()));
  114. regionDataMap.Add("SimPort", OSD.FromInteger(newRegionExternalEndPoint.Port));
  115. OSDArray regionDataArr = new OSDArray(1);
  116. regionDataArr.Add(regionDataMap);
  117. OSDMap llsdBody = new OSDMap(3);
  118. llsdBody.Add("Info", infoArr);
  119. llsdBody.Add("AgentData", agentDataArr);
  120. llsdBody.Add("RegionData", regionDataArr);
  121. return buildEvent("CrossedRegion", llsdBody);
  122. }
  123. public static OSD TeleportFinishEvent(
  124. ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint,
  125. uint locationID, uint flags, string capsURL, UUID agentID)
  126. {
  127. OSDMap info = new OSDMap();
  128. info.Add("AgentID", OSD.FromUUID(agentID));
  129. info.Add("LocationID", OSD.FromInteger(4)); // TODO what is this?
  130. info.Add("RegionHandle", OSD.FromBinary(ulongToByteArray(regionHandle)));
  131. info.Add("SeedCapability", OSD.FromString(capsURL));
  132. info.Add("SimAccess", OSD.FromInteger(simAccess));
  133. info.Add("SimIP", OSD.FromBinary(regionExternalEndPoint.Address.GetAddressBytes()));
  134. info.Add("SimPort", OSD.FromInteger(regionExternalEndPoint.Port));
  135. info.Add("TeleportFlags", OSD.FromBinary(1L << 4)); // AgentManager.TeleportFlags.ViaLocation
  136. OSDArray infoArr = new OSDArray();
  137. infoArr.Add(info);
  138. OSDMap body = new OSDMap();
  139. body.Add("Info", infoArr);
  140. return buildEvent("TeleportFinish", body);
  141. }
  142. public static OSD ScriptRunningReplyEvent(UUID objectID, UUID itemID, bool running, bool mono)
  143. {
  144. OSDMap script = new OSDMap();
  145. script.Add("ObjectID", OSD.FromUUID(objectID));
  146. script.Add("ItemID", OSD.FromUUID(itemID));
  147. script.Add("Running", OSD.FromBoolean(running));
  148. script.Add("Mono", OSD.FromBoolean(mono));
  149. OSDArray scriptArr = new OSDArray();
  150. scriptArr.Add(script);
  151. OSDMap body = new OSDMap();
  152. body.Add("Script", scriptArr);
  153. return buildEvent("ScriptRunningReply", body);
  154. }
  155. public static OSD EstablishAgentCommunication(UUID agentID, string simIpAndPort, string seedcap)
  156. {
  157. OSDMap body = new OSDMap(3);
  158. body.Add("agent-id", new OSDUUID(agentID));
  159. body.Add("sim-ip-and-port", new OSDString(simIpAndPort));
  160. body.Add("seed-capability", new OSDString(seedcap));
  161. return buildEvent("EstablishAgentCommunication", body);
  162. }
  163. public static OSD KeepAliveEvent()
  164. {
  165. return buildEvent("FAKEEVENT", new OSDMap());
  166. }
  167. public static OSD AgentParams(UUID agentID, bool checkEstate, int godLevel, bool limitedToEstate)
  168. {
  169. OSDMap body = new OSDMap(4);
  170. body.Add("agent_id", new OSDUUID(agentID));
  171. body.Add("check_estate", new OSDInteger(checkEstate ? 1 : 0));
  172. body.Add("god_level", new OSDInteger(godLevel));
  173. body.Add("limited_to_estate", new OSDInteger(limitedToEstate ? 1 : 0));
  174. return body;
  175. }
  176. public static OSD InstantMessageParams(UUID fromAgent, string message, UUID toAgent,
  177. string fromName, byte dialog, uint timeStamp, bool offline, int parentEstateID,
  178. Vector3 position, uint ttl, UUID transactionID, bool fromGroup, byte[] binaryBucket)
  179. {
  180. OSDMap messageParams = new OSDMap(15);
  181. messageParams.Add("type", new OSDInteger((int)dialog));
  182. OSDArray positionArray = new OSDArray(3);
  183. positionArray.Add(OSD.FromReal(position.X));
  184. positionArray.Add(OSD.FromReal(position.Y));
  185. positionArray.Add(OSD.FromReal(position.Z));
  186. messageParams.Add("position", positionArray);
  187. messageParams.Add("region_id", new OSDUUID(UUID.Zero));
  188. messageParams.Add("to_id", new OSDUUID(toAgent));
  189. messageParams.Add("source", new OSDInteger(0));
  190. OSDMap data = new OSDMap(1);
  191. data.Add("binary_bucket", OSD.FromBinary(binaryBucket));
  192. messageParams.Add("data", data);
  193. messageParams.Add("message", new OSDString(message));
  194. messageParams.Add("id", new OSDUUID(transactionID));
  195. messageParams.Add("from_name", new OSDString(fromName));
  196. messageParams.Add("timestamp", new OSDInteger((int)timeStamp));
  197. messageParams.Add("offline", new OSDInteger(offline ? 1 : 0));
  198. messageParams.Add("parent_estate_id", new OSDInteger(parentEstateID));
  199. messageParams.Add("ttl", new OSDInteger((int)ttl));
  200. messageParams.Add("from_id", new OSDUUID(fromAgent));
  201. messageParams.Add("from_group", new OSDInteger(fromGroup ? 1 : 0));
  202. return messageParams;
  203. }
  204. public static OSD InstantMessage(UUID fromAgent, string message, UUID toAgent,
  205. string fromName, byte dialog, uint timeStamp, bool offline, int parentEstateID,
  206. Vector3 position, uint ttl, UUID transactionID, bool fromGroup, byte[] binaryBucket,
  207. bool checkEstate, int godLevel, bool limitedToEstate)
  208. {
  209. OSDMap im = new OSDMap(2);
  210. im.Add("message_params", InstantMessageParams(fromAgent, message, toAgent,
  211. fromName, dialog, timeStamp, offline, parentEstateID,
  212. position, ttl, transactionID, fromGroup, binaryBucket));
  213. im.Add("agent_params", AgentParams(fromAgent, checkEstate, godLevel, limitedToEstate));
  214. return im;
  215. }
  216. public static OSD ChatterboxInvitation(UUID sessionID, string sessionName,
  217. UUID fromAgent, string message, UUID toAgent, string fromName, byte dialog,
  218. uint timeStamp, bool offline, int parentEstateID, Vector3 position,
  219. uint ttl, UUID transactionID, bool fromGroup, byte[] binaryBucket)
  220. {
  221. OSDMap body = new OSDMap(5);
  222. body.Add("session_id", new OSDUUID(sessionID));
  223. body.Add("from_name", new OSDString(fromName));
  224. body.Add("session_name", new OSDString(sessionName));
  225. body.Add("from_id", new OSDUUID(fromAgent));
  226. body.Add("instantmessage", InstantMessage(fromAgent, message, toAgent,
  227. fromName, dialog, timeStamp, offline, parentEstateID, position,
  228. ttl, transactionID, fromGroup, binaryBucket, true, 0, true));
  229. OSDMap chatterboxInvitation = new OSDMap(2);
  230. chatterboxInvitation.Add("message", new OSDString("ChatterBoxInvitation"));
  231. chatterboxInvitation.Add("body", body);
  232. return chatterboxInvitation;
  233. }
  234. public static OSD ChatterBoxSessionAgentListUpdates(UUID sessionID,
  235. UUID agentID, bool canVoiceChat, bool isModerator, bool textMute)
  236. {
  237. OSDMap body = new OSDMap();
  238. OSDMap agentUpdates = new OSDMap();
  239. OSDMap infoDetail = new OSDMap();
  240. OSDMap mutes = new OSDMap();
  241. mutes.Add("text", OSD.FromBoolean(textMute));
  242. infoDetail.Add("can_voice_chat", OSD.FromBoolean(canVoiceChat));
  243. infoDetail.Add("is_moderator", OSD.FromBoolean(isModerator));
  244. infoDetail.Add("mutes", mutes);
  245. OSDMap info = new OSDMap();
  246. info.Add("info", infoDetail);
  247. agentUpdates.Add(agentID.ToString(), info);
  248. body.Add("agent_updates", agentUpdates);
  249. body.Add("session_id", OSD.FromUUID(sessionID));
  250. body.Add("updates", new OSD());
  251. OSDMap chatterBoxSessionAgentListUpdates = new OSDMap();
  252. chatterBoxSessionAgentListUpdates.Add("message", OSD.FromString("ChatterBoxSessionAgentListUpdates"));
  253. chatterBoxSessionAgentListUpdates.Add("body", body);
  254. return chatterBoxSessionAgentListUpdates;
  255. }
  256. public static OSD ParcelProperties(ParcelPropertiesPacket parcelPropertiesPacket)
  257. {
  258. OSDMap parcelProperties = new OSDMap();
  259. OSDMap body = new OSDMap();
  260. OSDArray ageVerificationBlock = new OSDArray();
  261. OSDMap ageVerificationMap = new OSDMap();
  262. ageVerificationMap.Add("RegionDenyAgeUnverified",
  263. OSD.FromBoolean(parcelPropertiesPacket.AgeVerificationBlock.RegionDenyAgeUnverified));
  264. ageVerificationBlock.Add(ageVerificationMap);
  265. body.Add("AgeVerificationBlock", ageVerificationBlock);
  266. // LL sims send media info in this event queue message but it's not in the UDP
  267. // packet we construct this event queue message from. This should be refactored in
  268. // other areas of the code so it can all be send in the same message. Until then we will
  269. // still send the media info via UDP
  270. //OSDArray mediaData = new OSDArray();
  271. //OSDMap mediaDataMap = new OSDMap();
  272. //mediaDataMap.Add("MediaDesc", OSD.FromString(""));
  273. //mediaDataMap.Add("MediaHeight", OSD.FromInteger(0));
  274. //mediaDataMap.Add("MediaLoop", OSD.FromInteger(0));
  275. //mediaDataMap.Add("MediaType", OSD.FromString("type/type"));
  276. //mediaDataMap.Add("MediaWidth", OSD.FromInteger(0));
  277. //mediaDataMap.Add("ObscureMedia", OSD.FromInteger(0));
  278. //mediaDataMap.Add("ObscureMusic", OSD.FromInteger(0));
  279. //mediaData.Add(mediaDataMap);
  280. //body.Add("MediaData", mediaData);
  281. OSDArray parcelData = new OSDArray();
  282. OSDMap parcelDataMap = new OSDMap();
  283. OSDArray AABBMax = new OSDArray(3);
  284. AABBMax.Add(OSD.FromReal(parcelPropertiesPacket.ParcelData.AABBMax.X));
  285. AABBMax.Add(OSD.FromReal(parcelPropertiesPacket.ParcelData.AABBMax.Y));
  286. AABBMax.Add(OSD.FromReal(parcelPropertiesPacket.ParcelData.AABBMax.Z));
  287. parcelDataMap.Add("AABBMax", AABBMax);
  288. OSDArray AABBMin = new OSDArray(3);
  289. AABBMin.Add(OSD.FromReal(parcelPropertiesPacket.ParcelData.AABBMin.X));
  290. AABBMin.Add(OSD.FromReal(parcelPropertiesPacket.ParcelData.AABBMin.Y));
  291. AABBMin.Add(OSD.FromReal(parcelPropertiesPacket.ParcelData.AABBMin.Z));
  292. parcelDataMap.Add("AABBMin", AABBMin);
  293. parcelDataMap.Add("Area", OSD.FromInteger(parcelPropertiesPacket.ParcelData.Area));
  294. parcelDataMap.Add("AuctionID", OSD.FromBinary(uintToByteArray(parcelPropertiesPacket.ParcelData.AuctionID)));
  295. parcelDataMap.Add("AuthBuyerID", OSD.FromUUID(parcelPropertiesPacket.ParcelData.AuthBuyerID));
  296. parcelDataMap.Add("Bitmap", OSD.FromBinary(parcelPropertiesPacket.ParcelData.Bitmap));
  297. parcelDataMap.Add("Category", OSD.FromInteger((int)parcelPropertiesPacket.ParcelData.Category));
  298. parcelDataMap.Add("ClaimDate", OSD.FromInteger(parcelPropertiesPacket.ParcelData.ClaimDate));
  299. parcelDataMap.Add("ClaimPrice", OSD.FromInteger(parcelPropertiesPacket.ParcelData.ClaimPrice));
  300. parcelDataMap.Add("Desc", OSD.FromString(Utils.BytesToString(parcelPropertiesPacket.ParcelData.Desc)));
  301. parcelDataMap.Add("GroupID", OSD.FromUUID(parcelPropertiesPacket.ParcelData.GroupID));
  302. parcelDataMap.Add("GroupPrims", OSD.FromInteger(parcelPropertiesPacket.ParcelData.GroupPrims));
  303. parcelDataMap.Add("IsGroupOwned", OSD.FromBoolean(parcelPropertiesPacket.ParcelData.IsGroupOwned));
  304. parcelDataMap.Add("LandingType", OSD.FromInteger(parcelPropertiesPacket.ParcelData.LandingType));
  305. parcelDataMap.Add("LocalID", OSD.FromInteger(parcelPropertiesPacket.ParcelData.LocalID));
  306. parcelDataMap.Add("MaxPrims", OSD.FromInteger(parcelPropertiesPacket.ParcelData.MaxPrims));
  307. parcelDataMap.Add("MediaAutoScale", OSD.FromInteger((int)parcelPropertiesPacket.ParcelData.MediaAutoScale));
  308. parcelDataMap.Add("MediaID", OSD.FromUUID(parcelPropertiesPacket.ParcelData.MediaID));
  309. parcelDataMap.Add("MediaURL", OSD.FromString(Utils.BytesToString(parcelPropertiesPacket.ParcelData.MediaURL)));
  310. parcelDataMap.Add("MusicURL", OSD.FromString(Utils.BytesToString(parcelPropertiesPacket.ParcelData.MusicURL)));
  311. parcelDataMap.Add("Name", OSD.FromString(Utils.BytesToString(parcelPropertiesPacket.ParcelData.Name)));
  312. parcelDataMap.Add("OtherCleanTime", OSD.FromInteger(parcelPropertiesPacket.ParcelData.OtherCleanTime));
  313. parcelDataMap.Add("OtherCount", OSD.FromInteger(parcelPropertiesPacket.ParcelData.OtherCount));
  314. parcelDataMap.Add("OtherPrims", OSD.FromInteger(parcelPropertiesPacket.ParcelData.OtherPrims));
  315. parcelDataMap.Add("OwnerID", OSD.FromUUID(parcelPropertiesPacket.ParcelData.OwnerID));
  316. parcelDataMap.Add("OwnerPrims", OSD.FromInteger(parcelPropertiesPacket.ParcelData.OwnerPrims));
  317. parcelDataMap.Add("ParcelFlags", OSD.FromBinary(uintToByteArray(parcelPropertiesPacket.ParcelData.ParcelFlags)));
  318. parcelDataMap.Add("ParcelPrimBonus", OSD.FromReal(parcelPropertiesPacket.ParcelData.ParcelPrimBonus));
  319. parcelDataMap.Add("PassHours", OSD.FromReal(parcelPropertiesPacket.ParcelData.PassHours));
  320. parcelDataMap.Add("PassPrice", OSD.FromInteger(parcelPropertiesPacket.ParcelData.PassPrice));
  321. parcelDataMap.Add("PublicCount", OSD.FromInteger(parcelPropertiesPacket.ParcelData.PublicCount));
  322. parcelDataMap.Add("RegionDenyAnonymous", OSD.FromBoolean(parcelPropertiesPacket.ParcelData.RegionDenyAnonymous));
  323. parcelDataMap.Add("RegionDenyIdentified", OSD.FromBoolean(parcelPropertiesPacket.ParcelData.RegionDenyIdentified));
  324. parcelDataMap.Add("RegionDenyTransacted", OSD.FromBoolean(parcelPropertiesPacket.ParcelData.RegionDenyTransacted));
  325. parcelDataMap.Add("RegionPushOverride", OSD.FromBoolean(parcelPropertiesPacket.ParcelData.RegionPushOverride));
  326. parcelDataMap.Add("RentPrice", OSD.FromInteger(parcelPropertiesPacket.ParcelData.RentPrice));
  327. parcelDataMap.Add("RequestResult", OSD.FromInteger(parcelPropertiesPacket.ParcelData.RequestResult));
  328. parcelDataMap.Add("SalePrice", OSD.FromInteger(parcelPropertiesPacket.ParcelData.SalePrice));
  329. parcelDataMap.Add("SelectedPrims", OSD.FromInteger(parcelPropertiesPacket.ParcelData.SelectedPrims));
  330. parcelDataMap.Add("SelfCount", OSD.FromInteger(parcelPropertiesPacket.ParcelData.SelfCount));
  331. parcelDataMap.Add("SequenceID", OSD.FromInteger(parcelPropertiesPacket.ParcelData.SequenceID));
  332. parcelDataMap.Add("SimWideMaxPrims", OSD.FromInteger(parcelPropertiesPacket.ParcelData.SimWideMaxPrims));
  333. parcelDataMap.Add("SimWideTotalPrims", OSD.FromInteger(parcelPropertiesPacket.ParcelData.SimWideTotalPrims));
  334. parcelDataMap.Add("SnapSelection", OSD.FromBoolean(parcelPropertiesPacket.ParcelData.SnapSelection));
  335. parcelDataMap.Add("SnapshotID", OSD.FromUUID(parcelPropertiesPacket.ParcelData.SnapshotID));
  336. parcelDataMap.Add("Status", OSD.FromInteger((int)parcelPropertiesPacket.ParcelData.Status));
  337. parcelDataMap.Add("TotalPrims", OSD.FromInteger(parcelPropertiesPacket.ParcelData.TotalPrims));
  338. OSDArray UserLocation = new OSDArray(3);
  339. UserLocation.Add(OSD.FromReal(parcelPropertiesPacket.ParcelData.UserLocation.X));
  340. UserLocation.Add(OSD.FromReal(parcelPropertiesPacket.ParcelData.UserLocation.Y));
  341. UserLocation.Add(OSD.FromReal(parcelPropertiesPacket.ParcelData.UserLocation.Z));
  342. parcelDataMap.Add("UserLocation", UserLocation);
  343. OSDArray UserLookAt = new OSDArray(3);
  344. UserLookAt.Add(OSD.FromReal(parcelPropertiesPacket.ParcelData.UserLookAt.X));
  345. UserLookAt.Add(OSD.FromReal(parcelPropertiesPacket.ParcelData.UserLookAt.Y));
  346. UserLookAt.Add(OSD.FromReal(parcelPropertiesPacket.ParcelData.UserLookAt.Z));
  347. parcelDataMap.Add("UserLookAt", UserLookAt);
  348. parcelData.Add(parcelDataMap);
  349. body.Add("ParcelData", parcelData);
  350. parcelProperties.Add("body", body);
  351. parcelProperties.Add("message", OSD.FromString("ParcelProperties"));
  352. return parcelProperties;
  353. }
  354. public static OSD GroupMembership(AgentGroupDataUpdatePacket groupUpdatePacket)
  355. {
  356. OSDMap groupUpdate = new OSDMap();
  357. groupUpdate.Add("message", OSD.FromString("AgentGroupDataUpdate"));
  358. OSDMap body = new OSDMap();
  359. OSDArray agentData = new OSDArray();
  360. OSDMap agentDataMap = new OSDMap();
  361. agentDataMap.Add("AgentID", OSD.FromUUID(groupUpdatePacket.AgentData.AgentID));
  362. agentData.Add(agentDataMap);
  363. body.Add("AgentData", agentData);
  364. OSDArray groupData = new OSDArray();
  365. foreach (AgentGroupDataUpdatePacket.GroupDataBlock groupDataBlock in groupUpdatePacket.GroupData)
  366. {
  367. OSDMap groupDataMap = new OSDMap();
  368. groupDataMap.Add("ListInProfile", OSD.FromBoolean(false));
  369. groupDataMap.Add("GroupID", OSD.FromUUID(groupDataBlock.GroupID));
  370. groupDataMap.Add("GroupInsigniaID", OSD.FromUUID(groupDataBlock.GroupInsigniaID));
  371. groupDataMap.Add("Contribution", OSD.FromInteger(groupDataBlock.Contribution));
  372. groupDataMap.Add("GroupPowers", OSD.FromBinary(ulongToByteArray(groupDataBlock.GroupPowers)));
  373. groupDataMap.Add("GroupName", OSD.FromString(Utils.BytesToString(groupDataBlock.GroupName)));
  374. groupDataMap.Add("AcceptNotices", OSD.FromBoolean(groupDataBlock.AcceptNotices));
  375. groupData.Add(groupDataMap);
  376. }
  377. body.Add("GroupData", groupData);
  378. groupUpdate.Add("body", body);
  379. return groupUpdate;
  380. }
  381. }
  382. }