LandData.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  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. /// <summary>
  332. /// URL to the shoutcast music stream to play on the parcel
  333. /// </summary>
  334. public string MusicURL {
  335. get {
  336. return _musicURL;
  337. }
  338. set {
  339. _musicURL = value;
  340. }
  341. }
  342. /// <summary>
  343. /// Number of SceneObjectPart that are owned by users who do not own the parcel
  344. /// and don't have the 'group. These are elegable for AutoReturn collection
  345. /// </summary>
  346. [XmlIgnore]
  347. public int OtherPrims {
  348. get {
  349. return _otherPrims;
  350. }
  351. set {
  352. _otherPrims = value;
  353. }
  354. }
  355. /// <summary>
  356. /// Owner Avatar or Group of the parcel. Naturally, all land masses must be
  357. /// owned by someone
  358. /// </summary>
  359. public UUID OwnerID {
  360. get {
  361. return _ownerID;
  362. }
  363. set {
  364. _ownerID = value;
  365. }
  366. }
  367. /// <summary>
  368. /// Number of SceneObjectPart that are owned by the owner of the parcel
  369. /// </summary>
  370. [XmlIgnore]
  371. public int OwnerPrims {
  372. get {
  373. return _ownerPrims;
  374. }
  375. set {
  376. _ownerPrims = value;
  377. }
  378. }
  379. /// <summary>
  380. /// List of access data for the parcel. User data, some bitflags, and a time
  381. /// </summary>
  382. public List<ParcelManager.ParcelAccessEntry> ParcelAccessList {
  383. get {
  384. return _parcelAccessList;
  385. }
  386. set {
  387. _parcelAccessList = value;
  388. }
  389. }
  390. /// <summary>
  391. /// How long in hours a Pass to the parcel is given
  392. /// </summary>
  393. public float PassHours {
  394. get {
  395. return _passHours;
  396. }
  397. set {
  398. _passHours = value;
  399. }
  400. }
  401. /// <summary>
  402. /// Price to purchase a Pass to a restricted parcel
  403. /// </summary>
  404. public int PassPrice {
  405. get {
  406. return _passPrice;
  407. }
  408. set {
  409. _passPrice = value;
  410. }
  411. }
  412. /// <summary>
  413. /// When the parcel is being sold, this is the price to purchase the parcel
  414. /// </summary>
  415. public int SalePrice {
  416. get {
  417. return _salePrice;
  418. }
  419. set {
  420. _salePrice = value;
  421. }
  422. }
  423. /// <summary>
  424. /// Number of SceneObjectPart that are currently selected by avatar
  425. /// </summary>
  426. [XmlIgnore]
  427. public int SelectedPrims {
  428. get {
  429. return _selectedPrims;
  430. }
  431. set {
  432. _selectedPrims = value;
  433. }
  434. }
  435. /// <summary>
  436. /// Number of meters^2 in the Simulator
  437. /// </summary>
  438. [XmlIgnore]
  439. public int SimwideArea {
  440. get {
  441. return _simwideArea;
  442. }
  443. set {
  444. _simwideArea = value;
  445. }
  446. }
  447. /// <summary>
  448. /// Number of SceneObjectPart in the Simulator
  449. /// </summary>
  450. [XmlIgnore]
  451. public int SimwidePrims {
  452. get {
  453. return _simwidePrims;
  454. }
  455. set {
  456. _simwidePrims = value;
  457. }
  458. }
  459. /// <summary>
  460. /// ID of the snapshot used in the client parcel dialog of the parcel
  461. /// </summary>
  462. public UUID SnapshotID {
  463. get {
  464. return _snapshotID;
  465. }
  466. set {
  467. _snapshotID = value;
  468. }
  469. }
  470. /// <summary>
  471. /// When teleporting is restricted to a certain point, this is the location
  472. /// that the user will be redirected to
  473. /// </summary>
  474. public Vector3 UserLocation {
  475. get {
  476. return _userLocation;
  477. }
  478. set {
  479. _userLocation = value;
  480. }
  481. }
  482. /// <summary>
  483. /// When teleporting is restricted to a certain point, this is the rotation
  484. /// that the user will be positioned
  485. /// </summary>
  486. public Vector3 UserLookAt {
  487. get {
  488. return _userLookAt;
  489. }
  490. set {
  491. _userLookAt = value;
  492. }
  493. }
  494. /// <summary>
  495. /// Deprecated idea. Number of visitors ~= free money
  496. /// </summary>
  497. public int Dwell {
  498. get {
  499. return _dwell;
  500. }
  501. set {
  502. _dwell = value;
  503. }
  504. }
  505. /// <summary>
  506. /// Number of minutes to return SceneObjectGroup that are owned by someone who doesn't own
  507. /// the parcel and isn't set to the same 'group' as the parcel.
  508. /// </summary>
  509. public int OtherCleanTime {
  510. get {
  511. return _otherCleanTime;
  512. }
  513. set {
  514. _otherCleanTime = value;
  515. }
  516. }
  517. public LandData()
  518. {
  519. _globalID = UUID.Random();
  520. }
  521. /// <summary>
  522. /// Make a new copy of the land data
  523. /// </summary>
  524. /// <returns></returns>
  525. public LandData Copy()
  526. {
  527. LandData landData = new LandData();
  528. landData._AABBMax = _AABBMax;
  529. landData._AABBMin = _AABBMin;
  530. landData._area = _area;
  531. landData._auctionID = _auctionID;
  532. landData._authBuyerID = _authBuyerID;
  533. landData._category = _category;
  534. landData._claimDate = _claimDate;
  535. landData._claimPrice = _claimPrice;
  536. landData._globalID = _globalID;
  537. landData._groupID = _groupID;
  538. landData._groupPrims = _groupPrims;
  539. landData._otherPrims = _otherPrims;
  540. landData._ownerPrims = _ownerPrims;
  541. landData._selectedPrims = _selectedPrims;
  542. landData._isGroupOwned = _isGroupOwned;
  543. landData._localID = _localID;
  544. landData._landingType = _landingType;
  545. landData._mediaAutoScale = _mediaAutoScale;
  546. landData._mediaID = _mediaID;
  547. landData._mediaURL = _mediaURL;
  548. landData._musicURL = _musicURL;
  549. landData._ownerID = _ownerID;
  550. landData._bitmap = (byte[]) _bitmap.Clone();
  551. landData._description = _description;
  552. landData._flags = _flags;
  553. landData._name = _name;
  554. landData._status = _status;
  555. landData._passHours = _passHours;
  556. landData._passPrice = _passPrice;
  557. landData._salePrice = _salePrice;
  558. landData._snapshotID = _snapshotID;
  559. landData._userLocation = _userLocation;
  560. landData._userLookAt = _userLookAt;
  561. landData._otherCleanTime = _otherCleanTime;
  562. landData._dwell = _dwell;
  563. landData._parcelAccessList.Clear();
  564. foreach (ParcelManager.ParcelAccessEntry entry in _parcelAccessList)
  565. {
  566. ParcelManager.ParcelAccessEntry newEntry = new ParcelManager.ParcelAccessEntry();
  567. newEntry.AgentID = entry.AgentID;
  568. newEntry.Flags = entry.Flags;
  569. newEntry.Time = entry.Time;
  570. landData._parcelAccessList.Add(newEntry);
  571. }
  572. return landData;
  573. }
  574. public void ToXml(XmlWriter xmlWriter)
  575. {
  576. serializer.Serialize(xmlWriter, this);
  577. }
  578. /// <summary>
  579. /// Restore a LandData object from the serialized xml representation.
  580. /// </summary>
  581. /// <param name="xmlReader"></param>
  582. /// <returns></returns>
  583. public static LandData FromXml(XmlReader xmlReader)
  584. {
  585. LandData land = (LandData)serializer.Deserialize(xmlReader);
  586. return land;
  587. }
  588. }
  589. }