LandData.cs 21 KB

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