LandData.cs 19 KB

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