LandData.cs 21 KB

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