1
0

LandData.cs 21 KB

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