1
0

LandData.cs 21 KB

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