LandData.cs 21 KB

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