LandObject.cs 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235
  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.Reflection;
  30. using log4net;
  31. using OpenMetaverse;
  32. using OpenSim.Framework;
  33. using OpenSim.Region.Framework.Interfaces;
  34. using OpenSim.Region.Framework.Scenes;
  35. using RegionFlags = OpenMetaverse.RegionFlags;
  36. namespace OpenSim.Region.CoreModules.World.Land
  37. {
  38. /// <summary>
  39. /// Keeps track of a specific piece of land's information
  40. /// </summary>
  41. public class LandObject : ILandObject
  42. {
  43. #region Member Variables
  44. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  45. private static readonly string LogHeader = "[LAND OBJECT]";
  46. private bool[,] m_landBitmap;
  47. private readonly int landUnit = 4;
  48. private int m_lastSeqId = 0;
  49. protected LandData m_landData = new LandData();
  50. protected Scene m_scene;
  51. protected List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>();
  52. protected Dictionary<uint, UUID> m_listTransactions = new Dictionary<uint, UUID>();
  53. protected ExpiringCache<UUID, bool> m_groupMemberCache = new ExpiringCache<UUID, bool>();
  54. protected TimeSpan m_groupMemberCacheTimeout = TimeSpan.FromSeconds(30); // cache invalidation after 30 seconds
  55. public bool[,] LandBitmap
  56. {
  57. get { return m_landBitmap; }
  58. set { m_landBitmap = value; }
  59. }
  60. #endregion
  61. public int GetPrimsFree()
  62. {
  63. m_scene.EventManager.TriggerParcelPrimCountUpdate();
  64. int free = GetSimulatorMaxPrimCount() - m_landData.SimwidePrims;
  65. return free;
  66. }
  67. public LandData LandData
  68. {
  69. get { return m_landData; }
  70. set { m_landData = value; }
  71. }
  72. public IPrimCounts PrimCounts { get; set; }
  73. public UUID RegionUUID
  74. {
  75. get { return m_scene.RegionInfo.RegionID; }
  76. }
  77. public Vector3 StartPoint
  78. {
  79. get
  80. {
  81. for (int y = 0; y < LandBitmap.GetLength(1); y++)
  82. {
  83. for (int x = 0; x < LandBitmap.GetLength(0); x++)
  84. {
  85. if (LandBitmap[x, y])
  86. return new Vector3(x * landUnit, y * landUnit, 0);
  87. }
  88. }
  89. m_log.ErrorFormat("{0} StartPoint. No start point found. bitmapSize=<{1},{2}>",
  90. LogHeader, LandBitmap.GetLength(0), LandBitmap.GetLength(1));
  91. return new Vector3(-1, -1, -1);
  92. }
  93. }
  94. public Vector3 EndPoint
  95. {
  96. get
  97. {
  98. for (int y = LandBitmap.GetLength(1) - 1; y >= 0; y--)
  99. {
  100. for (int x = LandBitmap.GetLength(0) - 1; x >= 0; x--)
  101. {
  102. if (LandBitmap[x, y])
  103. {
  104. return new Vector3(x * landUnit + landUnit, y * landUnit + landUnit, 0);
  105. }
  106. }
  107. }
  108. m_log.ErrorFormat("{0} EndPoint. No end point found. bitmapSize=<{1},{2}>",
  109. LogHeader, LandBitmap.GetLength(0), LandBitmap.GetLength(1));
  110. return new Vector3(-1, -1, -1);
  111. }
  112. }
  113. #region Constructors
  114. public LandObject(UUID owner_id, bool is_group_owned, Scene scene)
  115. {
  116. m_scene = scene;
  117. m_landBitmap = new bool[m_scene.RegionInfo.RegionSizeX / landUnit, m_scene.RegionInfo.RegionSizeY / landUnit];
  118. LandData.OwnerID = owner_id;
  119. if (is_group_owned)
  120. LandData.GroupID = owner_id;
  121. else
  122. LandData.GroupID = UUID.Zero;
  123. LandData.IsGroupOwned = is_group_owned;
  124. }
  125. #endregion
  126. #region Member Functions
  127. #region General Functions
  128. /// <summary>
  129. /// Checks to see if this land object contains a point
  130. /// </summary>
  131. /// <param name="x"></param>
  132. /// <param name="y"></param>
  133. /// <returns>Returns true if the piece of land contains the specified point</returns>
  134. public bool ContainsPoint(int x, int y)
  135. {
  136. if (x >= 0 && y >= 0 && x < m_scene.RegionInfo.RegionSizeX && y < m_scene.RegionInfo.RegionSizeY)
  137. {
  138. return (LandBitmap[x / landUnit, y / landUnit] == true);
  139. }
  140. else
  141. {
  142. return false;
  143. }
  144. }
  145. public ILandObject Copy()
  146. {
  147. ILandObject newLand = new LandObject(LandData.OwnerID, LandData.IsGroupOwned, m_scene);
  148. //Place all new variables here!
  149. newLand.LandBitmap = (bool[,]) (LandBitmap.Clone());
  150. newLand.LandData = LandData.Copy();
  151. return newLand;
  152. }
  153. static overrideParcelMaxPrimCountDelegate overrideParcelMaxPrimCount;
  154. static overrideSimulatorMaxPrimCountDelegate overrideSimulatorMaxPrimCount;
  155. public void SetParcelObjectMaxOverride(overrideParcelMaxPrimCountDelegate overrideDel)
  156. {
  157. overrideParcelMaxPrimCount = overrideDel;
  158. }
  159. public void SetSimulatorObjectMaxOverride(overrideSimulatorMaxPrimCountDelegate overrideDel)
  160. {
  161. overrideSimulatorMaxPrimCount = overrideDel;
  162. }
  163. public int GetParcelMaxPrimCount()
  164. {
  165. if (overrideParcelMaxPrimCount != null)
  166. {
  167. return overrideParcelMaxPrimCount(this);
  168. }
  169. else
  170. {
  171. // Normal Calculations
  172. int parcelMax = (int)(((float)LandData.Area / (m_scene.RegionInfo.RegionSizeX * m_scene.RegionInfo.RegionSizeY))
  173. * (float)m_scene.RegionInfo.ObjectCapacity
  174. * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus);
  175. // TODO: The calculation of ObjectBonus should be refactored. It does still not work in the same manner as SL!
  176. return parcelMax;
  177. }
  178. }
  179. public int GetSimulatorMaxPrimCount()
  180. {
  181. if (overrideSimulatorMaxPrimCount != null)
  182. {
  183. return overrideSimulatorMaxPrimCount(this);
  184. }
  185. else
  186. {
  187. //Normal Calculations
  188. int simMax = (int)(((float)LandData.SimwideArea / (m_scene.RegionInfo.RegionSizeX * m_scene.RegionInfo.RegionSizeY))
  189. * (float)m_scene.RegionInfo.ObjectCapacity);
  190. return simMax;
  191. }
  192. }
  193. #endregion
  194. #region Packet Request Handling
  195. public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, IClientAPI remote_client)
  196. {
  197. IEstateModule estateModule = m_scene.RequestModuleInterface<IEstateModule>();
  198. // uint regionFlags = 336723974 & ~((uint)(RegionFlags.AllowLandmark | RegionFlags.AllowSetHome));
  199. uint regionFlags = (uint)(RegionFlags.PublicAllowed
  200. | RegionFlags.AllowDirectTeleport
  201. | RegionFlags.AllowParcelChanges
  202. | RegionFlags.AllowVoice );
  203. if (estateModule != null)
  204. regionFlags = estateModule.GetRegionFlags();
  205. int seq_id;
  206. if (snap_selection && (sequence_id == 0))
  207. {
  208. seq_id = m_lastSeqId;
  209. }
  210. else
  211. {
  212. seq_id = sequence_id;
  213. m_lastSeqId = seq_id;
  214. }
  215. remote_client.SendLandProperties(seq_id,
  216. snap_selection, request_result, this,
  217. (float)m_scene.RegionInfo.RegionSettings.ObjectBonus,
  218. GetParcelMaxPrimCount(),
  219. GetSimulatorMaxPrimCount(), regionFlags);
  220. }
  221. public void UpdateLandProperties(LandUpdateArgs args, IClientAPI remote_client)
  222. {
  223. //Needs later group support
  224. bool snap_selection = false;
  225. LandData newData = LandData.Copy();
  226. uint allowedDelta = 0;
  227. // These two are always blocked as no client can set them anyway
  228. // ParcelFlags.ForSaleObjects
  229. // ParcelFlags.LindenHome
  230. if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandOptions))
  231. {
  232. allowedDelta |= (uint)(ParcelFlags.AllowLandmark |
  233. ParcelFlags.AllowTerraform |
  234. ParcelFlags.AllowDamage |
  235. ParcelFlags.CreateObjects |
  236. ParcelFlags.RestrictPushObject |
  237. ParcelFlags.AllowOtherScripts |
  238. ParcelFlags.AllowGroupScripts |
  239. ParcelFlags.CreateGroupObjects |
  240. ParcelFlags.AllowAPrimitiveEntry |
  241. ParcelFlags.AllowGroupObjectEntry |
  242. ParcelFlags.AllowFly);
  243. }
  244. if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandSetSale))
  245. {
  246. if (args.AuthBuyerID != newData.AuthBuyerID ||
  247. args.SalePrice != newData.SalePrice)
  248. {
  249. snap_selection = true;
  250. }
  251. newData.AuthBuyerID = args.AuthBuyerID;
  252. newData.SalePrice = args.SalePrice;
  253. if (!LandData.IsGroupOwned)
  254. {
  255. newData.GroupID = args.GroupID;
  256. allowedDelta |= (uint)(ParcelFlags.AllowDeedToGroup |
  257. ParcelFlags.ContributeWithDeed |
  258. ParcelFlags.SellParcelObjects);
  259. }
  260. allowedDelta |= (uint)ParcelFlags.ForSale;
  261. }
  262. if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.FindPlaces))
  263. {
  264. newData.Category = args.Category;
  265. allowedDelta |= (uint)(ParcelFlags.ShowDirectory |
  266. ParcelFlags.AllowPublish |
  267. ParcelFlags.MaturePublish);
  268. }
  269. if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.LandChangeIdentity))
  270. {
  271. newData.Description = args.Desc;
  272. newData.Name = args.Name;
  273. newData.SnapshotID = args.SnapshotID;
  274. }
  275. if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.SetLandingPoint))
  276. {
  277. newData.LandingType = args.LandingType;
  278. newData.UserLocation = args.UserLocation;
  279. newData.UserLookAt = args.UserLookAt;
  280. }
  281. if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.ChangeMedia))
  282. {
  283. newData.MediaAutoScale = args.MediaAutoScale;
  284. newData.MediaID = args.MediaID;
  285. newData.MediaURL = args.MediaURL;
  286. newData.MusicURL = args.MusicURL;
  287. newData.MediaType = args.MediaType;
  288. newData.MediaDescription = args.MediaDescription;
  289. newData.MediaWidth = args.MediaWidth;
  290. newData.MediaHeight = args.MediaHeight;
  291. newData.MediaLoop = args.MediaLoop;
  292. newData.ObscureMusic = args.ObscureMusic;
  293. newData.ObscureMedia = args.ObscureMedia;
  294. allowedDelta |= (uint)(ParcelFlags.SoundLocal |
  295. ParcelFlags.UrlWebPage |
  296. ParcelFlags.UrlRawHtml |
  297. ParcelFlags.AllowVoiceChat |
  298. ParcelFlags.UseEstateVoiceChan);
  299. }
  300. if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.LandManagePasses))
  301. {
  302. newData.PassHours = args.PassHours;
  303. newData.PassPrice = args.PassPrice;
  304. allowedDelta |= (uint)ParcelFlags.UsePassList;
  305. }
  306. if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandManageAllowed))
  307. {
  308. allowedDelta |= (uint)(ParcelFlags.UseAccessGroup |
  309. ParcelFlags.UseAccessList);
  310. }
  311. if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandManageBanned))
  312. {
  313. allowedDelta |= (uint)(ParcelFlags.UseBanList |
  314. ParcelFlags.DenyAnonymous |
  315. ParcelFlags.DenyAgeUnverified);
  316. }
  317. uint preserve = LandData.Flags & ~allowedDelta;
  318. newData.Flags = preserve | (args.ParcelFlags & allowedDelta);
  319. m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData);
  320. SendLandUpdateToAvatarsOverMe(snap_selection);
  321. }
  322. public void UpdateLandSold(UUID avatarID, UUID groupID, bool groupOwned, uint AuctionID, int claimprice, int area)
  323. {
  324. LandData newData = LandData.Copy();
  325. newData.OwnerID = avatarID;
  326. newData.GroupID = groupID;
  327. newData.IsGroupOwned = groupOwned;
  328. //newData.auctionID = AuctionID;
  329. newData.ClaimDate = Util.UnixTimeSinceEpoch();
  330. newData.ClaimPrice = claimprice;
  331. newData.SalePrice = 0;
  332. newData.AuthBuyerID = UUID.Zero;
  333. newData.Flags &= ~(uint) (ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects | ParcelFlags.ShowDirectory);
  334. m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData);
  335. m_scene.EventManager.TriggerParcelPrimCountUpdate();
  336. SendLandUpdateToAvatarsOverMe(true);
  337. }
  338. public void DeedToGroup(UUID groupID)
  339. {
  340. LandData newData = LandData.Copy();
  341. newData.OwnerID = groupID;
  342. newData.GroupID = groupID;
  343. newData.IsGroupOwned = true;
  344. // Reset show in directory flag on deed
  345. newData.Flags &= ~(uint) (ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects | ParcelFlags.ShowDirectory);
  346. m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData);
  347. m_scene.EventManager.TriggerParcelPrimCountUpdate();
  348. SendLandUpdateToAvatarsOverMe(true);
  349. }
  350. public bool IsEitherBannedOrRestricted(UUID avatar)
  351. {
  352. if (IsBannedFromLand(avatar))
  353. {
  354. return true;
  355. }
  356. else if (IsRestrictedFromLand(avatar))
  357. {
  358. return true;
  359. }
  360. return false;
  361. }
  362. public bool CanBeOnThisLand(UUID avatar, float posHeight)
  363. {
  364. if (posHeight < LandChannel.BAN_LINE_SAFETY_HIEGHT && IsBannedFromLand(avatar))
  365. {
  366. return false;
  367. }
  368. else if (IsRestrictedFromLand(avatar))
  369. {
  370. return false;
  371. }
  372. return true;
  373. }
  374. public bool HasGroupAccess(UUID avatar)
  375. {
  376. if (LandData.GroupID != UUID.Zero && (LandData.Flags & (uint)ParcelFlags.UseAccessGroup) == (uint)ParcelFlags.UseAccessGroup)
  377. {
  378. ScenePresence sp;
  379. if (!m_scene.TryGetScenePresence(avatar, out sp))
  380. {
  381. bool isMember;
  382. if (m_groupMemberCache.TryGetValue(avatar, out isMember))
  383. {
  384. m_groupMemberCache.Update(avatar, isMember, m_groupMemberCacheTimeout);
  385. return isMember;
  386. }
  387. IGroupsModule groupsModule = m_scene.RequestModuleInterface<IGroupsModule>();
  388. if (groupsModule == null)
  389. return false;
  390. GroupMembershipData[] membership = groupsModule.GetMembershipData(avatar);
  391. if (membership == null || membership.Length == 0)
  392. {
  393. m_groupMemberCache.Add(avatar, false, m_groupMemberCacheTimeout);
  394. return false;
  395. }
  396. foreach (GroupMembershipData d in membership)
  397. {
  398. if (d.GroupID == LandData.GroupID)
  399. {
  400. m_groupMemberCache.Add(avatar, true, m_groupMemberCacheTimeout);
  401. return true;
  402. }
  403. }
  404. m_groupMemberCache.Add(avatar, false, m_groupMemberCacheTimeout);
  405. return false;
  406. }
  407. return sp.ControllingClient.IsGroupMember(LandData.GroupID);
  408. }
  409. return false;
  410. }
  411. public bool IsBannedFromLand(UUID avatar)
  412. {
  413. ExpireAccessList();
  414. if (m_scene.Permissions.IsAdministrator(avatar))
  415. return false;
  416. if (m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(avatar))
  417. return false;
  418. if (avatar == LandData.OwnerID)
  419. return false;
  420. if ((LandData.Flags & (uint) ParcelFlags.UseBanList) > 0)
  421. {
  422. if (LandData.ParcelAccessList.FindIndex(
  423. delegate(LandAccessEntry e)
  424. {
  425. if (e.AgentID == avatar && e.Flags == AccessList.Ban)
  426. return true;
  427. return false;
  428. }) != -1)
  429. {
  430. return true;
  431. }
  432. }
  433. return false;
  434. }
  435. public bool IsRestrictedFromLand(UUID avatar)
  436. {
  437. if ((LandData.Flags & (uint) ParcelFlags.UseAccessList) == 0)
  438. return false;
  439. if (m_scene.Permissions.IsAdministrator(avatar))
  440. return false;
  441. if (m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(avatar))
  442. return false;
  443. if (avatar == LandData.OwnerID)
  444. return false;
  445. if (HasGroupAccess(avatar))
  446. return false;
  447. return !IsInLandAccessList(avatar);
  448. }
  449. public bool IsInLandAccessList(UUID avatar)
  450. {
  451. ExpireAccessList();
  452. if (LandData.ParcelAccessList.FindIndex(
  453. delegate(LandAccessEntry e)
  454. {
  455. if (e.AgentID == avatar && e.Flags == AccessList.Access)
  456. return true;
  457. return false;
  458. }) == -1)
  459. {
  460. return false;
  461. }
  462. return true;
  463. }
  464. public void SendLandUpdateToClient(IClientAPI remote_client)
  465. {
  466. SendLandProperties(0, false, 0, remote_client);
  467. }
  468. public void SendLandUpdateToClient(bool snap_selection, IClientAPI remote_client)
  469. {
  470. m_scene.EventManager.TriggerParcelPrimCountUpdate();
  471. SendLandProperties(0, snap_selection, 0, remote_client);
  472. }
  473. public void SendLandUpdateToAvatarsOverMe()
  474. {
  475. SendLandUpdateToAvatarsOverMe(false);
  476. }
  477. public void SendLandUpdateToAvatarsOverMe(bool snap_selection)
  478. {
  479. m_scene.ForEachRootScenePresence(delegate(ScenePresence avatar)
  480. {
  481. ILandObject over = null;
  482. try
  483. {
  484. over =
  485. m_scene.LandChannel.GetLandObject(Util.Clamp<int>((int)Math.Round(avatar.AbsolutePosition.X), 0, ((int)m_scene.RegionInfo.RegionSizeX - 1)),
  486. Util.Clamp<int>((int)Math.Round(avatar.AbsolutePosition.Y), 0, ((int)m_scene.RegionInfo.RegionSizeY - 1)));
  487. }
  488. catch (Exception)
  489. {
  490. m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatar.AbsolutePosition.X) + " y: " +
  491. Math.Round(avatar.AbsolutePosition.Y));
  492. }
  493. if (over != null)
  494. {
  495. if (over.LandData.LocalID == LandData.LocalID)
  496. {
  497. if (((over.LandData.Flags & (uint)ParcelFlags.AllowDamage) != 0) &&
  498. m_scene.RegionInfo.RegionSettings.AllowDamage)
  499. avatar.Invulnerable = false;
  500. else
  501. avatar.Invulnerable = true;
  502. SendLandUpdateToClient(snap_selection, avatar.ControllingClient);
  503. }
  504. }
  505. });
  506. }
  507. #endregion
  508. #region AccessList Functions
  509. public List<LandAccessEntry> CreateAccessListArrayByFlag(AccessList flag)
  510. {
  511. ExpireAccessList();
  512. List<LandAccessEntry> list = new List<LandAccessEntry>();
  513. foreach (LandAccessEntry entry in LandData.ParcelAccessList)
  514. {
  515. if (entry.Flags == flag)
  516. list.Add(entry);
  517. }
  518. if (list.Count == 0)
  519. {
  520. LandAccessEntry e = new LandAccessEntry();
  521. e.AgentID = UUID.Zero;
  522. e.Flags = 0;
  523. e.Expires = 0;
  524. list.Add(e);
  525. }
  526. return list;
  527. }
  528. public void SendAccessList(UUID agentID, UUID sessionID, uint flags, int sequenceID,
  529. IClientAPI remote_client)
  530. {
  531. if (flags == (uint) AccessList.Access || flags == (uint) AccessList.Both)
  532. {
  533. List<LandAccessEntry> accessEntries = CreateAccessListArrayByFlag(AccessList.Access);
  534. remote_client.SendLandAccessListData(accessEntries,(uint) AccessList.Access,LandData.LocalID);
  535. }
  536. if (flags == (uint) AccessList.Ban || flags == (uint) AccessList.Both)
  537. {
  538. List<LandAccessEntry> accessEntries = CreateAccessListArrayByFlag(AccessList.Ban);
  539. remote_client.SendLandAccessListData(accessEntries, (uint)AccessList.Ban, LandData.LocalID);
  540. }
  541. }
  542. public void UpdateAccessList(uint flags, UUID transactionID,
  543. int sequenceID, int sections,
  544. List<LandAccessEntry> entries,
  545. IClientAPI remote_client)
  546. {
  547. LandData newData = LandData.Copy();
  548. if ((!m_listTransactions.ContainsKey(flags)) ||
  549. m_listTransactions[flags] != transactionID)
  550. {
  551. m_listTransactions[flags] = transactionID;
  552. List<LandAccessEntry> toRemove =
  553. new List<LandAccessEntry>();
  554. foreach (LandAccessEntry entry in newData.ParcelAccessList)
  555. {
  556. if (entry.Flags == (AccessList)flags)
  557. toRemove.Add(entry);
  558. }
  559. foreach (LandAccessEntry entry in toRemove)
  560. {
  561. newData.ParcelAccessList.Remove(entry);
  562. }
  563. // Checked here because this will always be the first
  564. // and only packet in a transaction
  565. if (entries.Count == 1 && entries[0].AgentID == UUID.Zero)
  566. {
  567. m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData);
  568. return;
  569. }
  570. }
  571. foreach (LandAccessEntry entry in entries)
  572. {
  573. LandAccessEntry temp =
  574. new LandAccessEntry();
  575. temp.AgentID = entry.AgentID;
  576. temp.Expires = entry.Expires;
  577. temp.Flags = (AccessList)flags;
  578. newData.ParcelAccessList.Add(temp);
  579. }
  580. m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData);
  581. }
  582. #endregion
  583. #region Update Functions
  584. public void UpdateLandBitmapByteArray()
  585. {
  586. LandData.Bitmap = ConvertLandBitmapToBytes();
  587. }
  588. /// <summary>
  589. /// Update all settings in land such as area, bitmap byte array, etc
  590. /// </summary>
  591. public void ForceUpdateLandInfo()
  592. {
  593. UpdateAABBAndAreaValues();
  594. UpdateLandBitmapByteArray();
  595. }
  596. public void SetLandBitmapFromByteArray()
  597. {
  598. LandBitmap = ConvertBytesToLandBitmap();
  599. }
  600. /// <summary>
  601. /// Updates the AABBMin and AABBMax values after area/shape modification of the land object
  602. /// </summary>
  603. private void UpdateAABBAndAreaValues()
  604. {
  605. int min_x = 10000;
  606. int min_y = 10000;
  607. int max_x = 0;
  608. int max_y = 0;
  609. int tempArea = 0;
  610. int x, y;
  611. for (x = 0; x < LandBitmap.GetLength(0); x++)
  612. {
  613. for (y = 0; y < LandBitmap.GetLength(1); y++)
  614. {
  615. if (LandBitmap[x, y] == true)
  616. {
  617. if (min_x > x) min_x = x;
  618. if (min_y > y) min_y = y;
  619. if (max_x < x) max_x = x;
  620. if (max_y < y) max_y = y;
  621. tempArea += landUnit * landUnit; //16sqm peice of land
  622. }
  623. }
  624. }
  625. int tx = min_x * landUnit;
  626. if (tx > ((int)m_scene.RegionInfo.RegionSizeX - 1))
  627. tx = ((int)m_scene.RegionInfo.RegionSizeX - 1);
  628. int ty = min_y * landUnit;
  629. if (ty > ((int)m_scene.RegionInfo.RegionSizeY - 1))
  630. ty = ((int)m_scene.RegionInfo.RegionSizeY - 1);
  631. LandData.AABBMin =
  632. new Vector3(
  633. (float)(min_x * landUnit), (float)(min_y * landUnit), m_scene != null ? (float)m_scene.Heightmap[tx, ty] : 0);
  634. tx = max_x * landUnit;
  635. if (tx > ((int)m_scene.RegionInfo.RegionSizeX - 1))
  636. tx = ((int)m_scene.RegionInfo.RegionSizeX - 1);
  637. ty = max_y * landUnit;
  638. if (ty > ((int)m_scene.RegionInfo.RegionSizeY - 1))
  639. ty = ((int)m_scene.RegionInfo.RegionSizeY - 1);
  640. LandData.AABBMax
  641. = new Vector3(
  642. (float)(max_x * landUnit), (float)(max_y * landUnit), m_scene != null ? (float)m_scene.Heightmap[tx, ty] : 0);
  643. LandData.Area = tempArea;
  644. }
  645. #endregion
  646. #region Land Bitmap Functions
  647. /// <summary>
  648. /// Sets the land's bitmap manually
  649. /// </summary>
  650. /// <param name="bitmap">block representing where this land is on a map mapped in a 4x4 meter grid</param>
  651. public void SetLandBitmap(bool[,] bitmap)
  652. {
  653. LandBitmap = bitmap;
  654. // m_log.DebugFormat("{0} SetLandBitmap. BitmapSize=<{1},{2}>", LogHeader, LandBitmap.GetLength(0), LandBitmap.GetLength(1));
  655. ForceUpdateLandInfo();
  656. }
  657. /// <summary>
  658. /// Gets the land's bitmap manually
  659. /// </summary>
  660. /// <returns></returns>
  661. public bool[,] GetLandBitmap()
  662. {
  663. return LandBitmap;
  664. }
  665. public bool[,] BasicFullRegionLandBitmap()
  666. {
  667. return GetSquareLandBitmap(0, 0, (int)m_scene.RegionInfo.RegionSizeX, (int) m_scene.RegionInfo.RegionSizeY);
  668. }
  669. public bool[,] GetSquareLandBitmap(int start_x, int start_y, int end_x, int end_y)
  670. {
  671. // Empty bitmap for the whole region
  672. bool[,] tempBitmap = new bool[m_scene.RegionInfo.RegionSizeX / landUnit, m_scene.RegionInfo.RegionSizeY / landUnit];
  673. tempBitmap.Initialize();
  674. // Fill the bitmap square area specified by state and end
  675. tempBitmap = ModifyLandBitmapSquare(tempBitmap, start_x, start_y, end_x, end_y, true);
  676. // m_log.DebugFormat("{0} GetSquareLandBitmap. tempBitmapSize=<{1},{2}>",
  677. // LogHeader, tempBitmap.GetLength(0), tempBitmap.GetLength(1));
  678. return tempBitmap;
  679. }
  680. /// <summary>
  681. /// Change a land bitmap at within a square and set those points to a specific value
  682. /// </summary>
  683. /// <param name="land_bitmap"></param>
  684. /// <param name="start_x"></param>
  685. /// <param name="start_y"></param>
  686. /// <param name="end_x"></param>
  687. /// <param name="end_y"></param>
  688. /// <param name="set_value"></param>
  689. /// <returns></returns>
  690. public bool[,] ModifyLandBitmapSquare(bool[,] land_bitmap, int start_x, int start_y, int end_x, int end_y,
  691. bool set_value)
  692. {
  693. int x, y;
  694. for (y = 0; y < land_bitmap.GetLength(1); y++)
  695. {
  696. for (x = 0; x < land_bitmap.GetLength(0); x++)
  697. {
  698. if (x >= start_x / landUnit && x < end_x / landUnit
  699. && y >= start_y / landUnit && y < end_y / landUnit)
  700. {
  701. land_bitmap[x, y] = set_value;
  702. }
  703. }
  704. }
  705. // m_log.DebugFormat("{0} ModifyLandBitmapSquare. startXY=<{1},{2}>, endXY=<{3},{4}>, val={5}, landBitmapSize=<{6},{7}>",
  706. // LogHeader, start_x, start_y, end_x, end_y, set_value, land_bitmap.GetLength(0), land_bitmap.GetLength(1));
  707. return land_bitmap;
  708. }
  709. /// <summary>
  710. /// Join the true values of 2 bitmaps together
  711. /// </summary>
  712. /// <param name="bitmap_base"></param>
  713. /// <param name="bitmap_add"></param>
  714. /// <returns></returns>
  715. public bool[,] MergeLandBitmaps(bool[,] bitmap_base, bool[,] bitmap_add)
  716. {
  717. if (bitmap_base.GetLength(0) != bitmap_add.GetLength(0)
  718. || bitmap_base.GetLength(1) != bitmap_add.GetLength(1)
  719. || bitmap_add.Rank != 2
  720. || bitmap_base.Rank != 2)
  721. {
  722. throw new Exception(
  723. String.Format("{0} MergeLandBitmaps. merging maps not same size. baseSizeXY=<{1},{2}>, addSizeXY=<{3},{4}>",
  724. LogHeader, bitmap_base.GetLength(0), bitmap_base.GetLength(1), bitmap_add.GetLength(0), bitmap_add.GetLength(1))
  725. );
  726. }
  727. int x, y;
  728. for (y = 0; y < bitmap_base.GetLength(1); y++)
  729. {
  730. for (x = 0; x < bitmap_add.GetLength(0); x++)
  731. {
  732. if (bitmap_add[x, y])
  733. {
  734. bitmap_base[x, y] = true;
  735. }
  736. }
  737. }
  738. return bitmap_base;
  739. }
  740. /// <summary>
  741. /// Converts the land bitmap to a packet friendly byte array
  742. /// </summary>
  743. /// <returns></returns>
  744. private byte[] ConvertLandBitmapToBytes()
  745. {
  746. byte[] tempConvertArr = new byte[LandBitmap.GetLength(0) * LandBitmap.GetLength(1) / 8];
  747. byte tempByte = 0;
  748. int byteNum = 0;
  749. int i = 0;
  750. for (int y = 0; y < LandBitmap.GetLength(1); y++)
  751. {
  752. for (int x = 0; x < LandBitmap.GetLength(0); x++)
  753. {
  754. tempByte = Convert.ToByte(tempByte | Convert.ToByte(LandBitmap[x, y]) << (i++ % 8));
  755. if (i % 8 == 0)
  756. {
  757. tempConvertArr[byteNum] = tempByte;
  758. tempByte = (byte) 0;
  759. i = 0;
  760. byteNum++;
  761. }
  762. }
  763. }
  764. // m_log.DebugFormat("{0} ConvertLandBitmapToBytes. BitmapSize=<{1},{2}>",
  765. // LogHeader, LandBitmap.GetLength(0), LandBitmap.GetLength(1));
  766. return tempConvertArr;
  767. }
  768. private bool[,] ConvertBytesToLandBitmap()
  769. {
  770. bool[,] tempConvertMap = new bool[m_scene.RegionInfo.RegionSizeX / landUnit, m_scene.RegionInfo.RegionSizeY / landUnit];
  771. tempConvertMap.Initialize();
  772. byte tempByte = 0;
  773. // Math.Min overcomes an old bug that might have made it into the database. Only use the bytes that fit into convertMap.
  774. int bitmapLen = Math.Min(LandData.Bitmap.Length, tempConvertMap.GetLength(0) * tempConvertMap.GetLength(1) / 8);
  775. int xLen = (int)(m_scene.RegionInfo.RegionSizeX / landUnit);
  776. if (bitmapLen == 512)
  777. {
  778. // Legacy bitmap being passed in. Use the legacy region size
  779. // and only set the lower area of the larger region.
  780. xLen = (int)(Constants.RegionSize / landUnit);
  781. }
  782. // m_log.DebugFormat("{0} ConvertBytesToLandBitmap: bitmapLen={1}, xLen={2}", LogHeader, bitmapLen, xLen);
  783. int x = 0, y = 0;
  784. for (int i = 0; i < bitmapLen; i++)
  785. {
  786. tempByte = LandData.Bitmap[i];
  787. for (int bitNum = 0; bitNum < 8; bitNum++)
  788. {
  789. bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte) 1);
  790. try
  791. {
  792. tempConvertMap[x, y] = bit;
  793. }
  794. catch (Exception e)
  795. {
  796. m_log.DebugFormat("{0} ConvertBytestoLandBitmap: i={1}, x={2}, y={3}", LogHeader, i, x, y);
  797. }
  798. x++;
  799. if (x >= xLen)
  800. {
  801. x = 0;
  802. y++;
  803. }
  804. }
  805. }
  806. return tempConvertMap;
  807. }
  808. #endregion
  809. #region Object Select and Object Owner Listing
  810. public void SendForceObjectSelect(int local_id, int request_type, List<UUID> returnIDs, IClientAPI remote_client)
  811. {
  812. if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandOptions))
  813. {
  814. List<uint> resultLocalIDs = new List<uint>();
  815. try
  816. {
  817. lock (primsOverMe)
  818. {
  819. foreach (SceneObjectGroup obj in primsOverMe)
  820. {
  821. if (obj.LocalId > 0)
  822. {
  823. if (request_type == LandChannel.LAND_SELECT_OBJECTS_OWNER && obj.OwnerID == LandData.OwnerID)
  824. {
  825. resultLocalIDs.Add(obj.LocalId);
  826. }
  827. else if (request_type == LandChannel.LAND_SELECT_OBJECTS_GROUP && obj.GroupID == LandData.GroupID && LandData.GroupID != UUID.Zero)
  828. {
  829. resultLocalIDs.Add(obj.LocalId);
  830. }
  831. else if (request_type == LandChannel.LAND_SELECT_OBJECTS_OTHER &&
  832. obj.OwnerID != remote_client.AgentId)
  833. {
  834. resultLocalIDs.Add(obj.LocalId);
  835. }
  836. else if (request_type == (int)ObjectReturnType.List && returnIDs.Contains(obj.OwnerID))
  837. {
  838. resultLocalIDs.Add(obj.LocalId);
  839. }
  840. }
  841. }
  842. }
  843. } catch (InvalidOperationException)
  844. {
  845. m_log.Error("[LAND]: Unable to force select the parcel objects. Arr.");
  846. }
  847. remote_client.SendForceClientSelectObjects(resultLocalIDs);
  848. }
  849. }
  850. /// <summary>
  851. /// Notify the parcel owner each avatar that owns prims situated on their land. This notification includes
  852. /// aggreagete details such as the number of prims.
  853. ///
  854. /// </summary>
  855. /// <param name="remote_client">
  856. /// A <see cref="IClientAPI"/>
  857. /// </param>
  858. public void SendLandObjectOwners(IClientAPI remote_client)
  859. {
  860. if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandOptions))
  861. {
  862. Dictionary<UUID, int> primCount = new Dictionary<UUID, int>();
  863. List<UUID> groups = new List<UUID>();
  864. lock (primsOverMe)
  865. {
  866. // m_log.DebugFormat(
  867. // "[LAND OBJECT]: Request for SendLandObjectOwners() from {0} with {1} known prims on region",
  868. // remote_client.Name, primsOverMe.Count);
  869. try
  870. {
  871. foreach (SceneObjectGroup obj in primsOverMe)
  872. {
  873. try
  874. {
  875. if (!primCount.ContainsKey(obj.OwnerID))
  876. {
  877. primCount.Add(obj.OwnerID, 0);
  878. }
  879. }
  880. catch (NullReferenceException)
  881. {
  882. m_log.Error("[LAND]: " + "Got Null Reference when searching land owners from the parcel panel");
  883. }
  884. try
  885. {
  886. primCount[obj.OwnerID] += obj.PrimCount;
  887. }
  888. catch (KeyNotFoundException)
  889. {
  890. m_log.Error("[LAND]: Unable to match a prim with it's owner.");
  891. }
  892. if (obj.OwnerID == obj.GroupID && (!groups.Contains(obj.OwnerID)))
  893. groups.Add(obj.OwnerID);
  894. }
  895. }
  896. catch (InvalidOperationException)
  897. {
  898. m_log.Error("[LAND]: Unable to Enumerate Land object arr.");
  899. }
  900. }
  901. remote_client.SendLandObjectOwners(LandData, groups, primCount);
  902. }
  903. }
  904. public Dictionary<UUID, int> GetLandObjectOwners()
  905. {
  906. Dictionary<UUID, int> ownersAndCount = new Dictionary<UUID, int>();
  907. lock (primsOverMe)
  908. {
  909. try
  910. {
  911. foreach (SceneObjectGroup obj in primsOverMe)
  912. {
  913. if (!ownersAndCount.ContainsKey(obj.OwnerID))
  914. {
  915. ownersAndCount.Add(obj.OwnerID, 0);
  916. }
  917. ownersAndCount[obj.OwnerID] += obj.PrimCount;
  918. }
  919. }
  920. catch (InvalidOperationException)
  921. {
  922. m_log.Error("[LAND]: Unable to enumerate land owners. arr.");
  923. }
  924. }
  925. return ownersAndCount;
  926. }
  927. #endregion
  928. #region Object Returning
  929. public void ReturnObject(SceneObjectGroup obj)
  930. {
  931. SceneObjectGroup[] objs = new SceneObjectGroup[1];
  932. objs[0] = obj;
  933. m_scene.returnObjects(objs, obj.OwnerID);
  934. }
  935. public void ReturnLandObjects(uint type, UUID[] owners, UUID[] tasks, IClientAPI remote_client)
  936. {
  937. // m_log.DebugFormat(
  938. // "[LAND OBJECT]: Request to return objects in {0} from {1}", LandData.Name, remote_client.Name);
  939. Dictionary<UUID,List<SceneObjectGroup>> returns = new Dictionary<UUID,List<SceneObjectGroup>>();
  940. lock (primsOverMe)
  941. {
  942. if (type == (uint)ObjectReturnType.Owner)
  943. {
  944. foreach (SceneObjectGroup obj in primsOverMe)
  945. {
  946. if (obj.OwnerID == m_landData.OwnerID)
  947. {
  948. if (!returns.ContainsKey(obj.OwnerID))
  949. returns[obj.OwnerID] =
  950. new List<SceneObjectGroup>();
  951. returns[obj.OwnerID].Add(obj);
  952. }
  953. }
  954. }
  955. else if (type == (uint)ObjectReturnType.Group && m_landData.GroupID != UUID.Zero)
  956. {
  957. foreach (SceneObjectGroup obj in primsOverMe)
  958. {
  959. if (obj.GroupID == m_landData.GroupID)
  960. {
  961. if (!returns.ContainsKey(obj.OwnerID))
  962. returns[obj.OwnerID] =
  963. new List<SceneObjectGroup>();
  964. returns[obj.OwnerID].Add(obj);
  965. }
  966. }
  967. }
  968. else if (type == (uint)ObjectReturnType.Other)
  969. {
  970. foreach (SceneObjectGroup obj in primsOverMe)
  971. {
  972. if (obj.OwnerID != m_landData.OwnerID &&
  973. (obj.GroupID != m_landData.GroupID ||
  974. m_landData.GroupID == UUID.Zero))
  975. {
  976. if (!returns.ContainsKey(obj.OwnerID))
  977. returns[obj.OwnerID] =
  978. new List<SceneObjectGroup>();
  979. returns[obj.OwnerID].Add(obj);
  980. }
  981. }
  982. }
  983. else if (type == (uint)ObjectReturnType.List)
  984. {
  985. List<UUID> ownerlist = new List<UUID>(owners);
  986. foreach (SceneObjectGroup obj in primsOverMe)
  987. {
  988. if (ownerlist.Contains(obj.OwnerID))
  989. {
  990. if (!returns.ContainsKey(obj.OwnerID))
  991. returns[obj.OwnerID] =
  992. new List<SceneObjectGroup>();
  993. returns[obj.OwnerID].Add(obj);
  994. }
  995. }
  996. }
  997. }
  998. foreach (List<SceneObjectGroup> ol in returns.Values)
  999. {
  1000. if (m_scene.Permissions.CanReturnObjects(this, remote_client.AgentId, ol))
  1001. m_scene.returnObjects(ol.ToArray(), remote_client.AgentId);
  1002. }
  1003. }
  1004. #endregion
  1005. #region Object Adding/Removing from Parcel
  1006. public void ResetOverMeRecord()
  1007. {
  1008. lock (primsOverMe)
  1009. primsOverMe.Clear();
  1010. }
  1011. public void AddPrimOverMe(SceneObjectGroup obj)
  1012. {
  1013. // m_log.DebugFormat("[LAND OBJECT]: Adding scene object {0} {1} over {2}", obj.Name, obj.LocalId, LandData.Name);
  1014. lock (primsOverMe)
  1015. primsOverMe.Add(obj);
  1016. }
  1017. public void RemovePrimFromOverMe(SceneObjectGroup obj)
  1018. {
  1019. // m_log.DebugFormat("[LAND OBJECT]: Removing scene object {0} {1} from over {2}", obj.Name, obj.LocalId, LandData.Name);
  1020. lock (primsOverMe)
  1021. primsOverMe.Remove(obj);
  1022. }
  1023. #endregion
  1024. /// <summary>
  1025. /// Set the media url for this land parcel
  1026. /// </summary>
  1027. /// <param name="url"></param>
  1028. public void SetMediaUrl(string url)
  1029. {
  1030. LandData.MediaURL = url;
  1031. SendLandUpdateToAvatarsOverMe();
  1032. }
  1033. /// <summary>
  1034. /// Set the music url for this land parcel
  1035. /// </summary>
  1036. /// <param name="url"></param>
  1037. public void SetMusicUrl(string url)
  1038. {
  1039. LandData.MusicURL = url;
  1040. SendLandUpdateToAvatarsOverMe();
  1041. }
  1042. /// <summary>
  1043. /// Get the music url for this land parcel
  1044. /// </summary>
  1045. /// <returns>The music url.</returns>
  1046. public string GetMusicUrl()
  1047. {
  1048. return LandData.MusicURL;
  1049. }
  1050. #endregion
  1051. private void ExpireAccessList()
  1052. {
  1053. List<LandAccessEntry> delete = new List<LandAccessEntry>();
  1054. foreach (LandAccessEntry entry in LandData.ParcelAccessList)
  1055. {
  1056. if (entry.Expires != 0 && entry.Expires < Util.UnixTimeSinceEpoch())
  1057. delete.Add(entry);
  1058. }
  1059. foreach (LandAccessEntry entry in delete)
  1060. LandData.ParcelAccessList.Remove(entry);
  1061. if (delete.Count > 0)
  1062. m_scene.EventManager.TriggerLandObjectUpdated((uint)LandData.LocalID, this);
  1063. }
  1064. }
  1065. }