LandData.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  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 int _groupPrims = 0;
  54. private bool _isGroupOwned = false;
  55. private byte[] _bitmap = new byte[512];
  56. private string _description = String.Empty;
  57. private uint _flags = (uint) ParcelFlags.AllowFly | (uint) ParcelFlags.AllowLandmark |
  58. (uint) ParcelFlags.AllowAPrimitiveEntry |
  59. (uint) ParcelFlags.AllowDeedToGroup | (uint) ParcelFlags.AllowTerraform |
  60. (uint) ParcelFlags.CreateObjects | (uint) ParcelFlags.AllowOtherScripts |
  61. (uint) ParcelFlags.SoundLocal;
  62. private byte _landingType = 0;
  63. private string _name = "Your Parcel";
  64. private ParcelStatus _status = ParcelStatus.Leased;
  65. private int _localID = 0;
  66. private byte _mediaAutoScale = 0;
  67. private UUID _mediaID = UUID.Zero;
  68. private string _mediaURL = String.Empty;
  69. private string _musicURL = String.Empty;
  70. private int _otherPrims = 0;
  71. private UUID _ownerID = UUID.Zero;
  72. private int _ownerPrims = 0;
  73. private List<ParcelManager.ParcelAccessEntry> _parcelAccessList = new List<ParcelManager.ParcelAccessEntry>();
  74. private float _passHours = 0;
  75. private int _passPrice = 0;
  76. private int _salePrice = 0; //Unemeplemented. Parcels price.
  77. private int _selectedPrims = 0;
  78. private int _simwideArea = 0;
  79. private int _simwidePrims = 0;
  80. private UUID _snapshotID = UUID.Zero;
  81. private Vector3 _userLocation = new Vector3();
  82. private Vector3 _userLookAt = new Vector3();
  83. private int _dwell = 0;
  84. private int _otherCleanTime = 0;
  85. /// <summary>
  86. /// Upper corner of the AABB for the parcel
  87. /// </summary>
  88. [XmlIgnore]
  89. public Vector3 AABBMax {
  90. get {
  91. return _AABBMax;
  92. }
  93. set {
  94. _AABBMax = value;
  95. }
  96. }
  97. /// <summary>
  98. /// Lower corner of the AABB for the parcel
  99. /// </summary>
  100. [XmlIgnore]
  101. public Vector3 AABBMin {
  102. get {
  103. return _AABBMin;
  104. }
  105. set {
  106. _AABBMin = value;
  107. }
  108. }
  109. /// <summary>
  110. /// Area in meters^2 the parcel contains
  111. /// </summary>
  112. public int Area {
  113. get {
  114. return _area;
  115. }
  116. set {
  117. _area = value;
  118. }
  119. }
  120. /// <summary>
  121. /// ID of auction (3rd Party Integration) when parcel is being auctioned
  122. /// </summary>
  123. public uint AuctionID {
  124. get {
  125. return _auctionID;
  126. }
  127. set {
  128. _auctionID = value;
  129. }
  130. }
  131. /// <summary>
  132. /// UUID of authorized buyer of parcel. This is UUID.Zero if anyone can buy it.
  133. /// </summary>
  134. public UUID AuthBuyerID {
  135. get {
  136. return _authBuyerID;
  137. }
  138. set {
  139. _authBuyerID = value;
  140. }
  141. }
  142. /// <summary>
  143. /// Category of parcel. Used for classifying the parcel in classified listings
  144. /// </summary>
  145. public ParcelCategory Category {
  146. get {
  147. return _category;
  148. }
  149. set {
  150. _category = value;
  151. }
  152. }
  153. /// <summary>
  154. /// Date that the current owner purchased or claimed the parcel
  155. /// </summary>
  156. public int ClaimDate {
  157. get {
  158. return _claimDate;
  159. }
  160. set {
  161. _claimDate = value;
  162. }
  163. }
  164. /// <summary>
  165. /// The last price that the parcel was sold at
  166. /// </summary>
  167. public int ClaimPrice {
  168. get {
  169. return _claimPrice;
  170. }
  171. set {
  172. _claimPrice = value;
  173. }
  174. }
  175. /// <summary>
  176. /// Global ID for the parcel. (3rd Party Integration)
  177. /// </summary>
  178. public UUID GlobalID {
  179. get {
  180. return _globalID;
  181. }
  182. set {
  183. _globalID = value;
  184. }
  185. }
  186. /// <summary>
  187. /// Unique ID of the Group that owns
  188. /// </summary>
  189. public UUID GroupID {
  190. get {
  191. return _groupID;
  192. }
  193. set {
  194. _groupID = value;
  195. }
  196. }
  197. /// <summary>
  198. /// Number of SceneObjectPart that are owned by a Group
  199. /// </summary>
  200. [XmlIgnore]
  201. public int GroupPrims {
  202. get {
  203. return _groupPrims;
  204. }
  205. set {
  206. _groupPrims = value;
  207. }
  208. }
  209. /// <summary>
  210. /// Returns true if the Land Parcel is owned by a group
  211. /// </summary>
  212. public bool IsGroupOwned {
  213. get {
  214. return _isGroupOwned;
  215. }
  216. set {
  217. _isGroupOwned = value;
  218. }
  219. }
  220. /// <summary>
  221. /// jp2 data for the image representative of the parcel in the parcel dialog
  222. /// </summary>
  223. public byte[] Bitmap {
  224. get {
  225. return _bitmap;
  226. }
  227. set {
  228. _bitmap = value;
  229. }
  230. }
  231. /// <summary>
  232. /// Parcel Description
  233. /// </summary>
  234. public string Description {
  235. get {
  236. return _description;
  237. }
  238. set {
  239. _description = value;
  240. }
  241. }
  242. /// <summary>
  243. /// Parcel settings. Access flags, Fly, NoPush, Voice, Scripts allowed, etc. ParcelFlags
  244. /// </summary>
  245. public uint Flags {
  246. get {
  247. return _flags;
  248. }
  249. set {
  250. _flags = value;
  251. }
  252. }
  253. /// <summary>
  254. /// Determines if people are able to teleport where they please on the parcel or if they
  255. /// get constrainted to a specific point on teleport within the parcel
  256. /// </summary>
  257. public byte LandingType {
  258. get {
  259. return _landingType;
  260. }
  261. set {
  262. _landingType = value;
  263. }
  264. }
  265. /// <summary>
  266. /// Parcel Name
  267. /// </summary>
  268. public string Name {
  269. get {
  270. return _name;
  271. }
  272. set {
  273. _name = value;
  274. }
  275. }
  276. /// <summary>
  277. /// Status of Parcel, Leased, Abandoned, For Sale
  278. /// </summary>
  279. public ParcelStatus Status {
  280. get {
  281. return _status;
  282. }
  283. set {
  284. _status = value;
  285. }
  286. }
  287. /// <summary>
  288. /// Internal ID of the parcel. Sometimes the client will try to use this value
  289. /// </summary>
  290. public int LocalID {
  291. get {
  292. return _localID;
  293. }
  294. set {
  295. _localID = value;
  296. }
  297. }
  298. /// <summary>
  299. /// Determines if we scale the media based on the surface it's on
  300. /// </summary>
  301. public byte MediaAutoScale {
  302. get {
  303. return _mediaAutoScale;
  304. }
  305. set {
  306. _mediaAutoScale = value;
  307. }
  308. }
  309. /// <summary>
  310. /// Texture Guid to replace with the output of the media stream
  311. /// </summary>
  312. public UUID MediaID {
  313. get {
  314. return _mediaID;
  315. }
  316. set {
  317. _mediaID = value;
  318. }
  319. }
  320. /// <summary>
  321. /// URL to the media file to display
  322. /// </summary>
  323. public string MediaURL {
  324. get {
  325. return _mediaURL;
  326. }
  327. set {
  328. _mediaURL = value;
  329. }
  330. }
  331. private int[] _mediaSize = new int[2];
  332. public int[] MediaSize
  333. {
  334. get
  335. {
  336. return _mediaSize;
  337. }
  338. set
  339. {
  340. _mediaSize = value;
  341. }
  342. }
  343. private string _mediaType = "";
  344. public string MediaType
  345. {
  346. get
  347. {
  348. return _mediaType;
  349. }
  350. set
  351. {
  352. _mediaType = value;
  353. }
  354. }
  355. /// <summary>
  356. /// URL to the shoutcast music stream to play on the parcel
  357. /// </summary>
  358. public string MusicURL {
  359. get {
  360. return _musicURL;
  361. }
  362. set {
  363. _musicURL = value;
  364. }
  365. }
  366. /// <summary>
  367. /// Number of SceneObjectPart that are owned by users who do not own the parcel
  368. /// and don't have the 'group. These are elegable for AutoReturn collection
  369. /// </summary>
  370. [XmlIgnore]
  371. public int OtherPrims {
  372. get {
  373. return _otherPrims;
  374. }
  375. set {
  376. _otherPrims = value;
  377. }
  378. }
  379. /// <summary>
  380. /// Owner Avatar or Group of the parcel. Naturally, all land masses must be
  381. /// owned by someone
  382. /// </summary>
  383. public UUID OwnerID {
  384. get {
  385. return _ownerID;
  386. }
  387. set {
  388. _ownerID = value;
  389. }
  390. }
  391. /// <summary>
  392. /// Number of SceneObjectPart that are owned by the owner of the parcel
  393. /// </summary>
  394. [XmlIgnore]
  395. public int OwnerPrims {
  396. get {
  397. return _ownerPrims;
  398. }
  399. set {
  400. _ownerPrims = value;
  401. }
  402. }
  403. /// <summary>
  404. /// List of access data for the parcel. User data, some bitflags, and a time
  405. /// </summary>
  406. public List<ParcelManager.ParcelAccessEntry> ParcelAccessList {
  407. get {
  408. return _parcelAccessList;
  409. }
  410. set {
  411. _parcelAccessList = value;
  412. }
  413. }
  414. /// <summary>
  415. /// How long in hours a Pass to the parcel is given
  416. /// </summary>
  417. public float PassHours {
  418. get {
  419. return _passHours;
  420. }
  421. set {
  422. _passHours = value;
  423. }
  424. }
  425. /// <summary>
  426. /// Price to purchase a Pass to a restricted parcel
  427. /// </summary>
  428. public int PassPrice {
  429. get {
  430. return _passPrice;
  431. }
  432. set {
  433. _passPrice = value;
  434. }
  435. }
  436. /// <summary>
  437. /// When the parcel is being sold, this is the price to purchase the parcel
  438. /// </summary>
  439. public int SalePrice {
  440. get {
  441. return _salePrice;
  442. }
  443. set {
  444. _salePrice = value;
  445. }
  446. }
  447. /// <summary>
  448. /// Number of SceneObjectPart that are currently selected by avatar
  449. /// </summary>
  450. [XmlIgnore]
  451. public int SelectedPrims {
  452. get {
  453. return _selectedPrims;
  454. }
  455. set {
  456. _selectedPrims = 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. /// Deprecated idea. Number of visitors ~= free money
  520. /// </summary>
  521. public int Dwell {
  522. get {
  523. return _dwell;
  524. }
  525. set {
  526. _dwell = value;
  527. }
  528. }
  529. /// <summary>
  530. /// Number of minutes to return SceneObjectGroup that are owned by someone who doesn't own
  531. /// the parcel and isn't set to the same 'group' as the parcel.
  532. /// </summary>
  533. public int OtherCleanTime {
  534. get {
  535. return _otherCleanTime;
  536. }
  537. set {
  538. _otherCleanTime = 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._groupPrims = _groupPrims;
  563. landData._otherPrims = _otherPrims;
  564. landData._ownerPrims = _ownerPrims;
  565. landData._selectedPrims = _selectedPrims;
  566. landData._isGroupOwned = _isGroupOwned;
  567. landData._localID = _localID;
  568. landData._landingType = _landingType;
  569. landData._mediaAutoScale = _mediaAutoScale;
  570. landData._mediaID = _mediaID;
  571. landData._mediaURL = _mediaURL;
  572. landData._musicURL = _musicURL;
  573. landData._ownerID = _ownerID;
  574. landData._bitmap = (byte[]) _bitmap.Clone();
  575. landData._description = _description;
  576. landData._flags = _flags;
  577. landData._name = _name;
  578. landData._status = _status;
  579. landData._passHours = _passHours;
  580. landData._passPrice = _passPrice;
  581. landData._salePrice = _salePrice;
  582. landData._snapshotID = _snapshotID;
  583. landData._userLocation = _userLocation;
  584. landData._userLookAt = _userLookAt;
  585. landData._otherCleanTime = _otherCleanTime;
  586. landData._dwell = _dwell;
  587. landData._parcelAccessList.Clear();
  588. foreach (ParcelManager.ParcelAccessEntry entry in _parcelAccessList)
  589. {
  590. ParcelManager.ParcelAccessEntry newEntry = new ParcelManager.ParcelAccessEntry();
  591. newEntry.AgentID = entry.AgentID;
  592. newEntry.Flags = entry.Flags;
  593. newEntry.Time = entry.Time;
  594. landData._parcelAccessList.Add(newEntry);
  595. }
  596. return landData;
  597. }
  598. public void ToXml(XmlWriter xmlWriter)
  599. {
  600. serializer.Serialize(xmlWriter, this);
  601. }
  602. /// <summary>
  603. /// Restore a LandData object from the serialized xml representation.
  604. /// </summary>
  605. /// <param name="xmlReader"></param>
  606. /// <returns></returns>
  607. public static LandData FromXml(XmlReader xmlReader)
  608. {
  609. LandData land = (LandData)serializer.Deserialize(xmlReader);
  610. return land;
  611. }
  612. }
  613. }