LandManagementModule.cs 97 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330
  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;
  29. using System.Collections.Generic;
  30. using System.Diagnostics;
  31. using System.Reflection;
  32. using System.Text;
  33. using log4net;
  34. using Nini.Config;
  35. using OpenMetaverse;
  36. using OpenMetaverse.StructuredData;
  37. using OpenMetaverse.Messages.Linden;
  38. using Mono.Addins;
  39. using OpenSim.Framework;
  40. using OpenSim.Framework.Capabilities;
  41. using OpenSim.Framework.Console;
  42. using OpenSim.Framework.Servers;
  43. using OpenSim.Framework.Servers.HttpServer;
  44. using OpenSim.Region.Framework.Interfaces;
  45. using OpenSim.Region.Framework.Scenes;
  46. using OpenSim.Region.PhysicsModules.SharedBase;
  47. using OpenSim.Services.Interfaces;
  48. using Caps = OpenSim.Framework.Capabilities.Caps;
  49. using GridRegion = OpenSim.Services.Interfaces.GridRegion;
  50. namespace OpenSim.Region.CoreModules.World.Land
  51. {
  52. // used for caching
  53. internal class ExtendedLandData
  54. {
  55. public LandData LandData;
  56. public ulong RegionHandle;
  57. public uint X, Y;
  58. public byte RegionAccess;
  59. }
  60. [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LandManagementModule")]
  61. public class LandManagementModule : INonSharedRegionModule
  62. {
  63. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  64. private static readonly string LogHeader = "[LAND MANAGEMENT MODULE]";
  65. /// <summary>
  66. /// Minimum land unit size in region co-ordinates.
  67. /// </summary>
  68. public const int LandUnit = 4;
  69. private static readonly string remoteParcelRequestPath = "0009/";
  70. private LandChannel landChannel;
  71. private Scene m_scene;
  72. protected IGroupsModule m_groupManager;
  73. protected IUserManagement m_userManager;
  74. protected IPrimCountModule m_primCountModule;
  75. protected IDialogModule m_Dialog;
  76. /// <value>
  77. /// Local land ids at specified region co-ordinates (region size / 4)
  78. /// </value>
  79. private int[,] m_landIDList;
  80. /// <value>
  81. /// Land objects keyed by local id
  82. /// </value>
  83. // private readonly Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>();
  84. //ubit: removed the readonly so i can move it around
  85. private Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>();
  86. private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1;
  87. private bool m_allowedForcefulBans = true;
  88. private UUID DefaultGodParcelGroup;
  89. private string DefaultGodParcelName;
  90. // caches ExtendedLandData
  91. private Cache parcelInfoCache;
  92. /// <summary>
  93. /// Record positions that avatar's are currently being forced to move to due to parcel entry restrictions.
  94. /// </summary>
  95. private Dictionary<UUID, Vector3> forcedPosition = new Dictionary<UUID, Vector3>();
  96. // Enables limiting parcel layer info transmission when doing simple updates
  97. private bool shouldLimitParcelLayerInfoToViewDistance { get; set; }
  98. // "View distance" for sending parcel layer info if asked for from a view point in the region
  99. private int parcelLayerViewDistance { get; set; }
  100. #region INonSharedRegionModule Members
  101. public Type ReplaceableInterface
  102. {
  103. get { return null; }
  104. }
  105. public void Initialise(IConfigSource source)
  106. {
  107. shouldLimitParcelLayerInfoToViewDistance = true;
  108. parcelLayerViewDistance = 128;
  109. IConfig landManagementConfig = source.Configs["LandManagement"];
  110. if (landManagementConfig != null)
  111. {
  112. shouldLimitParcelLayerInfoToViewDistance = landManagementConfig.GetBoolean("LimitParcelLayerUpdateDistance", shouldLimitParcelLayerInfoToViewDistance);
  113. parcelLayerViewDistance = landManagementConfig.GetInt("ParcelLayerViewDistance", parcelLayerViewDistance);
  114. DefaultGodParcelGroup = new UUID(landManagementConfig.GetString("DefaultAdministratorGroupUUID", UUID.Zero.ToString()));
  115. DefaultGodParcelName = landManagementConfig.GetString("DefaultAdministratorParcelName", "Default Parcel");
  116. }
  117. }
  118. public void AddRegion(Scene scene)
  119. {
  120. m_scene = scene;
  121. m_landIDList = new int[m_scene.RegionInfo.RegionSizeX / LandUnit, m_scene.RegionInfo.RegionSizeY / LandUnit];
  122. landChannel = new LandChannel(scene, this);
  123. parcelInfoCache = new Cache();
  124. parcelInfoCache.Size = 30; // the number of different parcel requests in this region to cache
  125. parcelInfoCache.DefaultTTL = new TimeSpan(0, 5, 0);
  126. m_scene.EventManager.OnParcelPrimCountAdd += EventManagerOnParcelPrimCountAdd;
  127. m_scene.EventManager.OnParcelPrimCountUpdate += EventManagerOnParcelPrimCountUpdate;
  128. m_scene.EventManager.OnObjectBeingRemovedFromScene += EventManagerOnObjectBeingRemovedFromScene;
  129. m_scene.EventManager.OnRequestParcelPrimCountUpdate += EventManagerOnRequestParcelPrimCountUpdate;
  130. m_scene.EventManager.OnAvatarEnteringNewParcel += EventManagerOnAvatarEnteringNewParcel;
  131. m_scene.EventManager.OnClientMovement += EventManagerOnClientMovement;
  132. m_scene.EventManager.OnValidateLandBuy += EventManagerOnValidateLandBuy;
  133. m_scene.EventManager.OnLandBuy += EventManagerOnLandBuy;
  134. m_scene.EventManager.OnNewClient += EventManagerOnNewClient;
  135. m_scene.EventManager.OnMakeChildAgent += EventMakeChildAgent;
  136. m_scene.EventManager.OnSignificantClientMovement += EventManagerOnSignificantClientMovement;
  137. m_scene.EventManager.OnNoticeNoLandDataFromStorage += EventManagerOnNoLandDataFromStorage;
  138. m_scene.EventManager.OnIncomingLandDataFromStorage += EventManagerOnIncomingLandDataFromStorage;
  139. m_scene.EventManager.OnSetAllowForcefulBan += EventManagerOnSetAllowedForcefulBan;
  140. m_scene.EventManager.OnRegisterCaps += EventManagerOnRegisterCaps;
  141. lock (m_scene)
  142. {
  143. m_scene.LandChannel = (ILandChannel)landChannel;
  144. }
  145. RegisterCommands();
  146. }
  147. public void RegionLoaded(Scene scene)
  148. {
  149. m_userManager = m_scene.RequestModuleInterface<IUserManagement>();
  150. m_groupManager = m_scene.RequestModuleInterface<IGroupsModule>();
  151. m_primCountModule = m_scene.RequestModuleInterface<IPrimCountModule>();
  152. m_Dialog = m_scene.RequestModuleInterface<IDialogModule>();
  153. }
  154. public void RemoveRegion(Scene scene)
  155. {
  156. // TODO: Release event manager listeners here
  157. }
  158. // private bool OnVerifyUserConnection(ScenePresence scenePresence, out string reason)
  159. // {
  160. // ILandObject nearestParcel = m_scene.GetNearestAllowedParcel(scenePresence.UUID, scenePresence.AbsolutePosition.X, scenePresence.AbsolutePosition.Y);
  161. // reason = "You are not allowed to enter this sim.";
  162. // return nearestParcel != null;
  163. // }
  164. void EventManagerOnNewClient(IClientAPI client)
  165. {
  166. //Register some client events
  167. client.OnParcelPropertiesRequest += ClientOnParcelPropertiesRequest;
  168. client.OnParcelDivideRequest += ClientOnParcelDivideRequest;
  169. client.OnParcelJoinRequest += ClientOnParcelJoinRequest;
  170. client.OnParcelPropertiesUpdateRequest += ClientOnParcelPropertiesUpdateRequest;
  171. client.OnParcelSelectObjects += ClientOnParcelSelectObjects;
  172. client.OnParcelObjectOwnerRequest += ClientOnParcelObjectOwnerRequest;
  173. client.OnParcelAccessListRequest += ClientOnParcelAccessListRequest;
  174. client.OnParcelAccessListUpdateRequest += ClientOnParcelAccessListUpdateRequest;
  175. client.OnParcelAbandonRequest += ClientOnParcelAbandonRequest;
  176. client.OnParcelGodForceOwner += ClientOnParcelGodForceOwner;
  177. client.OnParcelReclaim += ClientOnParcelReclaim;
  178. client.OnParcelInfoRequest += ClientOnParcelInfoRequest;
  179. client.OnParcelDeedToGroup += ClientOnParcelDeedToGroup;
  180. client.OnPreAgentUpdate += ClientOnPreAgentUpdate;
  181. client.OnParcelEjectUser += ClientOnParcelEjectUser;
  182. client.OnParcelFreezeUser += ClientOnParcelFreezeUser;
  183. client.OnSetStartLocationRequest += ClientOnSetHome;
  184. /* avatar is still a child here position is unknown
  185. EntityBase presenceEntity;
  186. if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence)
  187. {
  188. SendLandUpdate((ScenePresence)presenceEntity, true);
  189. SendParcelOverlay(client);
  190. }
  191. */
  192. }
  193. public void EventMakeChildAgent(ScenePresence avatar)
  194. {
  195. avatar.currentParcelUUID = UUID.Zero;
  196. }
  197. void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
  198. {
  199. }
  200. public void Close()
  201. {
  202. }
  203. public string Name
  204. {
  205. get { return "LandManagementModule"; }
  206. }
  207. #endregion
  208. #region Parcel Add/Remove/Get/Create
  209. public void EventManagerOnSetAllowedForcefulBan(bool forceful)
  210. {
  211. AllowedForcefulBans = forceful;
  212. }
  213. public void UpdateLandObject(int local_id, LandData data)
  214. {
  215. LandData newData = data.Copy();
  216. newData.LocalID = local_id;
  217. ILandObject land;
  218. lock (m_landList)
  219. {
  220. if (m_landList.TryGetValue(local_id, out land))
  221. land.LandData = newData;
  222. }
  223. if (land != null)
  224. m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, land);
  225. }
  226. public bool AllowedForcefulBans
  227. {
  228. get { return m_allowedForcefulBans; }
  229. set { m_allowedForcefulBans = value; }
  230. }
  231. /// <summary>
  232. /// Resets the sim to the default land object (full sim piece of land owned by the default user)
  233. /// </summary>
  234. public void ResetSimLandObjects()
  235. {
  236. //Remove all the land objects in the sim and add a blank, full sim land object set to public
  237. lock (m_landList)
  238. {
  239. m_landList.Clear();
  240. m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1;
  241. m_landIDList = new int[m_scene.RegionInfo.RegionSizeX / LandUnit, m_scene.RegionInfo.RegionSizeY / LandUnit];
  242. }
  243. }
  244. /// <summary>
  245. /// Create a default parcel that spans the entire region and is owned by the estate owner.
  246. /// </summary>
  247. /// <returns>The parcel created.</returns>
  248. protected ILandObject CreateDefaultParcel()
  249. {
  250. m_log.DebugFormat("{0} Creating default parcel for region {1}", LogHeader, m_scene.RegionInfo.RegionName);
  251. ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene);
  252. fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0,
  253. (int)m_scene.RegionInfo.RegionSizeX, (int)m_scene.RegionInfo.RegionSizeY));
  254. fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
  255. fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch();
  256. return AddLandObject(fullSimParcel);
  257. }
  258. public List<ILandObject> AllParcels()
  259. {
  260. lock (m_landList)
  261. {
  262. return new List<ILandObject>(m_landList.Values);
  263. }
  264. }
  265. public List<ILandObject> ParcelsNearPoint(Vector3 position)
  266. {
  267. List<ILandObject> parcelsNear = new List<ILandObject>();
  268. for (int x = -4; x <= 4; x += 4)
  269. {
  270. for (int y = -4; y <= 4; y += 4)
  271. {
  272. ILandObject check = GetLandObject(position.X + x, position.Y + y);
  273. if (check != null)
  274. {
  275. if (!parcelsNear.Contains(check))
  276. {
  277. parcelsNear.Add(check);
  278. }
  279. }
  280. }
  281. }
  282. return parcelsNear;
  283. }
  284. public void SendYouAreBannedNotice(ScenePresence avatar)
  285. {
  286. if (AllowedForcefulBans)
  287. {
  288. avatar.ControllingClient.SendAlertMessage(
  289. "You are not allowed on this parcel because you are banned. Please go away.");
  290. }
  291. else
  292. {
  293. avatar.ControllingClient.SendAlertMessage(
  294. "You are not allowed on this parcel because you are banned; however, the grid administrator has disabled ban lines globally. Please obey the land owner's requests or you can be banned from the entire sim!");
  295. }
  296. }
  297. private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position)
  298. {
  299. if (m_scene.Permissions.IsGod(avatar.UUID)) return;
  300. if (!position.HasValue)
  301. return;
  302. // land should have no word on avatar physics
  303. // bool isFlying = avatar.PhysicsActor.Flying;
  304. // avatar.RemoveFromPhysicalScene();
  305. avatar.AbsolutePosition = (Vector3)position;
  306. // avatar.AddToPhysicalScene(isFlying);
  307. }
  308. public void SendYouAreRestrictedNotice(ScenePresence avatar)
  309. {
  310. avatar.ControllingClient.SendAlertMessage(
  311. "You are not allowed on this parcel because the land owner has restricted access.");
  312. }
  313. public void EventManagerOnAvatarEnteringNewParcel(ScenePresence avatar, int localLandID, UUID regionID)
  314. {
  315. if (m_scene.RegionInfo.RegionID == regionID)
  316. {
  317. ILandObject parcelAvatarIsEntering;
  318. lock (m_landList)
  319. {
  320. parcelAvatarIsEntering = m_landList[localLandID];
  321. }
  322. if (parcelAvatarIsEntering != null)
  323. EnforceBans(parcelAvatarIsEntering, avatar);
  324. }
  325. }
  326. public void SendOutNearestBanLine(IClientAPI client)
  327. {
  328. ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
  329. if (sp == null)
  330. return;
  331. List<ILandObject> checkLandParcels = ParcelsNearPoint(sp.AbsolutePosition);
  332. foreach (ILandObject checkBan in checkLandParcels)
  333. {
  334. if (checkBan.IsBannedFromLand(client.AgentId))
  335. {
  336. checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionBanned, false, (int)ParcelResult.Single, client);
  337. return; //Only send one
  338. }
  339. if (checkBan.IsRestrictedFromLand(client.AgentId))
  340. {
  341. checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionNotOnAccessList, false, (int)ParcelResult.Single, client);
  342. return; //Only send one
  343. }
  344. }
  345. return;
  346. }
  347. public void sendClientInitialLandInfo(IClientAPI remoteClient)
  348. {
  349. ScenePresence avatar;
  350. if (!m_scene.TryGetScenePresence(remoteClient.AgentId, out avatar))
  351. return;
  352. if (!avatar.IsChildAgent)
  353. {
  354. ILandObject over = GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
  355. if (over == null)
  356. return;
  357. avatar.currentParcelUUID = over.LandData.GlobalID;
  358. over.SendLandUpdateToClient(avatar.ControllingClient);
  359. }
  360. SendParcelOverlay(remoteClient);
  361. }
  362. public void SendLandUpdate(ScenePresence avatar, bool force)
  363. {
  364. if (avatar.IsChildAgent)
  365. return;
  366. ILandObject over = GetLandObjectClipedXY(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
  367. if (over != null)
  368. {
  369. bool NotsameID = (avatar.currentParcelUUID != over.LandData.GlobalID);
  370. if (force || NotsameID)
  371. {
  372. over.SendLandUpdateToClient(avatar.ControllingClient);
  373. // sl doesnt seem to send this now, as it used 2
  374. // SendParcelOverlay(avatar.ControllingClient);
  375. avatar.currentParcelUUID = over.LandData.GlobalID;
  376. m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID,
  377. m_scene.RegionInfo.RegionID);
  378. }
  379. }
  380. }
  381. public void SendLandUpdate(ScenePresence avatar)
  382. {
  383. SendLandUpdate(avatar, false);
  384. }
  385. public void EventManagerOnSignificantClientMovement(ScenePresence clientAvatar)
  386. {
  387. SendLandUpdate(clientAvatar);
  388. SendOutNearestBanLine(clientAvatar.ControllingClient);
  389. ILandObject parcel = GetLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y);
  390. if (parcel != null)
  391. {
  392. if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT &&
  393. clientAvatar.sentMessageAboutRestrictedParcelFlyingDown)
  394. {
  395. EventManagerOnAvatarEnteringNewParcel(clientAvatar, parcel.LandData.LocalID,
  396. m_scene.RegionInfo.RegionID);
  397. //They are going under the safety line!
  398. if (!parcel.IsBannedFromLand(clientAvatar.UUID))
  399. {
  400. clientAvatar.sentMessageAboutRestrictedParcelFlyingDown = false;
  401. }
  402. }
  403. else if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT &&
  404. parcel.IsBannedFromLand(clientAvatar.UUID))
  405. {
  406. //once we've sent the message once, keep going toward the target until we are done
  407. if (forcedPosition.ContainsKey(clientAvatar.ControllingClient.AgentId))
  408. {
  409. SendYouAreBannedNotice(clientAvatar);
  410. ForceAvatarToPosition(clientAvatar, m_scene.GetNearestAllowedPosition(clientAvatar));
  411. }
  412. }
  413. else if (parcel.IsRestrictedFromLand(clientAvatar.UUID))
  414. {
  415. //once we've sent the message once, keep going toward the target until we are done
  416. if (forcedPosition.ContainsKey(clientAvatar.ControllingClient.AgentId))
  417. {
  418. SendYouAreRestrictedNotice(clientAvatar);
  419. ForceAvatarToPosition(clientAvatar, m_scene.GetNearestAllowedPosition(clientAvatar));
  420. }
  421. }
  422. else
  423. {
  424. //when we are finally in a safe place, lets release the forced position lock
  425. forcedPosition.Remove(clientAvatar.ControllingClient.AgentId);
  426. }
  427. EnforceBans(parcel, clientAvatar);
  428. }
  429. }
  430. /// <summary>
  431. /// Like handleEventManagerOnSignificantClientMovement, but called with an AgentUpdate regardless of distance.
  432. /// </summary>
  433. /// <param name="avatar"></param>
  434. public void EventManagerOnClientMovement(ScenePresence avatar)
  435. {
  436. Vector3 pos = avatar.AbsolutePosition;
  437. ILandObject over = GetLandObject(pos.X, pos.Y);
  438. if (over != null)
  439. {
  440. if (!over.IsRestrictedFromLand(avatar.UUID) && (!over.IsBannedFromLand(avatar.UUID) || pos.Z >= LandChannel.BAN_LINE_SAFETY_HIEGHT))
  441. avatar.lastKnownAllowedPosition = pos;
  442. }
  443. }
  444. public void ClientOnParcelAccessListRequest(UUID agentID, UUID sessionID, uint flags, int sequenceID,
  445. int landLocalID, IClientAPI remote_client)
  446. {
  447. ILandObject land;
  448. lock (m_landList)
  449. {
  450. m_landList.TryGetValue(landLocalID, out land);
  451. }
  452. if (land != null)
  453. {
  454. land.SendAccessList(agentID, sessionID, flags, sequenceID, remote_client);
  455. }
  456. }
  457. public void ClientOnParcelAccessListUpdateRequest(UUID agentID,
  458. uint flags, int landLocalID, UUID transactionID, int sequenceID,
  459. int sections, List<LandAccessEntry> entries,
  460. IClientAPI remote_client)
  461. {
  462. // Flags is the list to update, it can mean either the ban or
  463. // the access list (WTH is a pass list? Mentioned in ParcelFlags)
  464. //
  465. // There may be multiple packets, because these can get LONG.
  466. // Use transactionID to determine a new chain of packets since
  467. // packets may have come in out of sequence and that would be
  468. // a big mess if using the sequenceID
  469. ILandObject land;
  470. lock (m_landList)
  471. {
  472. m_landList.TryGetValue(landLocalID, out land);
  473. }
  474. if (land != null)
  475. {
  476. GroupPowers requiredPowers = GroupPowers.LandManageAllowed;
  477. if (flags == (uint)AccessList.Ban)
  478. requiredPowers = GroupPowers.LandManageBanned;
  479. if (m_scene.Permissions.CanEditParcelProperties(agentID,
  480. land, requiredPowers, false))
  481. {
  482. land.UpdateAccessList(flags, transactionID, sequenceID,
  483. sections, entries, remote_client);
  484. }
  485. }
  486. else
  487. {
  488. m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Invalid local land ID {0}", landLocalID);
  489. }
  490. }
  491. /// <summary>
  492. /// Adds a land object to the stored list and adds them to the landIDList to what they own
  493. /// </summary>
  494. /// <param name="new_land">
  495. /// The land object being added.
  496. /// Will return null if this overlaps with an existing parcel that has not had its bitmap adjusted.
  497. /// </param>
  498. public ILandObject AddLandObject(ILandObject land)
  499. {
  500. ILandObject new_land = land.Copy();
  501. // Only now can we add the prim counts to the land object - we rely on the global ID which is generated
  502. // as a random UUID inside LandData initialization
  503. if (m_primCountModule != null)
  504. new_land.PrimCounts = m_primCountModule.GetPrimCounts(new_land.LandData.GlobalID);
  505. lock (m_landList)
  506. {
  507. int newLandLocalID = m_lastLandLocalID + 1;
  508. new_land.LandData.LocalID = newLandLocalID;
  509. bool[,] landBitmap = new_land.GetLandBitmap();
  510. if (landBitmap.GetLength(0) != m_landIDList.GetLength(0) || landBitmap.GetLength(1) != m_landIDList.GetLength(1))
  511. {
  512. // Going to variable sized regions can cause mismatches
  513. m_log.ErrorFormat("{0} AddLandObject. Added land bitmap different size than region ID map. bitmapSize=({1},{2}), landIDSize=({3},{4})",
  514. LogHeader, landBitmap.GetLength(0), landBitmap.GetLength(1), m_landIDList.GetLength(0), m_landIDList.GetLength(1));
  515. }
  516. else
  517. {
  518. // If other land objects still believe that they occupy any parts of the same space,
  519. // then do not allow the add to proceed.
  520. for (int x = 0; x < landBitmap.GetLength(0); x++)
  521. {
  522. for (int y = 0; y < landBitmap.GetLength(1); y++)
  523. {
  524. if (landBitmap[x, y])
  525. {
  526. int lastRecordedLandId = m_landIDList[x, y];
  527. if (lastRecordedLandId > 0)
  528. {
  529. ILandObject lastRecordedLo = m_landList[lastRecordedLandId];
  530. if (lastRecordedLo.LandBitmap[x, y])
  531. {
  532. m_log.ErrorFormat(
  533. "{0}: Cannot add parcel \"{1}\", local ID {2} at tile {3},{4} because this is still occupied by parcel \"{5}\", local ID {6} in {7}",
  534. LogHeader, new_land.LandData.Name, new_land.LandData.LocalID, x, y,
  535. lastRecordedLo.LandData.Name, lastRecordedLo.LandData.LocalID, m_scene.Name);
  536. return null;
  537. }
  538. }
  539. }
  540. }
  541. }
  542. for (int x = 0; x < landBitmap.GetLength(0); x++)
  543. {
  544. for (int y = 0; y < landBitmap.GetLength(1); y++)
  545. {
  546. if (landBitmap[x, y])
  547. {
  548. // m_log.DebugFormat(
  549. // "[LAND MANAGEMENT MODULE]: Registering parcel {0} for land co-ord ({1}, {2}) on {3}",
  550. // new_land.LandData.Name, x, y, m_scene.RegionInfo.RegionName);
  551. m_landIDList[x, y] = newLandLocalID;
  552. }
  553. }
  554. }
  555. }
  556. m_landList.Add(newLandLocalID, new_land);
  557. m_lastLandLocalID++;
  558. }
  559. new_land.ForceUpdateLandInfo();
  560. m_scene.EventManager.TriggerLandObjectAdded(new_land);
  561. return new_land;
  562. }
  563. /// <summary>
  564. /// Removes a land object from the list. Will not remove if local_id is still owning an area in landIDList
  565. /// </summary>
  566. /// <param name="local_id">Land.localID of the peice of land to remove.</param>
  567. public void removeLandObject(int local_id)
  568. {
  569. ILandObject land;
  570. lock (m_landList)
  571. {
  572. for (int x = 0; x < m_landIDList.GetLength(0); x++)
  573. {
  574. for (int y = 0; y < m_landIDList.GetLength(1); y++)
  575. {
  576. if (m_landIDList[x, y] == local_id)
  577. {
  578. m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Not removing land object {0}; still being used at {1}, {2}",
  579. local_id, x, y);
  580. return;
  581. //throw new Exception("Could not remove land object. Still being used at " + x + ", " + y);
  582. }
  583. }
  584. }
  585. land = m_landList[local_id];
  586. m_landList.Remove(local_id);
  587. }
  588. m_scene.EventManager.TriggerLandObjectRemoved(land.LandData.GlobalID);
  589. }
  590. /// <summary>
  591. /// Clear the scene of all parcels
  592. /// </summary>
  593. public void Clear(bool setupDefaultParcel)
  594. {
  595. Dictionary<int, ILandObject> landworkList;
  596. // move to work pointer since we are deleting it all
  597. lock (m_landList)
  598. {
  599. landworkList = m_landList;
  600. m_landList = new Dictionary<int, ILandObject>();
  601. }
  602. // this 2 methods have locks (now)
  603. ResetSimLandObjects();
  604. if (setupDefaultParcel)
  605. CreateDefaultParcel();
  606. // fire outside events unlocked
  607. foreach (ILandObject lo in landworkList.Values)
  608. {
  609. //m_scene.SimulationDataService.RemoveLandObject(lo.LandData.GlobalID);
  610. m_scene.EventManager.TriggerLandObjectRemoved(lo.LandData.GlobalID);
  611. }
  612. landworkList.Clear();
  613. }
  614. private void performFinalLandJoin(ILandObject master, ILandObject slave)
  615. {
  616. bool[,] landBitmapSlave = slave.GetLandBitmap();
  617. lock (m_landList)
  618. {
  619. for (int x = 0; x < landBitmapSlave.GetLength(0); x++)
  620. {
  621. for (int y = 0; y < landBitmapSlave.GetLength(1); y++)
  622. {
  623. if (landBitmapSlave[x, y])
  624. {
  625. m_landIDList[x, y] = master.LandData.LocalID;
  626. }
  627. }
  628. }
  629. }
  630. removeLandObject(slave.LandData.LocalID);
  631. UpdateLandObject(master.LandData.LocalID, master.LandData);
  632. }
  633. public ILandObject GetLandObject(int parcelLocalID)
  634. {
  635. lock (m_landList)
  636. {
  637. if (m_landList.ContainsKey(parcelLocalID))
  638. {
  639. return m_landList[parcelLocalID];
  640. }
  641. }
  642. return null;
  643. }
  644. /// <summary>
  645. /// Get the land object at the specified point
  646. /// </summary>
  647. /// <param name="x_float">Value between 0 - 256 on the x axis of the point</param>
  648. /// <param name="y_float">Value between 0 - 256 on the y axis of the point</param>
  649. /// <returns>Land object at the point supplied</returns>
  650. public ILandObject GetLandObject(float x_float, float y_float)
  651. {
  652. return GetLandObject((int)x_float, (int)y_float, true);
  653. }
  654. // if x,y is off region this will return the parcel at cliped x,y
  655. // as did code it replaces
  656. public ILandObject GetLandObjectClipedXY(float x, float y)
  657. {
  658. //do clip inline
  659. int avx = (int)x;
  660. if (avx < 0)
  661. avx = 0;
  662. else if (avx >= m_scene.RegionInfo.RegionSizeX)
  663. avx = (int)Constants.RegionSize - 1;
  664. int avy = (int)y;
  665. if (avy < 0)
  666. avy = 0;
  667. else if (avy >= m_scene.RegionInfo.RegionSizeY)
  668. avy = (int)Constants.RegionSize - 1;
  669. lock (m_landIDList)
  670. {
  671. try
  672. {
  673. return m_landList[m_landIDList[avx / LandUnit, avy / LandUnit]];
  674. }
  675. catch (IndexOutOfRangeException)
  676. {
  677. return null;
  678. }
  679. }
  680. }
  681. // Public entry.
  682. // Throws exception if land object is not found
  683. public ILandObject GetLandObject(int x, int y)
  684. {
  685. return GetLandObject(x, y, false /* returnNullIfLandObjectNotFound */);
  686. }
  687. public ILandObject GetLandObject(int x, int y, bool returnNullIfLandObjectOutsideBounds)
  688. {
  689. if (x >= m_scene.RegionInfo.RegionSizeX || y >= m_scene.RegionInfo.RegionSizeY || x < 0 || y < 0)
  690. {
  691. // These exceptions here will cause a lot of complaints from the users specifically because
  692. // they happen every time at border crossings
  693. if (returnNullIfLandObjectOutsideBounds)
  694. return null;
  695. else
  696. throw new Exception("Error: Parcel not found at point " + x + ", " + y);
  697. }
  698. lock (m_landIDList)
  699. {
  700. try
  701. {
  702. return m_landList[m_landIDList[x / 4, y / 4]];
  703. }
  704. catch (IndexOutOfRangeException)
  705. {
  706. return null;
  707. }
  708. }
  709. return m_landList[m_landIDList[x / 4, y / 4]];
  710. }
  711. // Create a 'parcel is here' bitmap for the parcel identified by the passed landID
  712. private bool[,] CreateBitmapForID(int landID)
  713. {
  714. bool[,] ret = new bool[m_landIDList.GetLength(0), m_landIDList.GetLength(1)];
  715. for (int xx = 0; xx < m_landIDList.GetLength(0); xx++)
  716. for (int yy = 0; yy < m_landIDList.GetLength(0); yy++)
  717. if (m_landIDList[xx, yy] == landID)
  718. ret[xx, yy] = true;
  719. return ret;
  720. }
  721. #endregion
  722. #region Parcel Modification
  723. public void ResetOverMeRecords()
  724. {
  725. lock (m_landList)
  726. {
  727. foreach (LandObject p in m_landList.Values)
  728. {
  729. p.ResetOverMeRecord();
  730. }
  731. }
  732. }
  733. public void EventManagerOnParcelPrimCountAdd(SceneObjectGroup obj)
  734. {
  735. Vector3 position = obj.AbsolutePosition;
  736. ILandObject landUnderPrim = GetLandObject(position.X, position.Y);
  737. if (landUnderPrim != null)
  738. {
  739. ((LandObject)landUnderPrim).AddPrimOverMe(obj);
  740. }
  741. }
  742. public void EventManagerOnObjectBeingRemovedFromScene(SceneObjectGroup obj)
  743. {
  744. lock (m_landList)
  745. {
  746. foreach (LandObject p in m_landList.Values)
  747. {
  748. p.RemovePrimFromOverMe(obj);
  749. }
  750. }
  751. }
  752. public void FinalizeLandPrimCountUpdate()
  753. {
  754. //Get Simwide prim count for owner
  755. Dictionary<UUID, List<LandObject>> landOwnersAndParcels = new Dictionary<UUID, List<LandObject>>();
  756. lock (m_landList)
  757. {
  758. foreach (LandObject p in m_landList.Values)
  759. {
  760. if (!landOwnersAndParcels.ContainsKey(p.LandData.OwnerID))
  761. {
  762. List<LandObject> tempList = new List<LandObject>();
  763. tempList.Add(p);
  764. landOwnersAndParcels.Add(p.LandData.OwnerID, tempList);
  765. }
  766. else
  767. {
  768. landOwnersAndParcels[p.LandData.OwnerID].Add(p);
  769. }
  770. }
  771. }
  772. foreach (UUID owner in landOwnersAndParcels.Keys)
  773. {
  774. int simArea = 0;
  775. int simPrims = 0;
  776. foreach (LandObject p in landOwnersAndParcels[owner])
  777. {
  778. simArea += p.LandData.Area;
  779. simPrims += p.PrimCounts.Total;
  780. }
  781. foreach (LandObject p in landOwnersAndParcels[owner])
  782. {
  783. p.LandData.SimwideArea = simArea;
  784. p.LandData.SimwidePrims = simPrims;
  785. }
  786. }
  787. }
  788. public void EventManagerOnParcelPrimCountUpdate()
  789. {
  790. // m_log.DebugFormat(
  791. // "[LAND MANAGEMENT MODULE]: Triggered EventManagerOnParcelPrimCountUpdate() for {0}",
  792. // m_scene.RegionInfo.RegionName);
  793. ResetOverMeRecords();
  794. EntityBase[] entities = m_scene.Entities.GetEntities();
  795. foreach (EntityBase obj in entities)
  796. {
  797. if (obj != null)
  798. {
  799. if ((obj is SceneObjectGroup) && !obj.IsDeleted && !((SceneObjectGroup) obj).IsAttachment)
  800. {
  801. m_scene.EventManager.TriggerParcelPrimCountAdd((SceneObjectGroup) obj);
  802. }
  803. }
  804. }
  805. FinalizeLandPrimCountUpdate();
  806. }
  807. public void EventManagerOnRequestParcelPrimCountUpdate()
  808. {
  809. ResetOverMeRecords();
  810. m_scene.EventManager.TriggerParcelPrimCountUpdate();
  811. FinalizeLandPrimCountUpdate();
  812. }
  813. /// <summary>
  814. /// Subdivides a piece of land
  815. /// </summary>
  816. /// <param name="start_x">West Point</param>
  817. /// <param name="start_y">South Point</param>
  818. /// <param name="end_x">East Point</param>
  819. /// <param name="end_y">North Point</param>
  820. /// <param name="attempting_user_id">UUID of user who is trying to subdivide</param>
  821. /// <returns>Returns true if successful</returns>
  822. private void subdivide(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id)
  823. {
  824. //First, lets loop through the points and make sure they are all in the same peice of land
  825. //Get the land object at start
  826. ILandObject startLandObject = GetLandObject(start_x, start_y);
  827. if (startLandObject == null) return;
  828. //Loop through the points
  829. try
  830. {
  831. int totalX = end_x - start_x;
  832. int totalY = end_y - start_y;
  833. for (int y = 0; y < totalY; y++)
  834. {
  835. for (int x = 0; x < totalX; x++)
  836. {
  837. ILandObject tempLandObject = GetLandObject(start_x + x, start_y + y);
  838. if (tempLandObject == null) return;
  839. if (tempLandObject != startLandObject) return;
  840. }
  841. }
  842. }
  843. catch (Exception)
  844. {
  845. return;
  846. }
  847. //If we are still here, then they are subdividing within one piece of land
  848. //Check owner
  849. if (!m_scene.Permissions.CanEditParcelProperties(attempting_user_id, startLandObject, GroupPowers.LandDivideJoin, true))
  850. {
  851. return;
  852. }
  853. //Lets create a new land object with bitmap activated at that point (keeping the old land objects info)
  854. ILandObject newLand = startLandObject.Copy();
  855. newLand.LandData.Name = newLand.LandData.Name;
  856. newLand.LandData.GlobalID = UUID.Random();
  857. newLand.LandData.Dwell = 0;
  858. // Clear "Show in search" on the cut out parcel to prevent double-charging
  859. newLand.LandData.Flags &= ~(uint)ParcelFlags.ShowDirectory;
  860. newLand.SetLandBitmap(newLand.GetSquareLandBitmap(start_x, start_y, end_x, end_y));
  861. //Now, lets set the subdivision area of the original to false
  862. int startLandObjectIndex = startLandObject.LandData.LocalID;
  863. lock (m_landList)
  864. {
  865. m_landList[startLandObjectIndex].SetLandBitmap(
  866. newLand.ModifyLandBitmapSquare(startLandObject.GetLandBitmap(), start_x, start_y, end_x, end_y, false));
  867. m_landList[startLandObjectIndex].ForceUpdateLandInfo();
  868. }
  869. //Now add the new land object
  870. ILandObject result = AddLandObject(newLand);
  871. UpdateLandObject(startLandObject.LandData.LocalID, startLandObject.LandData);
  872. result.SendLandUpdateToAvatarsOverMe();
  873. startLandObject.SendLandUpdateToAvatarsOverMe();
  874. m_scene.ForEachClient(SendParcelOverlay);
  875. }
  876. /// <summary>
  877. /// Join 2 land objects together
  878. /// </summary>
  879. /// <param name="start_x">x value in first piece of land</param>
  880. /// <param name="start_y">y value in first piece of land</param>
  881. /// <param name="end_x">x value in second peice of land</param>
  882. /// <param name="end_y">y value in second peice of land</param>
  883. /// <param name="attempting_user_id">UUID of the avatar trying to join the land objects</param>
  884. /// <returns>Returns true if successful</returns>
  885. private void join(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id)
  886. {
  887. end_x -= 4;
  888. end_y -= 4;
  889. List<ILandObject> selectedLandObjects = new List<ILandObject>();
  890. int stepYSelected;
  891. for (stepYSelected = start_y; stepYSelected <= end_y; stepYSelected += 4)
  892. {
  893. int stepXSelected;
  894. for (stepXSelected = start_x; stepXSelected <= end_x; stepXSelected += 4)
  895. {
  896. ILandObject p = GetLandObject(stepXSelected, stepYSelected);
  897. if (p != null)
  898. {
  899. if (!selectedLandObjects.Contains(p))
  900. {
  901. selectedLandObjects.Add(p);
  902. }
  903. }
  904. }
  905. }
  906. ILandObject masterLandObject = selectedLandObjects[0];
  907. selectedLandObjects.RemoveAt(0);
  908. if (selectedLandObjects.Count < 1)
  909. {
  910. return;
  911. }
  912. if (!m_scene.Permissions.CanEditParcelProperties(attempting_user_id, masterLandObject, GroupPowers.LandDivideJoin, true))
  913. {
  914. return;
  915. }
  916. foreach (ILandObject p in selectedLandObjects)
  917. {
  918. if (p.LandData.OwnerID != masterLandObject.LandData.OwnerID)
  919. {
  920. return;
  921. }
  922. }
  923. lock (m_landList)
  924. {
  925. foreach (ILandObject slaveLandObject in selectedLandObjects)
  926. {
  927. m_landList[masterLandObject.LandData.LocalID].SetLandBitmap(
  928. slaveLandObject.MergeLandBitmaps(masterLandObject.GetLandBitmap(), slaveLandObject.GetLandBitmap()));
  929. performFinalLandJoin(masterLandObject, slaveLandObject);
  930. }
  931. }
  932. masterLandObject.SendLandUpdateToAvatarsOverMe();
  933. m_scene.ForEachClient(SendParcelOverlay);
  934. }
  935. public void Join(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id)
  936. {
  937. join(start_x, start_y, end_x, end_y, attempting_user_id);
  938. }
  939. public void Subdivide(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id)
  940. {
  941. subdivide(start_x, start_y, end_x, end_y, attempting_user_id);
  942. }
  943. #endregion
  944. #region Parcel Updating
  945. /// <summary>
  946. /// Send the parcel overlay blocks to the client. We send the overlay packets
  947. /// around a location and limited by the 'parcelLayerViewDistance'. This number
  948. /// is usually 128 and the code is arranged so it sends all the parcel overlay
  949. /// information for a whole region if the region is legacy sized (256x256). If
  950. /// the region is larger, only the parcel layer information is sent around
  951. /// the point specified. This reduces the problem of parcel layer information
  952. /// blocks increasing exponentially as region size increases.
  953. /// </summary>
  954. /// <param name="remote_client">The object representing the client</param>
  955. /// <param name="xPlace">X position in the region to send surrounding parcel layer info</param>
  956. /// <param name="yPlace">y position in the region to send surrounding parcel layer info</param>
  957. /// <param name="layerViewDistance">Distance from x,y position to send parcel layer info</param>
  958. public void SendParcelOverlay(IClientAPI remote_client)
  959. {
  960. if (remote_client.SceneAgent.PresenceType == PresenceType.Npc)
  961. return;
  962. const int LAND_BLOCKS_PER_PACKET = 1024;
  963. byte[] byteArray = new byte[LAND_BLOCKS_PER_PACKET];
  964. int byteArrayCount = 0;
  965. int sequenceID = 0;
  966. // Layer data is in LandUnit (4m) chunks
  967. for (int y = 0; y < m_scene.RegionInfo.RegionSizeY; y += LandUnit)
  968. {
  969. for (int x = 0; x < m_scene.RegionInfo.RegionSizeX; x += LandUnit)
  970. {
  971. byte tempByte = 0; //This represents the byte for the current 4x4
  972. ILandObject currentParcelBlock = GetLandObject(x, y);
  973. if (currentParcelBlock != null)
  974. {
  975. // types
  976. if (currentParcelBlock.LandData.OwnerID == remote_client.AgentId)
  977. {
  978. //Owner Flag
  979. tempByte = (byte)LandChannel.LAND_TYPE_OWNED_BY_REQUESTER;
  980. }
  981. else if (currentParcelBlock.LandData.IsGroupOwned && remote_client.IsGroupMember(currentParcelBlock.LandData.GroupID))
  982. {
  983. tempByte = (byte)LandChannel.LAND_TYPE_OWNED_BY_GROUP;
  984. }
  985. else if (currentParcelBlock.LandData.SalePrice > 0 &&
  986. (currentParcelBlock.LandData.AuthBuyerID == UUID.Zero ||
  987. currentParcelBlock.LandData.AuthBuyerID == remote_client.AgentId))
  988. {
  989. //Sale type
  990. tempByte = (byte)LandChannel.LAND_TYPE_IS_FOR_SALE;
  991. }
  992. else if (currentParcelBlock.LandData.OwnerID == UUID.Zero)
  993. {
  994. //Public type
  995. tempByte = (byte)LandChannel.LAND_TYPE_PUBLIC; // this does nothing, its zero
  996. }
  997. // LAND_TYPE_IS_BEING_AUCTIONED still unsuported
  998. else
  999. {
  1000. //Other Flag
  1001. tempByte = (byte)LandChannel.LAND_TYPE_OWNED_BY_OTHER;
  1002. }
  1003. // now flags
  1004. // border control
  1005. ILandObject westParcel = null;
  1006. ILandObject southParcel = null;
  1007. if (x > 0)
  1008. {
  1009. westParcel = GetLandObject((x - 1), y);
  1010. }
  1011. if (y > 0)
  1012. {
  1013. southParcel = GetLandObject(x, (y - 1));
  1014. }
  1015. if (x == 0)
  1016. {
  1017. tempByte |= (byte)LandChannel.LAND_FLAG_PROPERTY_BORDER_WEST;
  1018. }
  1019. else if (westParcel != null && westParcel != currentParcelBlock)
  1020. {
  1021. tempByte |= (byte)LandChannel.LAND_FLAG_PROPERTY_BORDER_WEST;
  1022. }
  1023. if (y == 0)
  1024. {
  1025. tempByte |= (byte)LandChannel.LAND_FLAG_PROPERTY_BORDER_SOUTH;
  1026. }
  1027. else if (southParcel != null && southParcel != currentParcelBlock)
  1028. {
  1029. tempByte |= (byte)LandChannel.LAND_FLAG_PROPERTY_BORDER_SOUTH;
  1030. }
  1031. // local sound
  1032. if ((currentParcelBlock.LandData.Flags & (uint)ParcelFlags.SoundLocal) != 0)
  1033. tempByte |= (byte)LandChannel.LAND_FLAG_LOCALSOUND;
  1034. // hide avatars
  1035. if (!currentParcelBlock.LandData.SeeAVs)
  1036. tempByte |= (byte)LandChannel.LAND_FLAG_HIDEAVATARS;
  1037. byteArray[byteArrayCount] = tempByte;
  1038. byteArrayCount++;
  1039. if (byteArrayCount >= LAND_BLOCKS_PER_PACKET)
  1040. {
  1041. remote_client.SendLandParcelOverlay(byteArray, sequenceID);
  1042. byteArrayCount = 0;
  1043. sequenceID++;
  1044. byteArray = new byte[LAND_BLOCKS_PER_PACKET];
  1045. }
  1046. }
  1047. }
  1048. }
  1049. if (byteArrayCount > 0)
  1050. {
  1051. remote_client.SendLandParcelOverlay(byteArray, sequenceID);
  1052. }
  1053. }
  1054. public void ClientOnParcelPropertiesRequest(int start_x, int start_y, int end_x, int end_y, int sequence_id,
  1055. bool snap_selection, IClientAPI remote_client)
  1056. {
  1057. //Get the land objects within the bounds
  1058. List<ILandObject> temp = new List<ILandObject>();
  1059. int inc_x = end_x - start_x;
  1060. int inc_y = end_y - start_y;
  1061. for (int x = 0; x < inc_x; x++)
  1062. {
  1063. for (int y = 0; y < inc_y; y++)
  1064. {
  1065. ILandObject currentParcel = GetLandObject(start_x + x, start_y + y);
  1066. if (currentParcel != null)
  1067. {
  1068. if (!temp.Contains(currentParcel))
  1069. {
  1070. if (!currentParcel.IsEitherBannedOrRestricted(remote_client.AgentId))
  1071. {
  1072. currentParcel.ForceUpdateLandInfo();
  1073. temp.Add(currentParcel);
  1074. }
  1075. }
  1076. }
  1077. }
  1078. }
  1079. int requestResult = LandChannel.LAND_RESULT_SINGLE;
  1080. if (temp.Count > 1)
  1081. {
  1082. requestResult = LandChannel.LAND_RESULT_MULTIPLE;
  1083. }
  1084. for (int i = 0; i < temp.Count; i++)
  1085. {
  1086. temp[i].SendLandProperties(sequence_id, snap_selection, requestResult, remote_client);
  1087. }
  1088. // SendParcelOverlay(remote_client);
  1089. }
  1090. public void UpdateLandProperties(ILandObject land, LandUpdateArgs args, IClientAPI remote_client)
  1091. {
  1092. bool snap_selection = false;
  1093. bool needOverlay = false;
  1094. if (land.UpdateLandProperties(args, remote_client, out snap_selection, out needOverlay))
  1095. {
  1096. //the proprieties to who changed them
  1097. ScenePresence av = m_scene.GetScenePresence(remote_client.AgentId);
  1098. if(av.IsChildAgent || land != GetLandObject(av.AbsolutePosition.X, av.AbsolutePosition.Y))
  1099. land.SendLandProperties(-10000, false, LandChannel.LAND_RESULT_SINGLE, remote_client);
  1100. else
  1101. land.SendLandProperties(0, false, LandChannel.LAND_RESULT_SINGLE, remote_client);
  1102. UUID parcelID = land.LandData.GlobalID;
  1103. m_scene.ForEachScenePresence(delegate(ScenePresence avatar)
  1104. {
  1105. if (avatar.IsDeleted || avatar.isNPC)
  1106. return;
  1107. IClientAPI client = avatar.ControllingClient;
  1108. if (needOverlay)
  1109. SendParcelOverlay(client);
  1110. if (avatar.IsChildAgent)
  1111. return;
  1112. ILandObject aland = GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
  1113. if (aland != null)
  1114. {
  1115. if (client != remote_client && land == aland)
  1116. aland.SendLandProperties(0, false, LandChannel.LAND_RESULT_SINGLE, client);
  1117. }
  1118. if (avatar.currentParcelUUID == parcelID)
  1119. avatar.currentParcelUUID = parcelID; // force parcel flags review
  1120. });
  1121. }
  1122. }
  1123. public void ClientOnParcelPropertiesUpdateRequest(LandUpdateArgs args, int localID, IClientAPI remote_client)
  1124. {
  1125. ILandObject land;
  1126. lock (m_landList)
  1127. {
  1128. m_landList.TryGetValue(localID, out land);
  1129. }
  1130. if (land != null)
  1131. {
  1132. UpdateLandProperties(land, args, remote_client);
  1133. m_scene.EventManager.TriggerOnParcelPropertiesUpdateRequest(args, localID, remote_client);
  1134. }
  1135. }
  1136. public void ClientOnParcelDivideRequest(int west, int south, int east, int north, IClientAPI remote_client)
  1137. {
  1138. subdivide(west, south, east, north, remote_client.AgentId);
  1139. }
  1140. public void ClientOnParcelJoinRequest(int west, int south, int east, int north, IClientAPI remote_client)
  1141. {
  1142. join(west, south, east, north, remote_client.AgentId);
  1143. }
  1144. public void ClientOnParcelSelectObjects(int local_id, int request_type,
  1145. List<UUID> returnIDs, IClientAPI remote_client)
  1146. {
  1147. m_landList[local_id].SendForceObjectSelect(local_id, request_type, returnIDs, remote_client);
  1148. }
  1149. public void ClientOnParcelObjectOwnerRequest(int local_id, IClientAPI remote_client)
  1150. {
  1151. ILandObject land;
  1152. lock (m_landList)
  1153. {
  1154. m_landList.TryGetValue(local_id, out land);
  1155. }
  1156. if (land != null)
  1157. {
  1158. m_scene.EventManager.TriggerParcelPrimCountUpdate();
  1159. m_landList[local_id].SendLandObjectOwners(remote_client);
  1160. }
  1161. else
  1162. {
  1163. m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Invalid land object {0} passed for parcel object owner request", local_id);
  1164. }
  1165. }
  1166. public void ClientOnParcelGodForceOwner(int local_id, UUID ownerID, IClientAPI remote_client)
  1167. {
  1168. ILandObject land;
  1169. lock (m_landList)
  1170. {
  1171. m_landList.TryGetValue(local_id, out land);
  1172. }
  1173. if (land != null)
  1174. {
  1175. if (m_scene.Permissions.IsGod(remote_client.AgentId))
  1176. {
  1177. land.LandData.OwnerID = ownerID;
  1178. land.LandData.GroupID = UUID.Zero;
  1179. land.LandData.IsGroupOwned = false;
  1180. land.LandData.Flags &= ~(uint) (ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects | ParcelFlags.ShowDirectory);
  1181. m_scene.ForEachClient(SendParcelOverlay);
  1182. land.SendLandUpdateToClient(true, remote_client);
  1183. UpdateLandObject(land.LandData.LocalID, land.LandData);
  1184. }
  1185. }
  1186. }
  1187. public void ClientOnParcelAbandonRequest(int local_id, IClientAPI remote_client)
  1188. {
  1189. ILandObject land;
  1190. lock (m_landList)
  1191. {
  1192. m_landList.TryGetValue(local_id, out land);
  1193. }
  1194. if (land != null)
  1195. {
  1196. if (m_scene.Permissions.CanAbandonParcel(remote_client.AgentId, land))
  1197. {
  1198. land.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
  1199. land.LandData.GroupID = UUID.Zero;
  1200. land.LandData.IsGroupOwned = false;
  1201. land.LandData.Flags &= ~(uint) (ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects | ParcelFlags.ShowDirectory);
  1202. m_scene.ForEachClient(SendParcelOverlay);
  1203. land.SendLandUpdateToClient(true, remote_client);
  1204. UpdateLandObject(land.LandData.LocalID, land.LandData);
  1205. }
  1206. }
  1207. }
  1208. public void ClientOnParcelReclaim(int local_id, IClientAPI remote_client)
  1209. {
  1210. ILandObject land;
  1211. lock (m_landList)
  1212. {
  1213. m_landList.TryGetValue(local_id, out land);
  1214. }
  1215. if (land != null)
  1216. {
  1217. if (m_scene.Permissions.CanReclaimParcel(remote_client.AgentId, land))
  1218. {
  1219. land.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
  1220. land.LandData.ClaimDate = Util.UnixTimeSinceEpoch();
  1221. land.LandData.GroupID = UUID.Zero;
  1222. land.LandData.IsGroupOwned = false;
  1223. land.LandData.SalePrice = 0;
  1224. land.LandData.AuthBuyerID = UUID.Zero;
  1225. land.LandData.Flags &= ~(uint) (ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects | ParcelFlags.ShowDirectory);
  1226. m_scene.ForEachClient(SendParcelOverlay);
  1227. land.SendLandUpdateToClient(true, remote_client);
  1228. UpdateLandObject(land.LandData.LocalID, land.LandData);
  1229. }
  1230. }
  1231. }
  1232. #endregion
  1233. // If the economy has been validated by the economy module,
  1234. // and land has been validated as well, this method transfers
  1235. // the land ownership
  1236. public void EventManagerOnLandBuy(Object o, EventManager.LandBuyArgs e)
  1237. {
  1238. if (e.economyValidated && e.landValidated)
  1239. {
  1240. ILandObject land;
  1241. lock (m_landList)
  1242. {
  1243. m_landList.TryGetValue(e.parcelLocalID, out land);
  1244. }
  1245. if (land != null)
  1246. {
  1247. land.UpdateLandSold(e.agentId, e.groupId, e.groupOwned, (uint)e.transactionID, e.parcelPrice, e.parcelArea);
  1248. }
  1249. }
  1250. }
  1251. // After receiving a land buy packet, first the data needs to
  1252. // be validated. This method validates the right to buy the
  1253. // parcel
  1254. public void EventManagerOnValidateLandBuy(Object o, EventManager.LandBuyArgs e)
  1255. {
  1256. if (e.landValidated == false)
  1257. {
  1258. ILandObject lob = null;
  1259. lock (m_landList)
  1260. {
  1261. m_landList.TryGetValue(e.parcelLocalID, out lob);
  1262. }
  1263. if (lob != null)
  1264. {
  1265. UUID AuthorizedID = lob.LandData.AuthBuyerID;
  1266. int saleprice = lob.LandData.SalePrice;
  1267. UUID pOwnerID = lob.LandData.OwnerID;
  1268. bool landforsale = ((lob.LandData.Flags &
  1269. (uint)(ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects)) != 0);
  1270. if ((AuthorizedID == UUID.Zero || AuthorizedID == e.agentId) && e.parcelPrice >= saleprice && landforsale)
  1271. {
  1272. // TODO I don't think we have to lock it here, no?
  1273. //lock (e)
  1274. //{
  1275. e.parcelOwnerID = pOwnerID;
  1276. e.landValidated = true;
  1277. //}
  1278. }
  1279. }
  1280. }
  1281. }
  1282. void ClientOnParcelDeedToGroup(int parcelLocalID, UUID groupID, IClientAPI remote_client)
  1283. {
  1284. ILandObject land;
  1285. lock (m_landList)
  1286. {
  1287. m_landList.TryGetValue(parcelLocalID, out land);
  1288. }
  1289. if (!m_scene.Permissions.CanDeedParcel(remote_client.AgentId, land))
  1290. return;
  1291. if (land != null)
  1292. {
  1293. land.DeedToGroup(groupID);
  1294. }
  1295. }
  1296. #region Land Object From Storage Functions
  1297. private void EventManagerOnIncomingLandDataFromStorage(List<LandData> data)
  1298. {
  1299. lock (m_landList)
  1300. {
  1301. for (int i = 0; i < data.Count; i++)
  1302. IncomingLandObjectFromStorage(data[i]);
  1303. // Layer data is in LandUnit (4m) chunks
  1304. for (int y = 0; y < m_scene.RegionInfo.RegionSizeY / Constants.TerrainPatchSize * (Constants.TerrainPatchSize / LandUnit); y++)
  1305. {
  1306. for (int x = 0; x < m_scene.RegionInfo.RegionSizeX / Constants.TerrainPatchSize * (Constants.TerrainPatchSize / LandUnit); x++)
  1307. {
  1308. if (m_landIDList[x, y] == 0)
  1309. {
  1310. if (m_landList.Count == 1)
  1311. {
  1312. m_log.DebugFormat(
  1313. "[{0}]: Auto-extending land parcel as landID at {1},{2} is 0 and only one land parcel is present in {3}",
  1314. LogHeader, x, y, m_scene.Name);
  1315. int onlyParcelID = 0;
  1316. ILandObject onlyLandObject = null;
  1317. foreach (KeyValuePair<int, ILandObject> kvp in m_landList)
  1318. {
  1319. onlyParcelID = kvp.Key;
  1320. onlyLandObject = kvp.Value;
  1321. break;
  1322. }
  1323. // There is only one parcel. Grow it to fill all the unallocated spaces.
  1324. for (int xx = 0; xx < m_landIDList.GetLength(0); xx++)
  1325. for (int yy = 0; yy < m_landIDList.GetLength(1); yy++)
  1326. if (m_landIDList[xx, yy] == 0)
  1327. m_landIDList[xx, yy] = onlyParcelID;
  1328. onlyLandObject.LandBitmap = CreateBitmapForID(onlyParcelID);
  1329. }
  1330. else if (m_landList.Count > 1)
  1331. {
  1332. m_log.DebugFormat(
  1333. "{0}: Auto-creating land parcel as landID at {1},{2} is 0 and more than one land parcel is present in {3}",
  1334. LogHeader, x, y, m_scene.Name);
  1335. // There are several other parcels so we must create a new one for the unassigned space
  1336. ILandObject newLand = new LandObject(UUID.Zero, false, m_scene);
  1337. // Claim all the unclaimed "0" ids
  1338. newLand.SetLandBitmap(CreateBitmapForID(0));
  1339. newLand.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
  1340. newLand.LandData.ClaimDate = Util.UnixTimeSinceEpoch();
  1341. newLand = AddLandObject(newLand);
  1342. }
  1343. else
  1344. {
  1345. // We should never reach this point as the separate code path when no land data exists should have fired instead.
  1346. m_log.WarnFormat(
  1347. "{0}: Ignoring request to auto-create parcel in {1} as there are no other parcels present",
  1348. LogHeader, m_scene.Name);
  1349. }
  1350. }
  1351. }
  1352. }
  1353. }
  1354. }
  1355. private void IncomingLandObjectFromStorage(LandData data)
  1356. {
  1357. ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene);
  1358. new_land.LandData = data.Copy();
  1359. new_land.SetLandBitmapFromByteArray();
  1360. AddLandObject(new_land);
  1361. // new_land.SendLandUpdateToAvatarsOverMe();
  1362. }
  1363. public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient)
  1364. {
  1365. if (localID != -1)
  1366. {
  1367. ILandObject selectedParcel = null;
  1368. lock (m_landList)
  1369. {
  1370. m_landList.TryGetValue(localID, out selectedParcel);
  1371. }
  1372. if (selectedParcel == null)
  1373. return;
  1374. selectedParcel.ReturnLandObjects(returnType, agentIDs, taskIDs, remoteClient);
  1375. }
  1376. else
  1377. {
  1378. if (returnType != 1)
  1379. {
  1380. m_log.WarnFormat("[LAND MANAGEMENT MODULE]: ReturnObjectsInParcel: unknown return type {0}", returnType);
  1381. return;
  1382. }
  1383. // We get here when the user returns objects from the list of Top Colliders or Top Scripts.
  1384. // In that case we receive specific object UUID's, but no parcel ID.
  1385. Dictionary<UUID, HashSet<SceneObjectGroup>> returns = new Dictionary<UUID, HashSet<SceneObjectGroup>>();
  1386. foreach (UUID groupID in taskIDs)
  1387. {
  1388. SceneObjectGroup obj = m_scene.GetSceneObjectGroup(groupID);
  1389. if (obj != null)
  1390. {
  1391. if (!returns.ContainsKey(obj.OwnerID))
  1392. returns[obj.OwnerID] = new HashSet<SceneObjectGroup>();
  1393. returns[obj.OwnerID].Add(obj);
  1394. }
  1395. else
  1396. {
  1397. m_log.WarnFormat("[LAND MANAGEMENT MODULE]: ReturnObjectsInParcel: unknown object {0}", groupID);
  1398. }
  1399. }
  1400. int num = 0;
  1401. foreach (HashSet<SceneObjectGroup> objs in returns.Values)
  1402. num += objs.Count;
  1403. m_log.DebugFormat("[LAND MANAGEMENT MODULE]: Returning {0} specific object(s)", num);
  1404. foreach (HashSet<SceneObjectGroup> objs in returns.Values)
  1405. {
  1406. List<SceneObjectGroup> objs2 = new List<SceneObjectGroup>(objs);
  1407. if (m_scene.Permissions.CanReturnObjects(null, remoteClient.AgentId, objs2))
  1408. {
  1409. m_scene.returnObjects(objs2.ToArray(), remoteClient.AgentId);
  1410. }
  1411. else
  1412. {
  1413. m_log.WarnFormat("[LAND MANAGEMENT MODULE]: ReturnObjectsInParcel: not permitted to return {0} object(s) belonging to user {1}",
  1414. objs2.Count, objs2[0].OwnerID);
  1415. }
  1416. }
  1417. }
  1418. }
  1419. public void EventManagerOnNoLandDataFromStorage()
  1420. {
  1421. ResetSimLandObjects();
  1422. CreateDefaultParcel();
  1423. }
  1424. #endregion
  1425. public void setParcelObjectMaxOverride(overrideParcelMaxPrimCountDelegate overrideDel)
  1426. {
  1427. lock (m_landList)
  1428. {
  1429. foreach (LandObject obj in m_landList.Values)
  1430. {
  1431. obj.SetParcelObjectMaxOverride(overrideDel);
  1432. }
  1433. }
  1434. }
  1435. public void setSimulatorObjectMaxOverride(overrideSimulatorMaxPrimCountDelegate overrideDel)
  1436. {
  1437. }
  1438. #region CAPS handler
  1439. private void EventManagerOnRegisterCaps(UUID agentID, Caps caps)
  1440. {
  1441. string capsBase = "/CAPS/" + caps.CapsObjectPath;
  1442. caps.RegisterHandler(
  1443. "RemoteParcelRequest",
  1444. new RestStreamHandler(
  1445. "POST",
  1446. capsBase + remoteParcelRequestPath,
  1447. (request, path, param, httpRequest, httpResponse)
  1448. => RemoteParcelRequest(request, path, param, agentID, caps),
  1449. "RemoteParcelRequest",
  1450. agentID.ToString()));
  1451. UUID parcelCapID = UUID.Random();
  1452. caps.RegisterHandler(
  1453. "ParcelPropertiesUpdate",
  1454. new RestStreamHandler(
  1455. "POST",
  1456. "/CAPS/" + parcelCapID,
  1457. (request, path, param, httpRequest, httpResponse)
  1458. => ProcessPropertiesUpdate(request, path, param, agentID, caps),
  1459. "ParcelPropertiesUpdate",
  1460. agentID.ToString()));
  1461. }
  1462. private string ProcessPropertiesUpdate(string request, string path, string param, UUID agentID, Caps caps)
  1463. {
  1464. IClientAPI client;
  1465. if (!m_scene.TryGetClient(agentID, out client))
  1466. {
  1467. m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Unable to retrieve IClientAPI for {0}", agentID);
  1468. return LLSDHelpers.SerialiseLLSDReply(new LLSDEmpty());
  1469. }
  1470. ParcelPropertiesUpdateMessage properties = new ParcelPropertiesUpdateMessage();
  1471. OpenMetaverse.StructuredData.OSDMap args = (OpenMetaverse.StructuredData.OSDMap) OSDParser.DeserializeLLSDXml(request);
  1472. properties.Deserialize(args);
  1473. LandUpdateArgs land_update = new LandUpdateArgs();
  1474. int parcelID = properties.LocalID;
  1475. land_update.AuthBuyerID = properties.AuthBuyerID;
  1476. land_update.Category = properties.Category;
  1477. land_update.Desc = properties.Desc;
  1478. land_update.GroupID = properties.GroupID;
  1479. land_update.LandingType = (byte) properties.Landing;
  1480. land_update.MediaAutoScale = (byte) Convert.ToInt32(properties.MediaAutoScale);
  1481. land_update.MediaID = properties.MediaID;
  1482. land_update.MediaURL = properties.MediaURL;
  1483. land_update.MusicURL = properties.MusicURL;
  1484. land_update.Name = properties.Name;
  1485. land_update.ParcelFlags = (uint) properties.ParcelFlags;
  1486. land_update.PassHours = (int) properties.PassHours;
  1487. land_update.PassPrice = (int) properties.PassPrice;
  1488. land_update.SalePrice = (int) properties.SalePrice;
  1489. land_update.SnapshotID = properties.SnapshotID;
  1490. land_update.UserLocation = properties.UserLocation;
  1491. land_update.UserLookAt = properties.UserLookAt;
  1492. land_update.MediaDescription = properties.MediaDesc;
  1493. land_update.MediaType = properties.MediaType;
  1494. land_update.MediaWidth = properties.MediaWidth;
  1495. land_update.MediaHeight = properties.MediaHeight;
  1496. land_update.MediaLoop = properties.MediaLoop;
  1497. land_update.ObscureMusic = properties.ObscureMusic;
  1498. land_update.ObscureMedia = properties.ObscureMedia;
  1499. if (args.ContainsKey("see_avs"))
  1500. {
  1501. land_update.SeeAVs = args["see_avs"].AsBoolean();
  1502. land_update.AnyAVSounds = args["any_av_sounds"].AsBoolean();
  1503. land_update.GroupAVSounds = args["group_av_sounds"].AsBoolean();
  1504. }
  1505. else
  1506. {
  1507. land_update.SeeAVs = true;
  1508. land_update.AnyAVSounds = true;
  1509. land_update.GroupAVSounds = true;
  1510. }
  1511. ILandObject land;
  1512. lock (m_landList)
  1513. {
  1514. m_landList.TryGetValue(parcelID, out land);
  1515. }
  1516. if (land != null)
  1517. {
  1518. UpdateLandProperties(land,land_update, client);
  1519. m_scene.EventManager.TriggerOnParcelPropertiesUpdateRequest(land_update, parcelID, client);
  1520. }
  1521. else
  1522. {
  1523. m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Unable to find parcelID {0}", parcelID);
  1524. }
  1525. return LLSDHelpers.SerialiseLLSDReply(new LLSDEmpty());
  1526. }
  1527. // we cheat here: As we don't have (and want) a grid-global parcel-store, we can't return the
  1528. // "real" parcelID, because we wouldn't be able to map that to the region the parcel belongs to.
  1529. // So, we create a "fake" parcelID by using the regionHandle (64 bit), and the local (integer) x
  1530. // and y coordinate (each 8 bit), encoded in a UUID (128 bit).
  1531. //
  1532. // Request format:
  1533. // <llsd>
  1534. // <map>
  1535. // <key>location</key>
  1536. // <array>
  1537. // <real>1.23</real>
  1538. // <real>45..6</real>
  1539. // <real>78.9</real>
  1540. // </array>
  1541. // <key>region_id</key>
  1542. // <uuid>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</uuid>
  1543. // </map>
  1544. // </llsd>
  1545. private string RemoteParcelRequest(string request, string path, string param, UUID agentID, Caps caps)
  1546. {
  1547. UUID parcelID = UUID.Zero;
  1548. try
  1549. {
  1550. Hashtable hash = new Hashtable();
  1551. hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request));
  1552. if (hash.ContainsKey("region_id") && hash.ContainsKey("location"))
  1553. {
  1554. UUID regionID = (UUID)hash["region_id"];
  1555. ArrayList list = (ArrayList)hash["location"];
  1556. uint x = (uint)(double)list[0];
  1557. uint y = (uint)(double)list[1];
  1558. if (hash.ContainsKey("region_handle"))
  1559. {
  1560. // if you do a "About Landmark" on a landmark a second time, the viewer sends the
  1561. // region_handle it got earlier via RegionHandleRequest
  1562. ulong regionHandle = Util.BytesToUInt64Big((byte[])hash["region_handle"]);
  1563. parcelID = Util.BuildFakeParcelID(regionHandle, x, y);
  1564. }
  1565. else if (regionID == m_scene.RegionInfo.RegionID)
  1566. {
  1567. // a parcel request for a local parcel => no need to query the grid
  1568. parcelID = Util.BuildFakeParcelID(m_scene.RegionInfo.RegionHandle, x, y);
  1569. }
  1570. else
  1571. {
  1572. // a parcel request for a parcel in another region. Ask the grid about the region
  1573. GridRegion info = m_scene.GridService.GetRegionByUUID(UUID.Zero, regionID);
  1574. if (info != null)
  1575. parcelID = Util.BuildFakeParcelID(info.RegionHandle, x, y);
  1576. }
  1577. }
  1578. }
  1579. catch (LLSD.LLSDParseException e)
  1580. {
  1581. m_log.ErrorFormat("[LAND MANAGEMENT MODULE]: Fetch error: {0}", e.Message);
  1582. m_log.ErrorFormat("[LAND MANAGEMENT MODULE]: ... in request {0}", request);
  1583. }
  1584. catch (InvalidCastException)
  1585. {
  1586. m_log.ErrorFormat("[LAND MANAGEMENT MODULE]: Wrong type in request {0}", request);
  1587. }
  1588. LLSDRemoteParcelResponse response = new LLSDRemoteParcelResponse();
  1589. response.parcel_id = parcelID;
  1590. m_log.DebugFormat("[LAND MANAGEMENT MODULE]: Got parcelID {0}", parcelID);
  1591. return LLSDHelpers.SerialiseLLSDReply(response);
  1592. }
  1593. #endregion
  1594. private void ClientOnParcelInfoRequest(IClientAPI remoteClient, UUID parcelID)
  1595. {
  1596. if (parcelID == UUID.Zero)
  1597. return;
  1598. ExtendedLandData data = (ExtendedLandData)parcelInfoCache.Get(parcelID.ToString(),
  1599. delegate(string id)
  1600. {
  1601. UUID parcel = UUID.Zero;
  1602. UUID.TryParse(id, out parcel);
  1603. // assume we've got the parcelID we just computed in RemoteParcelRequest
  1604. ExtendedLandData extLandData = new ExtendedLandData();
  1605. Util.ParseFakeParcelID(parcel, out extLandData.RegionHandle,
  1606. out extLandData.X, out extLandData.Y);
  1607. m_log.DebugFormat("[LAND MANAGEMENT MODULE]: Got parcelinfo request for regionHandle {0}, x/y {1}/{2}",
  1608. extLandData.RegionHandle, extLandData.X, extLandData.Y);
  1609. // for this region or for somewhere else?
  1610. if (extLandData.RegionHandle == m_scene.RegionInfo.RegionHandle)
  1611. {
  1612. extLandData.LandData = this.GetLandObject(extLandData.X, extLandData.Y).LandData;
  1613. extLandData.RegionAccess = m_scene.RegionInfo.AccessLevel;
  1614. }
  1615. else
  1616. {
  1617. ILandService landService = m_scene.RequestModuleInterface<ILandService>();
  1618. extLandData.LandData = landService.GetLandData(m_scene.RegionInfo.ScopeID,
  1619. extLandData.RegionHandle,
  1620. extLandData.X,
  1621. extLandData.Y,
  1622. out extLandData.RegionAccess);
  1623. if (extLandData.LandData == null)
  1624. {
  1625. // we didn't find the region/land => don't cache
  1626. return null;
  1627. }
  1628. }
  1629. return extLandData;
  1630. });
  1631. if (data != null) // if we found some data, send it
  1632. {
  1633. GridRegion info;
  1634. if (data.RegionHandle == m_scene.RegionInfo.RegionHandle)
  1635. {
  1636. info = new GridRegion(m_scene.RegionInfo);
  1637. }
  1638. else
  1639. {
  1640. // most likely still cached from building the extLandData entry
  1641. uint x = 0, y = 0;
  1642. Util.RegionHandleToWorldLoc(data.RegionHandle, out x, out y);
  1643. info = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
  1644. }
  1645. // we need to transfer the fake parcelID, not the one in landData, so the viewer can match it to the landmark.
  1646. m_log.DebugFormat("[LAND MANAGEMENT MODULE]: got parcelinfo for parcel {0} in region {1}; sending...",
  1647. data.LandData.Name, data.RegionHandle);
  1648. // HACK for now
  1649. RegionInfo r = new RegionInfo();
  1650. r.RegionName = info.RegionName;
  1651. r.RegionLocX = (uint)info.RegionLocX;
  1652. r.RegionLocY = (uint)info.RegionLocY;
  1653. r.RegionSettings.Maturity = (int)Util.ConvertAccessLevelToMaturity(data.RegionAccess);
  1654. remoteClient.SendParcelInfo(r, data.LandData, parcelID, data.X, data.Y);
  1655. }
  1656. else
  1657. m_log.Debug("[LAND MANAGEMENT MODULE]: got no parcelinfo; not sending");
  1658. }
  1659. public void setParcelOtherCleanTime(IClientAPI remoteClient, int localID, int otherCleanTime)
  1660. {
  1661. ILandObject land;
  1662. lock (m_landList)
  1663. {
  1664. m_landList.TryGetValue(localID, out land);
  1665. }
  1666. if (land == null) return;
  1667. if (!m_scene.Permissions.CanEditParcelProperties(remoteClient.AgentId, land, GroupPowers.LandOptions, false))
  1668. return;
  1669. land.LandData.OtherCleanTime = otherCleanTime;
  1670. UpdateLandObject(localID, land.LandData);
  1671. }
  1672. public void ClientOnParcelGodMark(IClientAPI client, UUID god, int landID)
  1673. {
  1674. ILandObject land = null;
  1675. List<ILandObject> Land = ((Scene)client.Scene).LandChannel.AllParcels();
  1676. foreach (ILandObject landObject in Land)
  1677. {
  1678. if (landObject.LandData.LocalID == landID)
  1679. {
  1680. land = landObject;
  1681. }
  1682. }
  1683. land.DeedToGroup(DefaultGodParcelGroup);
  1684. land.LandData.Name = DefaultGodParcelName;
  1685. land.SendLandUpdateToAvatarsOverMe();
  1686. }
  1687. private void ClientOnSimWideDeletes(IClientAPI client, UUID agentID, int flags, UUID targetID)
  1688. {
  1689. ScenePresence SP;
  1690. ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out SP);
  1691. List<SceneObjectGroup> returns = new List<SceneObjectGroup>();
  1692. if (SP.UserLevel != 0)
  1693. {
  1694. if (flags == 0) //All parcels, scripted or not
  1695. {
  1696. ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
  1697. {
  1698. if (e.OwnerID == targetID)
  1699. {
  1700. returns.Add(e);
  1701. }
  1702. }
  1703. );
  1704. }
  1705. if (flags == 4) //All parcels, scripted object
  1706. {
  1707. ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
  1708. {
  1709. if (e.OwnerID == targetID)
  1710. {
  1711. if (e.ContainsScripts())
  1712. {
  1713. returns.Add(e);
  1714. }
  1715. }
  1716. }
  1717. );
  1718. }
  1719. if (flags == 4) //not target parcel, scripted object
  1720. {
  1721. ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
  1722. {
  1723. if (e.OwnerID == targetID)
  1724. {
  1725. ILandObject landobject = ((Scene)client.Scene).LandChannel.GetLandObject(e.AbsolutePosition.X, e.AbsolutePosition.Y);
  1726. if (landobject.LandData.OwnerID != e.OwnerID)
  1727. {
  1728. if (e.ContainsScripts())
  1729. {
  1730. returns.Add(e);
  1731. }
  1732. }
  1733. }
  1734. }
  1735. );
  1736. }
  1737. foreach (SceneObjectGroup ol in returns)
  1738. {
  1739. ReturnObject(ol, client);
  1740. }
  1741. }
  1742. }
  1743. public void ReturnObject(SceneObjectGroup obj, IClientAPI client)
  1744. {
  1745. SceneObjectGroup[] objs = new SceneObjectGroup[1];
  1746. objs[0] = obj;
  1747. ((Scene)client.Scene).returnObjects(objs, client.AgentId);
  1748. }
  1749. Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>();
  1750. public void ClientOnParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
  1751. {
  1752. ScenePresence targetAvatar = null;
  1753. ((Scene)client.Scene).TryGetScenePresence(target, out targetAvatar);
  1754. ScenePresence parcelManager = null;
  1755. ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out parcelManager);
  1756. System.Threading.Timer Timer;
  1757. if (targetAvatar.UserLevel == 0)
  1758. {
  1759. ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
  1760. if (!((Scene)client.Scene).Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze, true))
  1761. return;
  1762. if (flags == 0)
  1763. {
  1764. targetAvatar.AllowMovement = false;
  1765. targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has frozen you for 30 seconds. You cannot move or interact with the world.");
  1766. parcelManager.ControllingClient.SendAlertMessage("Avatar Frozen.");
  1767. System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen);
  1768. Timer = new System.Threading.Timer(timeCB, targetAvatar, 30000, 0);
  1769. Timers.Add(targetAvatar.UUID, Timer);
  1770. }
  1771. else
  1772. {
  1773. targetAvatar.AllowMovement = true;
  1774. targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has unfrozen you.");
  1775. parcelManager.ControllingClient.SendAlertMessage("Avatar Unfrozen.");
  1776. Timers.TryGetValue(targetAvatar.UUID, out Timer);
  1777. Timers.Remove(targetAvatar.UUID);
  1778. Timer.Dispose();
  1779. }
  1780. }
  1781. }
  1782. private void OnEndParcelFrozen(object avatar)
  1783. {
  1784. ScenePresence targetAvatar = (ScenePresence)avatar;
  1785. targetAvatar.AllowMovement = true;
  1786. System.Threading.Timer Timer;
  1787. Timers.TryGetValue(targetAvatar.UUID, out Timer);
  1788. Timers.Remove(targetAvatar.UUID);
  1789. targetAvatar.ControllingClient.SendAgentAlertMessage("The freeze has worn off; you may go about your business.", false);
  1790. }
  1791. public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
  1792. {
  1793. ScenePresence targetAvatar = null;
  1794. ScenePresence parcelManager = null;
  1795. // Must have presences
  1796. if (!m_scene.TryGetScenePresence(target, out targetAvatar) ||
  1797. !m_scene.TryGetScenePresence(client.AgentId, out parcelManager))
  1798. return;
  1799. // Cannot eject estate managers or gods
  1800. if (m_scene.Permissions.IsAdministrator(target))
  1801. return;
  1802. // Check if you even have permission to do this
  1803. ILandObject land = m_scene.LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
  1804. if (!m_scene.Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze, true) &&
  1805. !m_scene.Permissions.IsAdministrator(client.AgentId))
  1806. return;
  1807. Vector3 pos = m_scene.GetNearestAllowedPosition(targetAvatar, land);
  1808. targetAvatar.TeleportWithMomentum(pos, null);
  1809. targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
  1810. parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
  1811. if ((flags & 1) != 0) // Ban TODO: Remove magic number
  1812. {
  1813. LandAccessEntry entry = new LandAccessEntry();
  1814. entry.AgentID = targetAvatar.UUID;
  1815. entry.Flags = AccessList.Ban;
  1816. entry.Expires = 0; // Perm
  1817. land.LandData.ParcelAccessList.Add(entry);
  1818. }
  1819. }
  1820. /// <summary>
  1821. /// Sets the Home Point. The LoginService uses this to know where to put a user when they log-in
  1822. /// </summary>
  1823. /// <param name="remoteClient"></param>
  1824. /// <param name="regionHandle"></param>
  1825. /// <param name="position"></param>
  1826. /// <param name="lookAt"></param>
  1827. /// <param name="flags"></param>
  1828. public virtual void ClientOnSetHome(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
  1829. {
  1830. // Let's find the parcel in question
  1831. ILandObject land = landChannel.GetLandObject(position);
  1832. if (land == null || m_scene.GridUserService == null)
  1833. {
  1834. m_Dialog.SendAlertToUser(remoteClient, "Set Home request failed.");
  1835. return;
  1836. }
  1837. // Gather some data
  1838. ulong gpowers = remoteClient.GetGroupPowers(land.LandData.GroupID);
  1839. SceneObjectGroup telehub = null;
  1840. if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero)
  1841. // Does the telehub exist in the scene?
  1842. telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject);
  1843. // Can the user set home here?
  1844. if (// Required: local user; foreign users cannot set home
  1845. m_scene.UserManagementModule.IsLocalGridUser(remoteClient.AgentId) &&
  1846. (// (a) gods and land managers can set home
  1847. m_scene.Permissions.IsAdministrator(remoteClient.AgentId) ||
  1848. m_scene.Permissions.IsGod(remoteClient.AgentId) ||
  1849. // (b) land owners can set home
  1850. remoteClient.AgentId == land.LandData.OwnerID ||
  1851. // (c) members of the land-associated group in roles that can set home
  1852. ((gpowers & (ulong)GroupPowers.AllowSetHome) == (ulong)GroupPowers.AllowSetHome) ||
  1853. // (d) parcels with telehubs can be the home of anyone
  1854. (telehub != null && land.ContainsPoint((int)telehub.AbsolutePosition.X, (int)telehub.AbsolutePosition.Y))))
  1855. {
  1856. string userId;
  1857. UUID test;
  1858. if (!m_scene.UserManagementModule.GetUserUUI(remoteClient.AgentId, out userId))
  1859. {
  1860. /* Do not set a home position in this grid for a HG visitor */
  1861. m_Dialog.SendAlertToUser(remoteClient, "Set Home request failed. (User Lookup)");
  1862. }
  1863. else if (!UUID.TryParse(userId, out test))
  1864. {
  1865. m_Dialog.SendAlertToUser(remoteClient, "Set Home request failed. (HG visitor)");
  1866. }
  1867. else if (m_scene.GridUserService.SetHome(userId, land.RegionUUID, position, lookAt))
  1868. {
  1869. // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
  1870. m_Dialog.SendAlertToUser(remoteClient, "Home position set.");
  1871. }
  1872. else
  1873. {
  1874. m_Dialog.SendAlertToUser(remoteClient, "Set Home request failed.");
  1875. }
  1876. }
  1877. else
  1878. m_Dialog.SendAlertToUser(remoteClient, "You are not allowed to set your home location in this parcel.");
  1879. }
  1880. protected void RegisterCommands()
  1881. {
  1882. ICommands commands = MainConsole.Instance.Commands;
  1883. commands.AddCommand(
  1884. "Land", false, "land clear",
  1885. "land clear",
  1886. "Clear all the parcels from the region.",
  1887. "Command will ask for confirmation before proceeding.",
  1888. HandleClearCommand);
  1889. commands.AddCommand(
  1890. "Land", false, "land show",
  1891. "land show [<local-land-id>]",
  1892. "Show information about the parcels on the region.",
  1893. "If no local land ID is given, then summary information about all the parcels is shown.\n"
  1894. + "If a local land ID is given then full information about that parcel is shown.",
  1895. HandleShowCommand);
  1896. }
  1897. protected void HandleClearCommand(string module, string[] args)
  1898. {
  1899. if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_scene))
  1900. return;
  1901. string response = MainConsole.Instance.CmdPrompt(
  1902. string.Format(
  1903. "Are you sure that you want to clear all land parcels from {0} (y or n)", m_scene.Name),
  1904. "n");
  1905. if (response.ToLower() == "y")
  1906. {
  1907. Clear(true);
  1908. MainConsole.Instance.OutputFormat("Cleared all parcels from {0}", m_scene.Name);
  1909. }
  1910. else
  1911. {
  1912. MainConsole.Instance.OutputFormat("Aborting clear of all parcels from {0}", m_scene.Name);
  1913. }
  1914. }
  1915. protected void HandleShowCommand(string module, string[] args)
  1916. {
  1917. if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_scene))
  1918. return;
  1919. StringBuilder report = new StringBuilder();
  1920. if (args.Length <= 2)
  1921. {
  1922. AppendParcelsSummaryReport(report);
  1923. }
  1924. else
  1925. {
  1926. int landLocalId;
  1927. if (!ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, args[2], out landLocalId))
  1928. return;
  1929. ILandObject lo;
  1930. lock (m_landList)
  1931. {
  1932. if (!m_landList.TryGetValue(landLocalId, out lo))
  1933. {
  1934. MainConsole.Instance.OutputFormat("No parcel found with local ID {0}", landLocalId);
  1935. return;
  1936. }
  1937. }
  1938. AppendParcelReport(report, lo);
  1939. }
  1940. MainConsole.Instance.Output(report.ToString());
  1941. }
  1942. private void AppendParcelsSummaryReport(StringBuilder report)
  1943. {
  1944. report.AppendFormat("Land information for {0}\n", m_scene.RegionInfo.RegionName);
  1945. report.AppendFormat(
  1946. "{0,-20} {1,-10} {2,-9} {3,-18} {4,-18} {5,-20}\n",
  1947. "Parcel Name",
  1948. "Local ID",
  1949. "Area",
  1950. "AABBMin",
  1951. "AABBMax",
  1952. "Owner");
  1953. lock (m_landList)
  1954. {
  1955. foreach (ILandObject lo in m_landList.Values)
  1956. {
  1957. LandData ld = lo.LandData;
  1958. report.AppendFormat(
  1959. "{0,-20} {1,-10} {2,-9} {3,-18} {4,-18} {5,-20}\n",
  1960. ld.Name, ld.LocalID, ld.Area, ld.AABBMin, ld.AABBMax, m_userManager.GetUserName(ld.OwnerID));
  1961. }
  1962. }
  1963. }
  1964. public void EnforceBans(ILandObject land, ScenePresence avatar)
  1965. {
  1966. if (avatar.AbsolutePosition.Z > LandChannel.BAN_LINE_SAFETY_HIEGHT)
  1967. return;
  1968. if (land.IsEitherBannedOrRestricted(avatar.UUID))
  1969. {
  1970. if (land.ContainsPoint(Convert.ToInt32(avatar.lastKnownAllowedPosition.X), Convert.ToInt32(avatar.lastKnownAllowedPosition.Y)))
  1971. {
  1972. Vector3? pos = m_scene.GetNearestAllowedPosition(avatar);
  1973. if (pos == null)
  1974. m_scene.TeleportClientHome(avatar.UUID, avatar.ControllingClient);
  1975. else
  1976. ForceAvatarToPosition(avatar, (Vector3)pos);
  1977. }
  1978. else
  1979. {
  1980. ForceAvatarToPosition(avatar, avatar.lastKnownAllowedPosition);
  1981. }
  1982. }
  1983. }
  1984. private void AppendParcelReport(StringBuilder report, ILandObject lo)
  1985. {
  1986. LandData ld = lo.LandData;
  1987. ConsoleDisplayList cdl = new ConsoleDisplayList();
  1988. cdl.AddRow("Parcel name", ld.Name);
  1989. cdl.AddRow("Local ID", ld.LocalID);
  1990. cdl.AddRow("Description", ld.Description);
  1991. cdl.AddRow("Snapshot ID", ld.SnapshotID);
  1992. cdl.AddRow("Area", ld.Area);
  1993. cdl.AddRow("AABB Min", ld.AABBMin);
  1994. cdl.AddRow("AABB Max", ld.AABBMax);
  1995. string ownerName;
  1996. if (ld.IsGroupOwned)
  1997. {
  1998. GroupRecord rec = m_groupManager.GetGroupRecord(ld.GroupID);
  1999. ownerName = (rec != null) ? rec.GroupName : "Unknown Group";
  2000. }
  2001. else
  2002. {
  2003. ownerName = m_userManager.GetUserName(ld.OwnerID);
  2004. }
  2005. cdl.AddRow("Owner", ownerName);
  2006. cdl.AddRow("Is group owned?", ld.IsGroupOwned);
  2007. cdl.AddRow("GroupID", ld.GroupID);
  2008. cdl.AddRow("Status", ld.Status);
  2009. cdl.AddRow("Flags", (ParcelFlags)ld.Flags);
  2010. cdl.AddRow("Landing Type", (LandingType)ld.LandingType);
  2011. cdl.AddRow("User Location", ld.UserLocation);
  2012. cdl.AddRow("User look at", ld.UserLookAt);
  2013. cdl.AddRow("Other clean time", ld.OtherCleanTime);
  2014. cdl.AddRow("Max Prims", lo.GetParcelMaxPrimCount());
  2015. IPrimCounts pc = lo.PrimCounts;
  2016. cdl.AddRow("Owner Prims", pc.Owner);
  2017. cdl.AddRow("Group Prims", pc.Group);
  2018. cdl.AddRow("Other Prims", pc.Others);
  2019. cdl.AddRow("Selected Prims", pc.Selected);
  2020. cdl.AddRow("Total Prims", pc.Total);
  2021. cdl.AddRow("Music URL", ld.MusicURL);
  2022. cdl.AddRow("Obscure Music", ld.ObscureMusic);
  2023. cdl.AddRow("Media ID", ld.MediaID);
  2024. cdl.AddRow("Media Autoscale", Convert.ToBoolean(ld.MediaAutoScale));
  2025. cdl.AddRow("Media URL", ld.MediaURL);
  2026. cdl.AddRow("Media Type", ld.MediaType);
  2027. cdl.AddRow("Media Description", ld.MediaDescription);
  2028. cdl.AddRow("Media Width", ld.MediaWidth);
  2029. cdl.AddRow("Media Height", ld.MediaHeight);
  2030. cdl.AddRow("Media Loop", ld.MediaLoop);
  2031. cdl.AddRow("Obscure Media", ld.ObscureMedia);
  2032. cdl.AddRow("Parcel Category", ld.Category);
  2033. cdl.AddRow("Claim Date", ld.ClaimDate);
  2034. cdl.AddRow("Claim Price", ld.ClaimPrice);
  2035. cdl.AddRow("Pass Hours", ld.PassHours);
  2036. cdl.AddRow("Pass Price", ld.PassPrice);
  2037. cdl.AddRow("Auction ID", ld.AuctionID);
  2038. cdl.AddRow("Authorized Buyer ID", ld.AuthBuyerID);
  2039. cdl.AddRow("Sale Price", ld.SalePrice);
  2040. cdl.AddToStringBuilder(report);
  2041. }
  2042. }
  2043. }