LandData.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  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.Collections.Generic;
  29. using System.Xml;
  30. using System.Xml.Serialization;
  31. using OpenMetaverse;
  32. namespace OpenSim.Framework
  33. {
  34. /// <summary>
  35. /// Details of a Parcel of land
  36. /// </summary>
  37. public class LandData
  38. {
  39. // use only one serializer to give the runtime a chance to
  40. // optimize it (it won't do that if you use a new instance
  41. // every time)
  42. private static XmlSerializer serializer = new XmlSerializer(typeof (LandData));
  43. private Vector3 _AABBMax = new Vector3();
  44. private Vector3 _AABBMin = new Vector3();
  45. private int _area = 0;
  46. private uint _auctionID = 0; //Unemplemented. If set to 0, not being auctioned
  47. private UUID _authBuyerID = UUID.Zero; //Unemplemented. Authorized Buyer's UUID
  48. private ParcelCategory _category = ParcelCategory.None; //Unemplemented. Parcel's chosen category
  49. private int _claimDate = 0;
  50. private int _claimPrice = 0; //Unemplemented
  51. private UUID _globalID = UUID.Zero;
  52. private UUID _groupID = UUID.Zero;
  53. private bool _isGroupOwned = false;
  54. private byte[] _bitmap = new byte[512];
  55. private string _description = String.Empty;
  56. private uint _flags = (uint) ParcelFlags.AllowFly | (uint) ParcelFlags.AllowLandmark |
  57. (uint) ParcelFlags.AllowAPrimitiveEntry |
  58. (uint) ParcelFlags.AllowDeedToGroup | (uint) ParcelFlags.AllowTerraform |
  59. (uint) ParcelFlags.CreateObjects | (uint) ParcelFlags.AllowOtherScripts |
  60. (uint) ParcelFlags.SoundLocal;
  61. private byte _landingType = 0;
  62. private string _name = "Your Parcel";
  63. private ParcelStatus _status = ParcelStatus.Leased;
  64. private int _localID = 0;
  65. private byte _mediaAutoScale = 0;
  66. private UUID _mediaID = UUID.Zero;
  67. private string _mediaURL = String.Empty;
  68. private string _musicURL = String.Empty;
  69. private UUID _ownerID = UUID.Zero;
  70. private List<ParcelManager.ParcelAccessEntry> _parcelAccessList = new List<ParcelManager.ParcelAccessEntry>();
  71. private float _passHours = 0;
  72. private int _passPrice = 0;
  73. private int _salePrice = 0; //Unemeplemented. Parcels price.
  74. private int _simwideArea = 0;
  75. private int _simwidePrims = 0;
  76. private UUID _snapshotID = UUID.Zero;
  77. private Vector3 _userLocation = new Vector3();
  78. private Vector3 _userLookAt = new Vector3();
  79. private int _otherCleanTime = 0;
  80. private string _mediaType = "none/none";
  81. private string _mediaDescription = "";
  82. private int _mediaHeight = 0;
  83. private int _mediaWidth = 0;
  84. private bool _mediaLoop = false;
  85. private bool _obscureMusic = false;
  86. private bool _obscureMedia = false;
  87. /// <summary>
  88. /// Whether to obscure parcel media URL
  89. /// </summary>
  90. [XmlIgnore]
  91. public bool ObscureMedia {
  92. get {
  93. return _obscureMedia;
  94. }
  95. set {
  96. _obscureMedia = value;
  97. }
  98. }
  99. /// <summary>
  100. /// Whether to obscure parcel music URL
  101. /// </summary>
  102. [XmlIgnore]
  103. public bool ObscureMusic {
  104. get {
  105. return _obscureMusic;
  106. }
  107. set {
  108. _obscureMusic = value;
  109. }
  110. }
  111. /// <summary>
  112. /// Whether to loop parcel media
  113. /// </summary>
  114. [XmlIgnore]
  115. public bool MediaLoop {
  116. get {
  117. return _mediaLoop;
  118. }
  119. set {
  120. _mediaLoop = value;
  121. }
  122. }
  123. /// <summary>
  124. /// Height of parcel media render
  125. /// </summary>
  126. [XmlIgnore]
  127. public int MediaHeight {
  128. get {
  129. return _mediaHeight;
  130. }
  131. set {
  132. _mediaHeight = value;
  133. }
  134. }
  135. /// <summary>
  136. /// Width of parcel media render
  137. /// </summary>
  138. [XmlIgnore]
  139. public int MediaWidth {
  140. get {
  141. return _mediaWidth;
  142. }
  143. set {
  144. _mediaWidth = value;
  145. }
  146. }
  147. /// <summary>
  148. /// Upper corner of the AABB for the parcel
  149. /// </summary>
  150. [XmlIgnore]
  151. public Vector3 AABBMax {
  152. get {
  153. return _AABBMax;
  154. }
  155. set {
  156. _AABBMax = value;
  157. }
  158. }
  159. /// <summary>
  160. /// Lower corner of the AABB for the parcel
  161. /// </summary>
  162. [XmlIgnore]
  163. public Vector3 AABBMin {
  164. get {
  165. return _AABBMin;
  166. }
  167. set {
  168. _AABBMin = value;
  169. }
  170. }
  171. /// <summary>
  172. /// Area in meters^2 the parcel contains
  173. /// </summary>
  174. public int Area {
  175. get {
  176. return _area;
  177. }
  178. set {
  179. _area = value;
  180. }
  181. }
  182. /// <summary>
  183. /// ID of auction (3rd Party Integration) when parcel is being auctioned
  184. /// </summary>
  185. public uint AuctionID {
  186. get {
  187. return _auctionID;
  188. }
  189. set {
  190. _auctionID = value;
  191. }
  192. }
  193. /// <summary>
  194. /// UUID of authorized buyer of parcel. This is UUID.Zero if anyone can buy it.
  195. /// </summary>
  196. public UUID AuthBuyerID {
  197. get {
  198. return _authBuyerID;
  199. }
  200. set {
  201. _authBuyerID = value;
  202. }
  203. }
  204. /// <summary>
  205. /// Category of parcel. Used for classifying the parcel in classified listings
  206. /// </summary>
  207. public ParcelCategory Category {
  208. get {
  209. return _category;
  210. }
  211. set {
  212. _category = value;
  213. }
  214. }
  215. /// <summary>
  216. /// Date that the current owner purchased or claimed the parcel
  217. /// </summary>
  218. public int ClaimDate {
  219. get {
  220. return _claimDate;
  221. }
  222. set {
  223. _claimDate = value;
  224. }
  225. }
  226. /// <summary>
  227. /// The last price that the parcel was sold at
  228. /// </summary>
  229. public int ClaimPrice {
  230. get {
  231. return _claimPrice;
  232. }
  233. set {
  234. _claimPrice = value;
  235. }
  236. }
  237. /// <summary>
  238. /// Global ID for the parcel. (3rd Party Integration)
  239. /// </summary>
  240. public UUID GlobalID {
  241. get {
  242. return _globalID;
  243. }
  244. set {
  245. _globalID = value;
  246. }
  247. }
  248. /// <summary>
  249. /// Unique ID of the Group that owns
  250. /// </summary>
  251. public UUID GroupID {
  252. get {
  253. return _groupID;
  254. }
  255. set {
  256. _groupID = value;
  257. }
  258. }
  259. /// <summary>
  260. /// Returns true if the Land Parcel is owned by a group
  261. /// </summary>
  262. public bool IsGroupOwned {
  263. get {
  264. return _isGroupOwned;
  265. }
  266. set {
  267. _isGroupOwned = value;
  268. }
  269. }
  270. /// <summary>
  271. /// jp2 data for the image representative of the parcel in the parcel dialog
  272. /// </summary>
  273. public byte[] Bitmap {
  274. get {
  275. return _bitmap;
  276. }
  277. set {
  278. _bitmap = value;
  279. }
  280. }
  281. /// <summary>
  282. /// Parcel Description
  283. /// </summary>
  284. public string Description {
  285. get {
  286. return _description;
  287. }
  288. set {
  289. _description = value;
  290. }
  291. }
  292. /// <summary>
  293. /// Parcel settings. Access flags, Fly, NoPush, Voice, Scripts allowed, etc. ParcelFlags
  294. /// </summary>
  295. public uint Flags {
  296. get {
  297. return _flags;
  298. }
  299. set {
  300. _flags = value;
  301. }
  302. }
  303. /// <summary>
  304. /// Determines if people are able to teleport where they please on the parcel or if they
  305. /// get constrainted to a specific point on teleport within the parcel
  306. /// </summary>
  307. public byte LandingType {
  308. get {
  309. return _landingType;
  310. }
  311. set {
  312. _landingType = value;
  313. }
  314. }
  315. /// <summary>
  316. /// Parcel Name
  317. /// </summary>
  318. public string Name {
  319. get {
  320. return _name;
  321. }
  322. set {
  323. _name = value;
  324. }
  325. }
  326. /// <summary>
  327. /// Status of Parcel, Leased, Abandoned, For Sale
  328. /// </summary>
  329. public ParcelStatus Status {
  330. get {
  331. return _status;
  332. }
  333. set {
  334. _status = value;
  335. }
  336. }
  337. /// <summary>
  338. /// Internal ID of the parcel. Sometimes the client will try to use this value
  339. /// </summary>
  340. public int LocalID {
  341. get {
  342. return _localID;
  343. }
  344. set {
  345. _localID = value;
  346. }
  347. }
  348. /// <summary>
  349. /// Determines if we scale the media based on the surface it's on
  350. /// </summary>
  351. public byte MediaAutoScale {
  352. get {
  353. return _mediaAutoScale;
  354. }
  355. set {
  356. _mediaAutoScale = value;
  357. }
  358. }
  359. /// <summary>
  360. /// Texture Guid to replace with the output of the media stream
  361. /// </summary>
  362. public UUID MediaID {
  363. get {
  364. return _mediaID;
  365. }
  366. set {
  367. _mediaID = value;
  368. }
  369. }
  370. /// <summary>
  371. /// URL to the media file to display
  372. /// </summary>
  373. public string MediaURL {
  374. get {
  375. return _mediaURL;
  376. }
  377. set {
  378. _mediaURL = value;
  379. }
  380. }
  381. public string MediaType
  382. {
  383. get
  384. {
  385. return _mediaType;
  386. }
  387. set
  388. {
  389. _mediaType = value;
  390. }
  391. }
  392. /// <summary>
  393. /// URL to the shoutcast music stream to play on the parcel
  394. /// </summary>
  395. public string MusicURL {
  396. get {
  397. return _musicURL;
  398. }
  399. set {
  400. _musicURL = value;
  401. }
  402. }
  403. /// <summary>
  404. /// Owner Avatar or Group of the parcel. Naturally, all land masses must be
  405. /// owned by someone
  406. /// </summary>
  407. public UUID OwnerID {
  408. get {
  409. return _ownerID;
  410. }
  411. set {
  412. _ownerID = value;
  413. }
  414. }
  415. /// <summary>
  416. /// List of access data for the parcel. User data, some bitflags, and a time
  417. /// </summary>
  418. public List<ParcelManager.ParcelAccessEntry> ParcelAccessList {
  419. get {
  420. return _parcelAccessList;
  421. }
  422. set {
  423. _parcelAccessList = value;
  424. }
  425. }
  426. /// <summary>
  427. /// How long in hours a Pass to the parcel is given
  428. /// </summary>
  429. public float PassHours {
  430. get {
  431. return _passHours;
  432. }
  433. set {
  434. _passHours = value;
  435. }
  436. }
  437. /// <summary>
  438. /// Price to purchase a Pass to a restricted parcel
  439. /// </summary>
  440. public int PassPrice {
  441. get {
  442. return _passPrice;
  443. }
  444. set {
  445. _passPrice = value;
  446. }
  447. }
  448. /// <summary>
  449. /// When the parcel is being sold, this is the price to purchase the parcel
  450. /// </summary>
  451. public int SalePrice {
  452. get {
  453. return _salePrice;
  454. }
  455. set {
  456. _salePrice = value;
  457. }
  458. }
  459. /// <summary>
  460. /// Number of meters^2 in the Simulator
  461. /// </summary>
  462. [XmlIgnore]
  463. public int SimwideArea {
  464. get {
  465. return _simwideArea;
  466. }
  467. set {
  468. _simwideArea = value;
  469. }
  470. }
  471. /// <summary>
  472. /// Number of SceneObjectPart in the Simulator
  473. /// </summary>
  474. [XmlIgnore]
  475. public int SimwidePrims {
  476. get {
  477. return _simwidePrims;
  478. }
  479. set {
  480. _simwidePrims = value;
  481. }
  482. }
  483. /// <summary>
  484. /// ID of the snapshot used in the client parcel dialog of the parcel
  485. /// </summary>
  486. public UUID SnapshotID {
  487. get {
  488. return _snapshotID;
  489. }
  490. set {
  491. _snapshotID = value;
  492. }
  493. }
  494. /// <summary>
  495. /// When teleporting is restricted to a certain point, this is the location
  496. /// that the user will be redirected to
  497. /// </summary>
  498. public Vector3 UserLocation {
  499. get {
  500. return _userLocation;
  501. }
  502. set {
  503. _userLocation = value;
  504. }
  505. }
  506. /// <summary>
  507. /// When teleporting is restricted to a certain point, this is the rotation
  508. /// that the user will be positioned
  509. /// </summary>
  510. public Vector3 UserLookAt {
  511. get {
  512. return _userLookAt;
  513. }
  514. set {
  515. _userLookAt = value;
  516. }
  517. }
  518. /// <summary>
  519. /// Autoreturn number of minutes to return SceneObjectGroup that are owned by someone who doesn't own
  520. /// the parcel and isn't set to the same 'group' as the parcel.
  521. /// </summary>
  522. public int OtherCleanTime {
  523. get {
  524. return _otherCleanTime;
  525. }
  526. set {
  527. _otherCleanTime = value;
  528. }
  529. }
  530. /// <summary>
  531. /// parcel media description
  532. /// </summary>
  533. public string MediaDescription {
  534. get {
  535. return _mediaDescription;
  536. }
  537. set {
  538. _mediaDescription = value;
  539. }
  540. }
  541. public LandData()
  542. {
  543. _globalID = UUID.Random();
  544. }
  545. /// <summary>
  546. /// Make a new copy of the land data
  547. /// </summary>
  548. /// <returns></returns>
  549. public LandData Copy()
  550. {
  551. LandData landData = new LandData();
  552. landData._AABBMax = _AABBMax;
  553. landData._AABBMin = _AABBMin;
  554. landData._area = _area;
  555. landData._auctionID = _auctionID;
  556. landData._authBuyerID = _authBuyerID;
  557. landData._category = _category;
  558. landData._claimDate = _claimDate;
  559. landData._claimPrice = _claimPrice;
  560. landData._globalID = _globalID;
  561. landData._groupID = _groupID;
  562. landData._isGroupOwned = _isGroupOwned;
  563. landData._localID = _localID;
  564. landData._landingType = _landingType;
  565. landData._mediaAutoScale = _mediaAutoScale;
  566. landData._mediaID = _mediaID;
  567. landData._mediaURL = _mediaURL;
  568. landData._musicURL = _musicURL;
  569. landData._ownerID = _ownerID;
  570. landData._bitmap = (byte[]) _bitmap.Clone();
  571. landData._description = _description;
  572. landData._flags = _flags;
  573. landData._name = _name;
  574. landData._status = _status;
  575. landData._passHours = _passHours;
  576. landData._passPrice = _passPrice;
  577. landData._salePrice = _salePrice;
  578. landData._snapshotID = _snapshotID;
  579. landData._userLocation = _userLocation;
  580. landData._userLookAt = _userLookAt;
  581. landData._otherCleanTime = _otherCleanTime;
  582. landData._mediaType = _mediaType;
  583. landData._mediaDescription = _mediaDescription;
  584. landData._mediaWidth = _mediaWidth;
  585. landData._mediaHeight = _mediaHeight;
  586. landData._mediaLoop = _mediaLoop;
  587. landData._obscureMusic = _obscureMusic;
  588. landData._obscureMedia = _obscureMedia;
  589. landData._simwideArea = _simwideArea;
  590. landData._simwidePrims = _simwidePrims;
  591. landData._parcelAccessList.Clear();
  592. foreach (ParcelManager.ParcelAccessEntry entry in _parcelAccessList)
  593. {
  594. ParcelManager.ParcelAccessEntry newEntry = new ParcelManager.ParcelAccessEntry();
  595. newEntry.AgentID = entry.AgentID;
  596. newEntry.Flags = entry.Flags;
  597. newEntry.Time = entry.Time;
  598. landData._parcelAccessList.Add(newEntry);
  599. }
  600. return landData;
  601. }
  602. public void ToXml(XmlWriter xmlWriter)
  603. {
  604. serializer.Serialize(xmlWriter, this);
  605. }
  606. /// <summary>
  607. /// Restore a LandData object from the serialized xml representation.
  608. /// </summary>
  609. /// <param name="xmlReader"></param>
  610. /// <returns></returns>
  611. public static LandData FromXml(XmlReader xmlReader)
  612. {
  613. LandData land = (LandData)serializer.Deserialize(xmlReader);
  614. return land;
  615. }
  616. }
  617. }