1
0

LandData.cs 21 KB

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