LandManagementModule.cs 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751
  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.CoreModules.Framework.InterfaceCommander;
  45. using OpenSim.Region.Framework.Interfaces;
  46. using OpenSim.Region.Framework.Scenes;
  47. using OpenSim.Region.Physics.Manager;
  48. using OpenSim.Services.Interfaces;
  49. using Caps = OpenSim.Framework.Capabilities.Caps;
  50. using GridRegion = OpenSim.Services.Interfaces.GridRegion;
  51. namespace OpenSim.Region.CoreModules.World.Land
  52. {
  53. // used for caching
  54. internal class ExtendedLandData
  55. {
  56. public LandData LandData;
  57. public ulong RegionHandle;
  58. public uint X, Y;
  59. public byte RegionAccess;
  60. }
  61. [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LandManagementModule")]
  62. public class LandManagementModule : INonSharedRegionModule
  63. {
  64. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  65. private static readonly string remoteParcelRequestPath = "0009/";
  66. private LandChannel landChannel;
  67. private Scene m_scene;
  68. protected Commander m_commander = new Commander("land");
  69. protected IUserManagement m_userManager;
  70. protected IPrimCountModule m_primCountModule;
  71. // Minimum for parcels to work is 64m even if we don't actually use them.
  72. #pragma warning disable 0429
  73. private const int landArrayMax = ((int)((int)Constants.RegionSize / 4) >= 64) ? (int)((int)Constants.RegionSize / 4) : 64;
  74. #pragma warning restore 0429
  75. /// <value>
  76. /// Local land ids at specified region co-ordinates (region size / 4)
  77. /// </value>
  78. private readonly int[,] m_landIDList = new int[landArrayMax, landArrayMax];
  79. /// <value>
  80. /// Land objects keyed by local id
  81. /// </value>
  82. private readonly Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>();
  83. private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1;
  84. private bool m_allowedForcefulBans = true;
  85. // caches ExtendedLandData
  86. private Cache parcelInfoCache;
  87. /// <summary>
  88. /// Record positions that avatar's are currently being forced to move to due to parcel entry restrictions.
  89. /// </summary>
  90. private Dictionary<UUID, Vector3> forcedPosition = new Dictionary<UUID, Vector3>();
  91. #region INonSharedRegionModule Members
  92. public Type ReplaceableInterface
  93. {
  94. get { return null; }
  95. }
  96. public void Initialise(IConfigSource source)
  97. {
  98. }
  99. public void AddRegion(Scene scene)
  100. {
  101. m_scene = scene;
  102. m_landIDList.Initialize();
  103. landChannel = new LandChannel(scene, this);
  104. parcelInfoCache = new Cache();
  105. parcelInfoCache.Size = 30; // the number of different parcel requests in this region to cache
  106. parcelInfoCache.DefaultTTL = new TimeSpan(0, 5, 0);
  107. m_scene.EventManager.OnParcelPrimCountAdd += EventManagerOnParcelPrimCountAdd;
  108. m_scene.EventManager.OnParcelPrimCountUpdate += EventManagerOnParcelPrimCountUpdate;
  109. m_scene.EventManager.OnObjectBeingRemovedFromScene += EventManagerOnObjectBeingRemovedFromScene;
  110. m_scene.EventManager.OnRequestParcelPrimCountUpdate += EventManagerOnRequestParcelPrimCountUpdate;
  111. m_scene.EventManager.OnAvatarEnteringNewParcel += EventManagerOnAvatarEnteringNewParcel;
  112. m_scene.EventManager.OnClientMovement += EventManagerOnClientMovement;
  113. m_scene.EventManager.OnValidateLandBuy += EventManagerOnValidateLandBuy;
  114. m_scene.EventManager.OnLandBuy += EventManagerOnLandBuy;
  115. m_scene.EventManager.OnNewClient += EventManagerOnNewClient;
  116. m_scene.EventManager.OnSignificantClientMovement += EventManagerOnSignificantClientMovement;
  117. m_scene.EventManager.OnNoticeNoLandDataFromStorage += EventManagerOnNoLandDataFromStorage;
  118. m_scene.EventManager.OnIncomingLandDataFromStorage += EventManagerOnIncomingLandDataFromStorage;
  119. m_scene.EventManager.OnSetAllowForcefulBan += EventManagerOnSetAllowedForcefulBan;
  120. m_scene.EventManager.OnRegisterCaps += EventManagerOnRegisterCaps;
  121. m_scene.EventManager.OnPluginConsole += EventManagerOnPluginConsole;
  122. lock (m_scene)
  123. {
  124. m_scene.LandChannel = (ILandChannel)landChannel;
  125. }
  126. InstallInterfaces();
  127. }
  128. public void RegionLoaded(Scene scene)
  129. {
  130. m_userManager = m_scene.RequestModuleInterface<IUserManagement>();
  131. m_primCountModule = m_scene.RequestModuleInterface<IPrimCountModule>();
  132. }
  133. public void RemoveRegion(Scene scene)
  134. {
  135. // TODO: Also release other event manager listeners here
  136. m_scene.EventManager.OnPluginConsole -= EventManagerOnPluginConsole;
  137. m_scene.UnregisterModuleCommander(m_commander.Name);
  138. }
  139. // private bool OnVerifyUserConnection(ScenePresence scenePresence, out string reason)
  140. // {
  141. // ILandObject nearestParcel = m_scene.GetNearestAllowedParcel(scenePresence.UUID, scenePresence.AbsolutePosition.X, scenePresence.AbsolutePosition.Y);
  142. // reason = "You are not allowed to enter this sim.";
  143. // return nearestParcel != null;
  144. // }
  145. /// <summary>
  146. /// Processes commandline input. Do not call directly.
  147. /// </summary>
  148. /// <param name="args">Commandline arguments</param>
  149. protected void EventManagerOnPluginConsole(string[] args)
  150. {
  151. if (args[0] == "land")
  152. {
  153. if (args.Length == 1)
  154. {
  155. m_commander.ProcessConsoleCommand("help", new string[0]);
  156. return;
  157. }
  158. string[] tmpArgs = new string[args.Length - 2];
  159. int i;
  160. for (i = 2; i < args.Length; i++)
  161. tmpArgs[i - 2] = args[i];
  162. m_commander.ProcessConsoleCommand(args[1], tmpArgs);
  163. }
  164. }
  165. void EventManagerOnNewClient(IClientAPI client)
  166. {
  167. //Register some client events
  168. client.OnParcelPropertiesRequest += ClientOnParcelPropertiesRequest;
  169. client.OnParcelDivideRequest += ClientOnParcelDivideRequest;
  170. client.OnParcelJoinRequest += ClientOnParcelJoinRequest;
  171. client.OnParcelPropertiesUpdateRequest += ClientOnParcelPropertiesUpdateRequest;
  172. client.OnParcelSelectObjects += ClientOnParcelSelectObjects;
  173. client.OnParcelObjectOwnerRequest += ClientOnParcelObjectOwnerRequest;
  174. client.OnParcelAccessListRequest += ClientOnParcelAccessListRequest;
  175. client.OnParcelAccessListUpdateRequest += ClientOnParcelAccessListUpdateRequest;
  176. client.OnParcelAbandonRequest += ClientOnParcelAbandonRequest;
  177. client.OnParcelGodForceOwner += ClientOnParcelGodForceOwner;
  178. client.OnParcelReclaim += ClientOnParcelReclaim;
  179. client.OnParcelInfoRequest += ClientOnParcelInfoRequest;
  180. client.OnParcelDeedToGroup += ClientOnParcelDeedToGroup;
  181. client.OnPreAgentUpdate += ClientOnPreAgentUpdate;
  182. client.OnParcelDwellRequest += ClientOnParcelDwellRequest;
  183. EntityBase presenceEntity;
  184. if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence)
  185. {
  186. SendLandUpdate((ScenePresence)presenceEntity, true);
  187. SendParcelOverlay(client);
  188. }
  189. }
  190. void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
  191. {
  192. //If we are forcing a position for them to go
  193. if (forcedPosition.ContainsKey(remoteClient.AgentId))
  194. {
  195. ScenePresence clientAvatar = m_scene.GetScenePresence(remoteClient.AgentId);
  196. //Putting the user into flying, both keeps the avatar in fligth when it bumps into something and stopped from going another direction AND
  197. //When the avatar walks into a ban line on the ground, it prevents getting stuck
  198. agentData.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
  199. //Make sure we stop if they get about to the right place to prevent yoyo and prevents getting stuck on banlines
  200. if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]) < .2)
  201. {
  202. // m_log.DebugFormat(
  203. // "[LAND MANAGEMENT MODULE]: Stopping force position of {0} because {1} is close enough to {2}",
  204. // clientAvatar.Name, clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]);
  205. forcedPosition.Remove(remoteClient.AgentId);
  206. }
  207. //if we are far away, teleport
  208. else if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]) > 3)
  209. {
  210. Vector3 forcePosition = forcedPosition[remoteClient.AgentId];
  211. // m_log.DebugFormat(
  212. // "[LAND MANAGEMENT MODULE]: Teleporting out {0} because {1} is too far from avatar position {2}",
  213. // clientAvatar.Name, clientAvatar.AbsolutePosition, forcePosition);
  214. m_scene.RequestTeleportLocation(remoteClient, m_scene.RegionInfo.RegionHandle,
  215. forcePosition, clientAvatar.Lookat, (uint)Constants.TeleportFlags.ForceRedirect);
  216. forcedPosition.Remove(remoteClient.AgentId);
  217. }
  218. else
  219. {
  220. // m_log.DebugFormat(
  221. // "[LAND MANAGEMENT MODULE]: Forcing {0} from {1} to {2}",
  222. // clientAvatar.Name, clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]);
  223. //Forces them toward the forced position we want if they aren't there yet
  224. agentData.UseClientAgentPosition = true;
  225. agentData.ClientAgentPosition = forcedPosition[remoteClient.AgentId];
  226. }
  227. }
  228. }
  229. public void Close()
  230. {
  231. }
  232. public string Name
  233. {
  234. get { return "LandManagementModule"; }
  235. }
  236. #endregion
  237. #region Parcel Add/Remove/Get/Create
  238. public void EventManagerOnSetAllowedForcefulBan(bool forceful)
  239. {
  240. AllowedForcefulBans = forceful;
  241. }
  242. public void UpdateLandObject(int local_id, LandData data)
  243. {
  244. LandData newData = data.Copy();
  245. newData.LocalID = local_id;
  246. lock (m_landList)
  247. {
  248. if (m_landList.ContainsKey(local_id))
  249. {
  250. m_landList[local_id].LandData = newData;
  251. m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, m_landList[local_id]);
  252. }
  253. }
  254. }
  255. public bool AllowedForcefulBans
  256. {
  257. get { return m_allowedForcefulBans; }
  258. set { m_allowedForcefulBans = value; }
  259. }
  260. /// <summary>
  261. /// Resets the sim to the default land object (full sim piece of land owned by the default user)
  262. /// </summary>
  263. public void ResetSimLandObjects()
  264. {
  265. //Remove all the land objects in the sim and add a blank, full sim land object set to public
  266. lock (m_landList)
  267. {
  268. m_landList.Clear();
  269. m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1;
  270. m_landIDList.Initialize();
  271. }
  272. }
  273. /// <summary>
  274. /// Create a default parcel that spans the entire region and is owned by the estate owner.
  275. /// </summary>
  276. /// <returns>The parcel created.</returns>
  277. protected ILandObject CreateDefaultParcel()
  278. {
  279. m_log.DebugFormat(
  280. "[LAND MANAGEMENT MODULE]: Creating default parcel for region {0}", m_scene.RegionInfo.RegionName);
  281. ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene);
  282. fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize));
  283. fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
  284. fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch();
  285. return AddLandObject(fullSimParcel);
  286. }
  287. public List<ILandObject> AllParcels()
  288. {
  289. lock (m_landList)
  290. {
  291. return new List<ILandObject>(m_landList.Values);
  292. }
  293. }
  294. public List<ILandObject> ParcelsNearPoint(Vector3 position)
  295. {
  296. List<ILandObject> parcelsNear = new List<ILandObject>();
  297. for (int x = -4; x <= 4; x += 4)
  298. {
  299. for (int y = -4; y <= 4; y += 4)
  300. {
  301. ILandObject check = GetLandObject(position.X + x, position.Y + y);
  302. if (check != null)
  303. {
  304. if (!parcelsNear.Contains(check))
  305. {
  306. parcelsNear.Add(check);
  307. }
  308. }
  309. }
  310. }
  311. return parcelsNear;
  312. }
  313. public void SendYouAreBannedNotice(ScenePresence avatar)
  314. {
  315. if (AllowedForcefulBans)
  316. {
  317. avatar.ControllingClient.SendAlertMessage(
  318. "You are not allowed on this parcel because you are banned. Please go away.");
  319. }
  320. else
  321. {
  322. avatar.ControllingClient.SendAlertMessage(
  323. "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!");
  324. }
  325. }
  326. private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position)
  327. {
  328. if (m_scene.Permissions.IsGod(avatar.UUID)) return;
  329. if (position.HasValue)
  330. {
  331. forcedPosition[avatar.ControllingClient.AgentId] = (Vector3)position;
  332. }
  333. }
  334. public void SendYouAreRestrictedNotice(ScenePresence avatar)
  335. {
  336. avatar.ControllingClient.SendAlertMessage(
  337. "You are not allowed on this parcel because the land owner has restricted access.");
  338. }
  339. public void EventManagerOnAvatarEnteringNewParcel(ScenePresence avatar, int localLandID, UUID regionID)
  340. {
  341. if (m_scene.RegionInfo.RegionID == regionID)
  342. {
  343. ILandObject parcelAvatarIsEntering;
  344. lock (m_landList)
  345. {
  346. parcelAvatarIsEntering = m_landList[localLandID];
  347. }
  348. if (parcelAvatarIsEntering != null)
  349. {
  350. if (avatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT)
  351. {
  352. if (parcelAvatarIsEntering.IsBannedFromLand(avatar.UUID))
  353. {
  354. SendYouAreBannedNotice(avatar);
  355. ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar));
  356. }
  357. else if (parcelAvatarIsEntering.IsRestrictedFromLand(avatar.UUID))
  358. {
  359. SendYouAreRestrictedNotice(avatar);
  360. ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar));
  361. }
  362. else
  363. {
  364. avatar.sentMessageAboutRestrictedParcelFlyingDown = true;
  365. }
  366. }
  367. else
  368. {
  369. avatar.sentMessageAboutRestrictedParcelFlyingDown = true;
  370. }
  371. }
  372. }
  373. }
  374. public void SendOutNearestBanLine(IClientAPI client)
  375. {
  376. ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
  377. if (sp == null || sp.IsChildAgent)
  378. return;
  379. List<ILandObject> checkLandParcels = ParcelsNearPoint(sp.AbsolutePosition);
  380. foreach (ILandObject checkBan in checkLandParcels)
  381. {
  382. if (checkBan.IsBannedFromLand(client.AgentId))
  383. {
  384. checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionBanned, false, (int)ParcelResult.Single, client);
  385. return; //Only send one
  386. }
  387. if (checkBan.IsRestrictedFromLand(client.AgentId))
  388. {
  389. checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionNotOnAccessList, false, (int)ParcelResult.Single, client);
  390. return; //Only send one
  391. }
  392. }
  393. return;
  394. }
  395. public void SendLandUpdate(ScenePresence avatar, bool force)
  396. {
  397. ILandObject over = GetLandObject((int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.X))),
  398. (int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.Y))));
  399. if (over != null)
  400. {
  401. if (force)
  402. {
  403. if (!avatar.IsChildAgent)
  404. {
  405. over.SendLandUpdateToClient(avatar.ControllingClient);
  406. m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID,
  407. m_scene.RegionInfo.RegionID);
  408. }
  409. }
  410. if (avatar.currentParcelUUID != over.LandData.GlobalID)
  411. {
  412. if (!avatar.IsChildAgent)
  413. {
  414. over.SendLandUpdateToClient(avatar.ControllingClient);
  415. avatar.currentParcelUUID = over.LandData.GlobalID;
  416. m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID,
  417. m_scene.RegionInfo.RegionID);
  418. }
  419. }
  420. }
  421. }
  422. public void SendLandUpdate(ScenePresence avatar)
  423. {
  424. SendLandUpdate(avatar, false);
  425. }
  426. public void EventManagerOnSignificantClientMovement(ScenePresence clientAvatar)
  427. {
  428. SendLandUpdate(clientAvatar);
  429. SendOutNearestBanLine(clientAvatar.ControllingClient);
  430. ILandObject parcel = GetLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y);
  431. if (parcel != null)
  432. {
  433. if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT &&
  434. clientAvatar.sentMessageAboutRestrictedParcelFlyingDown)
  435. {
  436. EventManagerOnAvatarEnteringNewParcel(clientAvatar, parcel.LandData.LocalID,
  437. m_scene.RegionInfo.RegionID);
  438. //They are going under the safety line!
  439. if (!parcel.IsBannedFromLand(clientAvatar.UUID))
  440. {
  441. clientAvatar.sentMessageAboutRestrictedParcelFlyingDown = false;
  442. }
  443. }
  444. else if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT &&
  445. parcel.IsBannedFromLand(clientAvatar.UUID))
  446. {
  447. //once we've sent the message once, keep going toward the target until we are done
  448. if (forcedPosition.ContainsKey(clientAvatar.ControllingClient.AgentId))
  449. {
  450. SendYouAreBannedNotice(clientAvatar);
  451. ForceAvatarToPosition(clientAvatar, m_scene.GetNearestAllowedPosition(clientAvatar));
  452. }
  453. }
  454. else if (parcel.IsRestrictedFromLand(clientAvatar.UUID))
  455. {
  456. //once we've sent the message once, keep going toward the target until we are done
  457. if (forcedPosition.ContainsKey(clientAvatar.ControllingClient.AgentId))
  458. {
  459. SendYouAreRestrictedNotice(clientAvatar);
  460. ForceAvatarToPosition(clientAvatar, m_scene.GetNearestAllowedPosition(clientAvatar));
  461. }
  462. }
  463. else
  464. {
  465. //when we are finally in a safe place, lets release the forced position lock
  466. forcedPosition.Remove(clientAvatar.ControllingClient.AgentId);
  467. }
  468. }
  469. }
  470. /// <summary>
  471. /// Like handleEventManagerOnSignificantClientMovement, but called with an AgentUpdate regardless of distance.
  472. /// </summary>
  473. /// <param name="avatar"></param>
  474. public void EventManagerOnClientMovement(ScenePresence avatar)
  475. //
  476. {
  477. ILandObject over = GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
  478. if (over != null)
  479. {
  480. if (!over.IsRestrictedFromLand(avatar.UUID) && (!over.IsBannedFromLand(avatar.UUID) || avatar.AbsolutePosition.Z >= LandChannel.BAN_LINE_SAFETY_HIEGHT))
  481. {
  482. avatar.lastKnownAllowedPosition =
  483. new Vector3(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z);
  484. }
  485. }
  486. }
  487. public void ClientOnParcelAccessListRequest(UUID agentID, UUID sessionID, uint flags, int sequenceID,
  488. int landLocalID, IClientAPI remote_client)
  489. {
  490. ILandObject land;
  491. lock (m_landList)
  492. {
  493. m_landList.TryGetValue(landLocalID, out land);
  494. }
  495. if (land != null)
  496. {
  497. land.SendAccessList(agentID, sessionID, flags, sequenceID, remote_client);
  498. }
  499. }
  500. public void ClientOnParcelAccessListUpdateRequest(UUID agentID,
  501. uint flags, int landLocalID, UUID transactionID, int sequenceID,
  502. int sections, List<LandAccessEntry> entries,
  503. IClientAPI remote_client)
  504. {
  505. // Flags is the list to update, it can mean either the ban or
  506. // the access list (WTH is a pass list? Mentioned in ParcelFlags)
  507. //
  508. // There may be multiple packets, because these can get LONG.
  509. // Use transactionID to determine a new chain of packets since
  510. // packets may have come in out of sequence and that would be
  511. // a big mess if using the sequenceID
  512. ILandObject land;
  513. lock (m_landList)
  514. {
  515. m_landList.TryGetValue(landLocalID, out land);
  516. }
  517. if (land != null)
  518. {
  519. GroupPowers requiredPowers = GroupPowers.LandManageAllowed;
  520. if (flags == (uint)AccessList.Ban)
  521. requiredPowers = GroupPowers.LandManageBanned;
  522. if (m_scene.Permissions.CanEditParcelProperties(agentID,
  523. land, requiredPowers))
  524. {
  525. land.UpdateAccessList(flags, transactionID, sequenceID,
  526. sections, entries, remote_client);
  527. }
  528. }
  529. else
  530. {
  531. m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Invalid local land ID {0}", landLocalID);
  532. }
  533. }
  534. /// <summary>
  535. /// Adds a land object to the stored list and adds them to the landIDList to what they own
  536. /// </summary>
  537. /// <param name="new_land">The land object being added</param>
  538. public ILandObject AddLandObject(ILandObject land)
  539. {
  540. ILandObject new_land = land.Copy();
  541. // Only now can we add the prim counts to the land object - we rely on the global ID which is generated
  542. // as a random UUID inside LandData initialization
  543. if (m_primCountModule != null)
  544. new_land.PrimCounts = m_primCountModule.GetPrimCounts(new_land.LandData.GlobalID);
  545. lock (m_landList)
  546. {
  547. int newLandLocalID = ++m_lastLandLocalID;
  548. new_land.LandData.LocalID = newLandLocalID;
  549. bool[,] landBitmap = new_land.GetLandBitmap();
  550. for (int x = 0; x < landArrayMax; x++)
  551. {
  552. for (int y = 0; y < landArrayMax; y++)
  553. {
  554. if (landBitmap[x, y])
  555. {
  556. // m_log.DebugFormat(
  557. // "[LAND MANAGEMENT MODULE]: Registering parcel {0} for land co-ord ({1}, {2}) on {3}",
  558. // new_land.LandData.Name, x, y, m_scene.RegionInfo.RegionName);
  559. m_landIDList[x, y] = newLandLocalID;
  560. }
  561. }
  562. }
  563. m_landList.Add(newLandLocalID, new_land);
  564. }
  565. new_land.ForceUpdateLandInfo();
  566. m_scene.EventManager.TriggerLandObjectAdded(new_land);
  567. return new_land;
  568. }
  569. /// <summary>
  570. /// Removes a land object from the list. Will not remove if local_id is still owning an area in landIDList
  571. /// </summary>
  572. /// <param name="local_id">Land.localID of the peice of land to remove.</param>
  573. public void removeLandObject(int local_id)
  574. {
  575. lock (m_landList)
  576. {
  577. for (int x = 0; x < 64; x++)
  578. {
  579. for (int y = 0; y < 64; y++)
  580. {
  581. if (m_landIDList[x, y] == local_id)
  582. {
  583. m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Not removing land object {0}; still being used at {1}, {2}",
  584. local_id, x, y);
  585. return;
  586. //throw new Exception("Could not remove land object. Still being used at " + x + ", " + y);
  587. }
  588. }
  589. }
  590. m_scene.EventManager.TriggerLandObjectRemoved(m_landList[local_id].LandData.GlobalID);
  591. m_landList.Remove(local_id);
  592. }
  593. }
  594. /// <summary>
  595. /// Clear the scene of all parcels
  596. /// </summary>
  597. public void Clear(bool setupDefaultParcel)
  598. {
  599. lock (m_landList)
  600. {
  601. foreach (ILandObject lo in m_landList.Values)
  602. {
  603. //m_scene.SimulationDataService.RemoveLandObject(lo.LandData.GlobalID);
  604. m_scene.EventManager.TriggerLandObjectRemoved(lo.LandData.GlobalID);
  605. }
  606. m_landList.Clear();
  607. ResetSimLandObjects();
  608. if (setupDefaultParcel)
  609. CreateDefaultParcel();
  610. }
  611. }
  612. private void performFinalLandJoin(ILandObject master, ILandObject slave)
  613. {
  614. bool[,] landBitmapSlave = slave.GetLandBitmap();
  615. lock (m_landList)
  616. {
  617. for (int x = 0; x < 64; x++)
  618. {
  619. for (int y = 0; y < 64; y++)
  620. {
  621. if (landBitmapSlave[x, y])
  622. {
  623. m_landIDList[x, y] = master.LandData.LocalID;
  624. }
  625. }
  626. }
  627. }
  628. removeLandObject(slave.LandData.LocalID);
  629. UpdateLandObject(master.LandData.LocalID, master.LandData);
  630. }
  631. public ILandObject GetLandObject(int parcelLocalID)
  632. {
  633. lock (m_landList)
  634. {
  635. if (m_landList.ContainsKey(parcelLocalID))
  636. {
  637. return m_landList[parcelLocalID];
  638. }
  639. }
  640. return null;
  641. }
  642. /// <summary>
  643. /// Get the land object at the specified point
  644. /// </summary>
  645. /// <param name="x_float">Value between 0 - 256 on the x axis of the point</param>
  646. /// <param name="y_float">Value between 0 - 256 on the y axis of the point</param>
  647. /// <returns>Land object at the point supplied</returns>
  648. public ILandObject GetLandObject(float x_float, float y_float)
  649. {
  650. int x;
  651. int y;
  652. if (x_float >= Constants.RegionSize || x_float < 0 || y_float >= Constants.RegionSize || y_float < 0)
  653. return null;
  654. try
  655. {
  656. x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float) / 4.0));
  657. y = Convert.ToInt32(Math.Floor(Convert.ToDouble(y_float) / 4.0));
  658. }
  659. catch (OverflowException)
  660. {
  661. return null;
  662. }
  663. if (x >= 64 || y >= 64 || x < 0 || y < 0)
  664. {
  665. return null;
  666. }
  667. lock (m_landList)
  668. {
  669. // Corner case. If an autoreturn happens during sim startup
  670. // we will come here with the list uninitialized
  671. //
  672. // int landId = m_landIDList[x, y];
  673. // if (landId == 0)
  674. // m_log.DebugFormat(
  675. // "[LAND MANAGEMENT MODULE]: No land object found at ({0}, {1}) on {2}",
  676. // x, y, m_scene.RegionInfo.RegionName);
  677. if (m_landList.ContainsKey(m_landIDList[x, y]))
  678. return m_landList[m_landIDList[x, y]];
  679. return null;
  680. }
  681. }
  682. public ILandObject GetLandObject(int x, int y)
  683. {
  684. if (x >= Convert.ToInt32(Constants.RegionSize) || y >= Convert.ToInt32(Constants.RegionSize) || x < 0 || y < 0)
  685. {
  686. // These exceptions here will cause a lot of complaints from the users specifically because
  687. // they happen every time at border crossings
  688. throw new Exception("Error: Parcel not found at point " + x + ", " + y);
  689. }
  690. lock (m_landIDList)
  691. {
  692. try
  693. {
  694. return m_landList[m_landIDList[x / 4, y / 4]];
  695. }
  696. catch (IndexOutOfRangeException)
  697. {
  698. // m_log.WarnFormat(
  699. // "[LAND MANAGEMENT MODULE]: Tried to retrieve land object from out of bounds co-ordinate ({0},{1}) in {2}",
  700. // x, y, m_scene.RegionInfo.RegionName);
  701. return null;
  702. }
  703. }
  704. }
  705. private void ClientOnParcelDwellRequest(int localID, IClientAPI client)
  706. {
  707. ILandObject parcel = null;
  708. lock (m_landList)
  709. {
  710. if (!m_landList.TryGetValue(localID, out parcel))
  711. return;
  712. }
  713. client.SendParcelDwellReply(localID, parcel.LandData.GlobalID, parcel.LandData.Dwell);
  714. }
  715. #endregion
  716. #region Parcel Modification
  717. public void ResetOverMeRecords()
  718. {
  719. lock (m_landList)
  720. {
  721. foreach (LandObject p in m_landList.Values)
  722. {
  723. p.ResetOverMeRecord();
  724. }
  725. }
  726. }
  727. public void EventManagerOnParcelPrimCountAdd(SceneObjectGroup obj)
  728. {
  729. Vector3 position = obj.AbsolutePosition;
  730. ILandObject landUnderPrim = GetLandObject(position.X, position.Y);
  731. if (landUnderPrim != null)
  732. {
  733. ((LandObject)landUnderPrim).AddPrimOverMe(obj);
  734. }
  735. }
  736. public void EventManagerOnObjectBeingRemovedFromScene(SceneObjectGroup obj)
  737. {
  738. lock (m_landList)
  739. {
  740. foreach (LandObject p in m_landList.Values)
  741. {
  742. p.RemovePrimFromOverMe(obj);
  743. }
  744. }
  745. }
  746. public void FinalizeLandPrimCountUpdate()
  747. {
  748. //Get Simwide prim count for owner
  749. Dictionary<UUID, List<LandObject>> landOwnersAndParcels = new Dictionary<UUID, List<LandObject>>();
  750. lock (m_landList)
  751. {
  752. foreach (LandObject p in m_landList.Values)
  753. {
  754. if (!landOwnersAndParcels.ContainsKey(p.LandData.OwnerID))
  755. {
  756. List<LandObject> tempList = new List<LandObject>();
  757. tempList.Add(p);
  758. landOwnersAndParcels.Add(p.LandData.OwnerID, tempList);
  759. }
  760. else
  761. {
  762. landOwnersAndParcels[p.LandData.OwnerID].Add(p);
  763. }
  764. }
  765. }
  766. foreach (UUID owner in landOwnersAndParcels.Keys)
  767. {
  768. int simArea = 0;
  769. int simPrims = 0;
  770. foreach (LandObject p in landOwnersAndParcels[owner])
  771. {
  772. simArea += p.LandData.Area;
  773. simPrims += p.PrimCounts.Total;
  774. }
  775. foreach (LandObject p in landOwnersAndParcels[owner])
  776. {
  777. p.LandData.SimwideArea = simArea;
  778. p.LandData.SimwidePrims = simPrims;
  779. }
  780. }
  781. }
  782. public void EventManagerOnParcelPrimCountUpdate()
  783. {
  784. // m_log.DebugFormat(
  785. // "[LAND MANAGEMENT MODULE]: Triggered EventManagerOnParcelPrimCountUpdate() for {0}",
  786. // m_scene.RegionInfo.RegionName);
  787. ResetOverMeRecords();
  788. EntityBase[] entities = m_scene.Entities.GetEntities();
  789. foreach (EntityBase obj in entities)
  790. {
  791. if (obj != null)
  792. {
  793. if ((obj is SceneObjectGroup) && !obj.IsDeleted && !((SceneObjectGroup) obj).IsAttachment)
  794. {
  795. m_scene.EventManager.TriggerParcelPrimCountAdd((SceneObjectGroup) obj);
  796. }
  797. }
  798. }
  799. FinalizeLandPrimCountUpdate();
  800. }
  801. public void EventManagerOnRequestParcelPrimCountUpdate()
  802. {
  803. ResetOverMeRecords();
  804. m_scene.EventManager.TriggerParcelPrimCountUpdate();
  805. FinalizeLandPrimCountUpdate();
  806. }
  807. /// <summary>
  808. /// Subdivides a piece of land
  809. /// </summary>
  810. /// <param name="start_x">West Point</param>
  811. /// <param name="start_y">South Point</param>
  812. /// <param name="end_x">East Point</param>
  813. /// <param name="end_y">North Point</param>
  814. /// <param name="attempting_user_id">UUID of user who is trying to subdivide</param>
  815. /// <returns>Returns true if successful</returns>
  816. private void subdivide(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id)
  817. {
  818. //First, lets loop through the points and make sure they are all in the same peice of land
  819. //Get the land object at start
  820. ILandObject startLandObject = GetLandObject(start_x, start_y);
  821. if (startLandObject == null) return;
  822. //Loop through the points
  823. try
  824. {
  825. int totalX = end_x - start_x;
  826. int totalY = end_y - start_y;
  827. for (int y = 0; y < totalY; y++)
  828. {
  829. for (int x = 0; x < totalX; x++)
  830. {
  831. ILandObject tempLandObject = GetLandObject(start_x + x, start_y + y);
  832. if (tempLandObject == null) return;
  833. if (tempLandObject != startLandObject) return;
  834. }
  835. }
  836. }
  837. catch (Exception)
  838. {
  839. return;
  840. }
  841. //If we are still here, then they are subdividing within one piece of land
  842. //Check owner
  843. if (!m_scene.Permissions.CanEditParcelProperties(attempting_user_id, startLandObject, GroupPowers.LandDivideJoin))
  844. {
  845. return;
  846. }
  847. //Lets create a new land object with bitmap activated at that point (keeping the old land objects info)
  848. ILandObject newLand = startLandObject.Copy();
  849. newLand.LandData.Name = newLand.LandData.Name;
  850. newLand.LandData.GlobalID = UUID.Random();
  851. newLand.LandData.Dwell = 0;
  852. newLand.SetLandBitmap(newLand.GetSquareLandBitmap(start_x, start_y, end_x, end_y));
  853. //Now, lets set the subdivision area of the original to false
  854. int startLandObjectIndex = startLandObject.LandData.LocalID;
  855. lock (m_landList)
  856. {
  857. m_landList[startLandObjectIndex].SetLandBitmap(
  858. newLand.ModifyLandBitmapSquare(startLandObject.GetLandBitmap(), start_x, start_y, end_x, end_y, false));
  859. m_landList[startLandObjectIndex].ForceUpdateLandInfo();
  860. }
  861. //Now add the new land object
  862. ILandObject result = AddLandObject(newLand);
  863. UpdateLandObject(startLandObject.LandData.LocalID, startLandObject.LandData);
  864. result.SendLandUpdateToAvatarsOverMe();
  865. }
  866. /// <summary>
  867. /// Join 2 land objects together
  868. /// </summary>
  869. /// <param name="start_x">x value in first piece of land</param>
  870. /// <param name="start_y">y value in first piece of land</param>
  871. /// <param name="end_x">x value in second peice of land</param>
  872. /// <param name="end_y">y value in second peice of land</param>
  873. /// <param name="attempting_user_id">UUID of the avatar trying to join the land objects</param>
  874. /// <returns>Returns true if successful</returns>
  875. private void join(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id)
  876. {
  877. end_x -= 4;
  878. end_y -= 4;
  879. List<ILandObject> selectedLandObjects = new List<ILandObject>();
  880. int stepYSelected;
  881. for (stepYSelected = start_y; stepYSelected <= end_y; stepYSelected += 4)
  882. {
  883. int stepXSelected;
  884. for (stepXSelected = start_x; stepXSelected <= end_x; stepXSelected += 4)
  885. {
  886. ILandObject p = GetLandObject(stepXSelected, stepYSelected);
  887. if (p != null)
  888. {
  889. if (!selectedLandObjects.Contains(p))
  890. {
  891. selectedLandObjects.Add(p);
  892. }
  893. }
  894. }
  895. }
  896. ILandObject masterLandObject = selectedLandObjects[0];
  897. selectedLandObjects.RemoveAt(0);
  898. if (selectedLandObjects.Count < 1)
  899. {
  900. return;
  901. }
  902. if (!m_scene.Permissions.CanEditParcelProperties(attempting_user_id, masterLandObject, GroupPowers.LandDivideJoin))
  903. {
  904. return;
  905. }
  906. foreach (ILandObject p in selectedLandObjects)
  907. {
  908. if (p.LandData.OwnerID != masterLandObject.LandData.OwnerID)
  909. {
  910. return;
  911. }
  912. }
  913. lock (m_landList)
  914. {
  915. foreach (ILandObject slaveLandObject in selectedLandObjects)
  916. {
  917. m_landList[masterLandObject.LandData.LocalID].SetLandBitmap(
  918. slaveLandObject.MergeLandBitmaps(masterLandObject.GetLandBitmap(), slaveLandObject.GetLandBitmap()));
  919. performFinalLandJoin(masterLandObject, slaveLandObject);
  920. }
  921. }
  922. masterLandObject.SendLandUpdateToAvatarsOverMe();
  923. }
  924. public void Join(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id)
  925. {
  926. join(start_x, start_y, end_x, end_y, attempting_user_id);
  927. }
  928. public void Subdivide(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id)
  929. {
  930. subdivide(start_x, start_y, end_x, end_y, attempting_user_id);
  931. }
  932. #endregion
  933. #region Parcel Updating
  934. /// <summary>
  935. /// Where we send the ParcelOverlay packet to the client
  936. /// </summary>
  937. /// <param name="remote_client">The object representing the client</param>
  938. public void SendParcelOverlay(IClientAPI remote_client)
  939. {
  940. const int LAND_BLOCKS_PER_PACKET = 1024;
  941. byte[] byteArray = new byte[LAND_BLOCKS_PER_PACKET];
  942. int byteArrayCount = 0;
  943. int sequenceID = 0;
  944. int blockmeters = 4 * (int) Constants.RegionSize/(int)Constants.TerrainPatchSize;
  945. for (int y = 0; y < blockmeters; y++)
  946. {
  947. for (int x = 0; x < blockmeters; x++)
  948. {
  949. byte tempByte = 0; //This represents the byte for the current 4x4
  950. ILandObject currentParcelBlock = GetLandObject(x * 4, y * 4);
  951. if (currentParcelBlock != null)
  952. {
  953. if (currentParcelBlock.LandData.OwnerID == remote_client.AgentId)
  954. {
  955. //Owner Flag
  956. tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_REQUESTER);
  957. }
  958. else if (currentParcelBlock.LandData.SalePrice > 0 &&
  959. (currentParcelBlock.LandData.AuthBuyerID == UUID.Zero ||
  960. currentParcelBlock.LandData.AuthBuyerID == remote_client.AgentId))
  961. {
  962. //Sale Flag
  963. tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_IS_FOR_SALE);
  964. }
  965. else if (currentParcelBlock.LandData.OwnerID == UUID.Zero)
  966. {
  967. //Public Flag
  968. tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_PUBLIC);
  969. }
  970. else
  971. {
  972. //Other Flag
  973. tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_OTHER);
  974. }
  975. //Now for border control
  976. ILandObject westParcel = null;
  977. ILandObject southParcel = null;
  978. if (x > 0)
  979. {
  980. westParcel = GetLandObject((x - 1) * 4, y * 4);
  981. }
  982. if (y > 0)
  983. {
  984. southParcel = GetLandObject(x * 4, (y - 1) * 4);
  985. }
  986. if (x == 0)
  987. {
  988. tempByte = Convert.ToByte(tempByte | LandChannel.LAND_FLAG_PROPERTY_BORDER_WEST);
  989. }
  990. else if (westParcel != null && westParcel != currentParcelBlock)
  991. {
  992. tempByte = Convert.ToByte(tempByte | LandChannel.LAND_FLAG_PROPERTY_BORDER_WEST);
  993. }
  994. if (y == 0)
  995. {
  996. tempByte = Convert.ToByte(tempByte | LandChannel.LAND_FLAG_PROPERTY_BORDER_SOUTH);
  997. }
  998. else if (southParcel != null && southParcel != currentParcelBlock)
  999. {
  1000. tempByte = Convert.ToByte(tempByte | LandChannel.LAND_FLAG_PROPERTY_BORDER_SOUTH);
  1001. }
  1002. byteArray[byteArrayCount] = tempByte;
  1003. byteArrayCount++;
  1004. if (byteArrayCount >= LAND_BLOCKS_PER_PACKET)
  1005. {
  1006. remote_client.SendLandParcelOverlay(byteArray, sequenceID);
  1007. byteArrayCount = 0;
  1008. sequenceID++;
  1009. byteArray = new byte[LAND_BLOCKS_PER_PACKET];
  1010. }
  1011. }
  1012. }
  1013. }
  1014. }
  1015. public void ClientOnParcelPropertiesRequest(int start_x, int start_y, int end_x, int end_y, int sequence_id,
  1016. bool snap_selection, IClientAPI remote_client)
  1017. {
  1018. //Get the land objects within the bounds
  1019. List<ILandObject> temp = new List<ILandObject>();
  1020. int inc_x = end_x - start_x;
  1021. int inc_y = end_y - start_y;
  1022. for (int x = 0; x < inc_x; x++)
  1023. {
  1024. for (int y = 0; y < inc_y; y++)
  1025. {
  1026. ILandObject currentParcel = GetLandObject(start_x + x, start_y + y);
  1027. if (currentParcel != null)
  1028. {
  1029. if (!temp.Contains(currentParcel))
  1030. {
  1031. currentParcel.ForceUpdateLandInfo();
  1032. temp.Add(currentParcel);
  1033. }
  1034. }
  1035. }
  1036. }
  1037. int requestResult = LandChannel.LAND_RESULT_SINGLE;
  1038. if (temp.Count > 1)
  1039. {
  1040. requestResult = LandChannel.LAND_RESULT_MULTIPLE;
  1041. }
  1042. for (int i = 0; i < temp.Count; i++)
  1043. {
  1044. temp[i].SendLandProperties(sequence_id, snap_selection, requestResult, remote_client);
  1045. }
  1046. SendParcelOverlay(remote_client);
  1047. }
  1048. public void ClientOnParcelPropertiesUpdateRequest(LandUpdateArgs args, int localID, IClientAPI remote_client)
  1049. {
  1050. ILandObject land;
  1051. lock (m_landList)
  1052. {
  1053. m_landList.TryGetValue(localID, out land);
  1054. }
  1055. if (land != null)
  1056. {
  1057. land.UpdateLandProperties(args, remote_client);
  1058. m_scene.EventManager.TriggerOnParcelPropertiesUpdateRequest(args, localID, remote_client);
  1059. }
  1060. }
  1061. public void ClientOnParcelDivideRequest(int west, int south, int east, int north, IClientAPI remote_client)
  1062. {
  1063. subdivide(west, south, east, north, remote_client.AgentId);
  1064. }
  1065. public void ClientOnParcelJoinRequest(int west, int south, int east, int north, IClientAPI remote_client)
  1066. {
  1067. join(west, south, east, north, remote_client.AgentId);
  1068. }
  1069. public void ClientOnParcelSelectObjects(int local_id, int request_type,
  1070. List<UUID> returnIDs, IClientAPI remote_client)
  1071. {
  1072. m_landList[local_id].SendForceObjectSelect(local_id, request_type, returnIDs, remote_client);
  1073. }
  1074. public void ClientOnParcelObjectOwnerRequest(int local_id, IClientAPI remote_client)
  1075. {
  1076. ILandObject land;
  1077. lock (m_landList)
  1078. {
  1079. m_landList.TryGetValue(local_id, out land);
  1080. }
  1081. if (land != null)
  1082. {
  1083. m_scene.EventManager.TriggerParcelPrimCountUpdate();
  1084. m_landList[local_id].SendLandObjectOwners(remote_client);
  1085. }
  1086. else
  1087. {
  1088. m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Invalid land object {0} passed for parcel object owner request", local_id);
  1089. }
  1090. }
  1091. public void ClientOnParcelGodForceOwner(int local_id, UUID ownerID, IClientAPI remote_client)
  1092. {
  1093. ILandObject land;
  1094. lock (m_landList)
  1095. {
  1096. m_landList.TryGetValue(local_id, out land);
  1097. }
  1098. if (land != null)
  1099. {
  1100. if (m_scene.Permissions.IsGod(remote_client.AgentId))
  1101. {
  1102. land.LandData.OwnerID = ownerID;
  1103. land.LandData.GroupID = UUID.Zero;
  1104. land.LandData.IsGroupOwned = false;
  1105. land.LandData.Flags &= ~(uint) (ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects | ParcelFlags.ShowDirectory);
  1106. m_scene.ForEachClient(SendParcelOverlay);
  1107. land.SendLandUpdateToClient(true, remote_client);
  1108. }
  1109. }
  1110. }
  1111. public void ClientOnParcelAbandonRequest(int local_id, IClientAPI remote_client)
  1112. {
  1113. ILandObject land;
  1114. lock (m_landList)
  1115. {
  1116. m_landList.TryGetValue(local_id, out land);
  1117. }
  1118. if (land != null)
  1119. {
  1120. if (m_scene.Permissions.CanAbandonParcel(remote_client.AgentId, land))
  1121. {
  1122. land.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
  1123. land.LandData.GroupID = UUID.Zero;
  1124. land.LandData.IsGroupOwned = false;
  1125. land.LandData.Flags &= ~(uint) (ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects | ParcelFlags.ShowDirectory);
  1126. m_scene.ForEachClient(SendParcelOverlay);
  1127. land.SendLandUpdateToClient(true, remote_client);
  1128. }
  1129. }
  1130. }
  1131. public void ClientOnParcelReclaim(int local_id, IClientAPI remote_client)
  1132. {
  1133. ILandObject land;
  1134. lock (m_landList)
  1135. {
  1136. m_landList.TryGetValue(local_id, out land);
  1137. }
  1138. if (land != null)
  1139. {
  1140. if (m_scene.Permissions.CanReclaimParcel(remote_client.AgentId, land))
  1141. {
  1142. land.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
  1143. land.LandData.ClaimDate = Util.UnixTimeSinceEpoch();
  1144. land.LandData.GroupID = UUID.Zero;
  1145. land.LandData.IsGroupOwned = false;
  1146. land.LandData.SalePrice = 0;
  1147. land.LandData.AuthBuyerID = UUID.Zero;
  1148. land.LandData.Flags &= ~(uint) (ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects | ParcelFlags.ShowDirectory);
  1149. m_scene.ForEachClient(SendParcelOverlay);
  1150. land.SendLandUpdateToClient(true, remote_client);
  1151. }
  1152. }
  1153. }
  1154. #endregion
  1155. // If the economy has been validated by the economy module,
  1156. // and land has been validated as well, this method transfers
  1157. // the land ownership
  1158. public void EventManagerOnLandBuy(Object o, EventManager.LandBuyArgs e)
  1159. {
  1160. if (e.economyValidated && e.landValidated)
  1161. {
  1162. ILandObject land;
  1163. lock (m_landList)
  1164. {
  1165. m_landList.TryGetValue(e.parcelLocalID, out land);
  1166. }
  1167. if (land != null)
  1168. {
  1169. land.UpdateLandSold(e.agentId, e.groupId, e.groupOwned, (uint)e.transactionID, e.parcelPrice, e.parcelArea);
  1170. }
  1171. }
  1172. }
  1173. // After receiving a land buy packet, first the data needs to
  1174. // be validated. This method validates the right to buy the
  1175. // parcel
  1176. public void EventManagerOnValidateLandBuy(Object o, EventManager.LandBuyArgs e)
  1177. {
  1178. if (e.landValidated == false)
  1179. {
  1180. ILandObject lob = null;
  1181. lock (m_landList)
  1182. {
  1183. m_landList.TryGetValue(e.parcelLocalID, out lob);
  1184. }
  1185. if (lob != null)
  1186. {
  1187. UUID AuthorizedID = lob.LandData.AuthBuyerID;
  1188. int saleprice = lob.LandData.SalePrice;
  1189. UUID pOwnerID = lob.LandData.OwnerID;
  1190. bool landforsale = ((lob.LandData.Flags &
  1191. (uint)(ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects)) != 0);
  1192. if ((AuthorizedID == UUID.Zero || AuthorizedID == e.agentId) && e.parcelPrice >= saleprice && landforsale)
  1193. {
  1194. // TODO I don't think we have to lock it here, no?
  1195. //lock (e)
  1196. //{
  1197. e.parcelOwnerID = pOwnerID;
  1198. e.landValidated = true;
  1199. //}
  1200. }
  1201. }
  1202. }
  1203. }
  1204. void ClientOnParcelDeedToGroup(int parcelLocalID, UUID groupID, IClientAPI remote_client)
  1205. {
  1206. ILandObject land;
  1207. lock (m_landList)
  1208. {
  1209. m_landList.TryGetValue(parcelLocalID, out land);
  1210. }
  1211. if (!m_scene.Permissions.CanDeedParcel(remote_client.AgentId, land))
  1212. return;
  1213. if (land != null)
  1214. {
  1215. land.DeedToGroup(groupID);
  1216. }
  1217. }
  1218. #region Land Object From Storage Functions
  1219. public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data)
  1220. {
  1221. // m_log.DebugFormat(
  1222. // "[LAND MANAGMENT MODULE]: Processing {0} incoming parcels on {1}", data.Count, m_scene.Name);
  1223. for (int i = 0; i < data.Count; i++)
  1224. IncomingLandObjectFromStorage(data[i]);
  1225. }
  1226. public void IncomingLandObjectFromStorage(LandData data)
  1227. {
  1228. ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene);
  1229. new_land.LandData = data.Copy();
  1230. new_land.SetLandBitmapFromByteArray();
  1231. AddLandObject(new_land);
  1232. }
  1233. public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient)
  1234. {
  1235. ILandObject selectedParcel = null;
  1236. lock (m_landList)
  1237. {
  1238. m_landList.TryGetValue(localID, out selectedParcel);
  1239. }
  1240. if (selectedParcel == null) return;
  1241. selectedParcel.ReturnLandObjects(returnType, agentIDs, taskIDs, remoteClient);
  1242. }
  1243. public void EventManagerOnNoLandDataFromStorage()
  1244. {
  1245. lock (m_landList)
  1246. {
  1247. ResetSimLandObjects();
  1248. CreateDefaultParcel();
  1249. }
  1250. }
  1251. #endregion
  1252. public void setParcelObjectMaxOverride(overrideParcelMaxPrimCountDelegate overrideDel)
  1253. {
  1254. lock (m_landList)
  1255. {
  1256. foreach (LandObject obj in m_landList.Values)
  1257. {
  1258. obj.SetParcelObjectMaxOverride(overrideDel);
  1259. }
  1260. }
  1261. }
  1262. public void setSimulatorObjectMaxOverride(overrideSimulatorMaxPrimCountDelegate overrideDel)
  1263. {
  1264. }
  1265. #region CAPS handler
  1266. private void EventManagerOnRegisterCaps(UUID agentID, Caps caps)
  1267. {
  1268. string capsBase = "/CAPS/" + caps.CapsObjectPath;
  1269. caps.RegisterHandler(
  1270. "RemoteParcelRequest",
  1271. new RestStreamHandler(
  1272. "POST",
  1273. capsBase + remoteParcelRequestPath,
  1274. (request, path, param, httpRequest, httpResponse)
  1275. => RemoteParcelRequest(request, path, param, agentID, caps),
  1276. "RemoteParcelRequest",
  1277. agentID.ToString()));
  1278. UUID parcelCapID = UUID.Random();
  1279. caps.RegisterHandler(
  1280. "ParcelPropertiesUpdate",
  1281. new RestStreamHandler(
  1282. "POST",
  1283. "/CAPS/" + parcelCapID,
  1284. (request, path, param, httpRequest, httpResponse)
  1285. => ProcessPropertiesUpdate(request, path, param, agentID, caps),
  1286. "ParcelPropertiesUpdate",
  1287. agentID.ToString()));
  1288. }
  1289. private string ProcessPropertiesUpdate(string request, string path, string param, UUID agentID, Caps caps)
  1290. {
  1291. IClientAPI client;
  1292. if (!m_scene.TryGetClient(agentID, out client))
  1293. {
  1294. m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Unable to retrieve IClientAPI for {0}", agentID);
  1295. return LLSDHelpers.SerialiseLLSDReply(new LLSDEmpty());
  1296. }
  1297. ParcelPropertiesUpdateMessage properties = new ParcelPropertiesUpdateMessage();
  1298. OpenMetaverse.StructuredData.OSDMap args = (OpenMetaverse.StructuredData.OSDMap) OSDParser.DeserializeLLSDXml(request);
  1299. properties.Deserialize(args);
  1300. LandUpdateArgs land_update = new LandUpdateArgs();
  1301. int parcelID = properties.LocalID;
  1302. land_update.AuthBuyerID = properties.AuthBuyerID;
  1303. land_update.Category = properties.Category;
  1304. land_update.Desc = properties.Desc;
  1305. land_update.GroupID = properties.GroupID;
  1306. land_update.LandingType = (byte) properties.Landing;
  1307. land_update.MediaAutoScale = (byte) Convert.ToInt32(properties.MediaAutoScale);
  1308. land_update.MediaID = properties.MediaID;
  1309. land_update.MediaURL = properties.MediaURL;
  1310. land_update.MusicURL = properties.MusicURL;
  1311. land_update.Name = properties.Name;
  1312. land_update.ParcelFlags = (uint) properties.ParcelFlags;
  1313. land_update.PassHours = (int) properties.PassHours;
  1314. land_update.PassPrice = (int) properties.PassPrice;
  1315. land_update.SalePrice = (int) properties.SalePrice;
  1316. land_update.SnapshotID = properties.SnapshotID;
  1317. land_update.UserLocation = properties.UserLocation;
  1318. land_update.UserLookAt = properties.UserLookAt;
  1319. land_update.MediaDescription = properties.MediaDesc;
  1320. land_update.MediaType = properties.MediaType;
  1321. land_update.MediaWidth = properties.MediaWidth;
  1322. land_update.MediaHeight = properties.MediaHeight;
  1323. land_update.MediaLoop = properties.MediaLoop;
  1324. land_update.ObscureMusic = properties.ObscureMusic;
  1325. land_update.ObscureMedia = properties.ObscureMedia;
  1326. ILandObject land;
  1327. lock (m_landList)
  1328. {
  1329. m_landList.TryGetValue(parcelID, out land);
  1330. }
  1331. if (land != null)
  1332. {
  1333. land.UpdateLandProperties(land_update, client);
  1334. m_scene.EventManager.TriggerOnParcelPropertiesUpdateRequest(land_update, parcelID, client);
  1335. }
  1336. else
  1337. {
  1338. m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Unable to find parcelID {0}", parcelID);
  1339. }
  1340. return LLSDHelpers.SerialiseLLSDReply(new LLSDEmpty());
  1341. }
  1342. // we cheat here: As we don't have (and want) a grid-global parcel-store, we can't return the
  1343. // "real" parcelID, because we wouldn't be able to map that to the region the parcel belongs to.
  1344. // So, we create a "fake" parcelID by using the regionHandle (64 bit), and the local (integer) x
  1345. // and y coordinate (each 8 bit), encoded in a UUID (128 bit).
  1346. //
  1347. // Request format:
  1348. // <llsd>
  1349. // <map>
  1350. // <key>location</key>
  1351. // <array>
  1352. // <real>1.23</real>
  1353. // <real>45..6</real>
  1354. // <real>78.9</real>
  1355. // </array>
  1356. // <key>region_id</key>
  1357. // <uuid>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</uuid>
  1358. // </map>
  1359. // </llsd>
  1360. private string RemoteParcelRequest(string request, string path, string param, UUID agentID, Caps caps)
  1361. {
  1362. UUID parcelID = UUID.Zero;
  1363. try
  1364. {
  1365. Hashtable hash = new Hashtable();
  1366. hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request));
  1367. if (hash.ContainsKey("region_id") && hash.ContainsKey("location"))
  1368. {
  1369. UUID regionID = (UUID)hash["region_id"];
  1370. ArrayList list = (ArrayList)hash["location"];
  1371. uint x = (uint)(double)list[0];
  1372. uint y = (uint)(double)list[1];
  1373. if (hash.ContainsKey("region_handle"))
  1374. {
  1375. // if you do a "About Landmark" on a landmark a second time, the viewer sends the
  1376. // region_handle it got earlier via RegionHandleRequest
  1377. ulong regionHandle = Util.BytesToUInt64Big((byte[])hash["region_handle"]);
  1378. parcelID = Util.BuildFakeParcelID(regionHandle, x, y);
  1379. }
  1380. else if (regionID == m_scene.RegionInfo.RegionID)
  1381. {
  1382. // a parcel request for a local parcel => no need to query the grid
  1383. parcelID = Util.BuildFakeParcelID(m_scene.RegionInfo.RegionHandle, x, y);
  1384. }
  1385. else
  1386. {
  1387. // a parcel request for a parcel in another region. Ask the grid about the region
  1388. GridRegion info = m_scene.GridService.GetRegionByUUID(UUID.Zero, regionID);
  1389. if (info != null)
  1390. parcelID = Util.BuildFakeParcelID(info.RegionHandle, x, y);
  1391. }
  1392. }
  1393. }
  1394. catch (LLSD.LLSDParseException e)
  1395. {
  1396. m_log.ErrorFormat("[LAND MANAGEMENT MODULE]: Fetch error: {0}", e.Message);
  1397. m_log.ErrorFormat("[LAND MANAGEMENT MODULE]: ... in request {0}", request);
  1398. }
  1399. catch (InvalidCastException)
  1400. {
  1401. m_log.ErrorFormat("[LAND MANAGEMENT MODULE]: Wrong type in request {0}", request);
  1402. }
  1403. LLSDRemoteParcelResponse response = new LLSDRemoteParcelResponse();
  1404. response.parcel_id = parcelID;
  1405. m_log.DebugFormat("[LAND MANAGEMENT MODULE]: Got parcelID {0}", parcelID);
  1406. return LLSDHelpers.SerialiseLLSDReply(response);
  1407. }
  1408. #endregion
  1409. private void ClientOnParcelInfoRequest(IClientAPI remoteClient, UUID parcelID)
  1410. {
  1411. if (parcelID == UUID.Zero)
  1412. return;
  1413. ExtendedLandData data = (ExtendedLandData)parcelInfoCache.Get(parcelID.ToString(),
  1414. delegate(string id)
  1415. {
  1416. UUID parcel = UUID.Zero;
  1417. UUID.TryParse(id, out parcel);
  1418. // assume we've got the parcelID we just computed in RemoteParcelRequest
  1419. ExtendedLandData extLandData = new ExtendedLandData();
  1420. Util.ParseFakeParcelID(parcel, out extLandData.RegionHandle,
  1421. out extLandData.X, out extLandData.Y);
  1422. m_log.DebugFormat("[LAND MANAGEMENT MODULE]: Got parcelinfo request for regionHandle {0}, x/y {1}/{2}",
  1423. extLandData.RegionHandle, extLandData.X, extLandData.Y);
  1424. // for this region or for somewhere else?
  1425. if (extLandData.RegionHandle == m_scene.RegionInfo.RegionHandle)
  1426. {
  1427. extLandData.LandData = this.GetLandObject(extLandData.X, extLandData.Y).LandData;
  1428. extLandData.RegionAccess = m_scene.RegionInfo.AccessLevel;
  1429. }
  1430. else
  1431. {
  1432. ILandService landService = m_scene.RequestModuleInterface<ILandService>();
  1433. extLandData.LandData = landService.GetLandData(m_scene.RegionInfo.ScopeID,
  1434. extLandData.RegionHandle,
  1435. extLandData.X,
  1436. extLandData.Y,
  1437. out extLandData.RegionAccess);
  1438. if (extLandData.LandData == null)
  1439. {
  1440. // we didn't find the region/land => don't cache
  1441. return null;
  1442. }
  1443. }
  1444. return extLandData;
  1445. });
  1446. if (data != null) // if we found some data, send it
  1447. {
  1448. GridRegion info;
  1449. if (data.RegionHandle == m_scene.RegionInfo.RegionHandle)
  1450. {
  1451. info = new GridRegion(m_scene.RegionInfo);
  1452. }
  1453. else
  1454. {
  1455. // most likely still cached from building the extLandData entry
  1456. uint x = 0, y = 0;
  1457. Utils.LongToUInts(data.RegionHandle, out x, out y);
  1458. info = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
  1459. }
  1460. // we need to transfer the fake parcelID, not the one in landData, so the viewer can match it to the landmark.
  1461. m_log.DebugFormat("[LAND MANAGEMENT MODULE]: got parcelinfo for parcel {0} in region {1}; sending...",
  1462. data.LandData.Name, data.RegionHandle);
  1463. // HACK for now
  1464. RegionInfo r = new RegionInfo();
  1465. r.RegionName = info.RegionName;
  1466. r.RegionLocX = (uint)info.RegionLocX;
  1467. r.RegionLocY = (uint)info.RegionLocY;
  1468. r.RegionSettings.Maturity = (int)Util.ConvertAccessLevelToMaturity(data.RegionAccess);
  1469. remoteClient.SendParcelInfo(r, data.LandData, parcelID, data.X, data.Y);
  1470. }
  1471. else
  1472. m_log.Debug("[LAND MANAGEMENT MODULE]: got no parcelinfo; not sending");
  1473. }
  1474. public void setParcelOtherCleanTime(IClientAPI remoteClient, int localID, int otherCleanTime)
  1475. {
  1476. ILandObject land;
  1477. lock (m_landList)
  1478. {
  1479. m_landList.TryGetValue(localID, out land);
  1480. }
  1481. if (land == null) return;
  1482. if (!m_scene.Permissions.CanEditParcelProperties(remoteClient.AgentId, land, GroupPowers.LandOptions))
  1483. return;
  1484. land.LandData.OtherCleanTime = otherCleanTime;
  1485. UpdateLandObject(localID, land.LandData);
  1486. }
  1487. protected void InstallInterfaces()
  1488. {
  1489. Command clearCommand
  1490. = new Command("clear", CommandIntentions.COMMAND_HAZARDOUS, ClearCommand, "Clears all the parcels from the region.");
  1491. Command showCommand
  1492. = new Command("show", CommandIntentions.COMMAND_STATISTICAL, ShowParcelsCommand, "Shows all parcels on the region.");
  1493. m_commander.RegisterCommand("clear", clearCommand);
  1494. m_commander.RegisterCommand("show", showCommand);
  1495. // Add this to our scene so scripts can call these functions
  1496. m_scene.RegisterModuleCommander(m_commander);
  1497. }
  1498. protected void ClearCommand(Object[] args)
  1499. {
  1500. string response = MainConsole.Instance.CmdPrompt(
  1501. string.Format(
  1502. "Are you sure that you want to clear all land parcels from {0} (y or n)",
  1503. m_scene.RegionInfo.RegionName),
  1504. "n");
  1505. if (response.ToLower() == "y")
  1506. {
  1507. Clear(true);
  1508. MainConsole.Instance.OutputFormat("Cleared all parcels from {0}", m_scene.RegionInfo.RegionName);
  1509. }
  1510. else
  1511. {
  1512. MainConsole.Instance.OutputFormat("Aborting clear of all parcels from {0}", m_scene.RegionInfo.RegionName);
  1513. }
  1514. }
  1515. protected void ShowParcelsCommand(Object[] args)
  1516. {
  1517. StringBuilder report = new StringBuilder();
  1518. report.AppendFormat("Land information for {0}\n", m_scene.RegionInfo.RegionName);
  1519. report.AppendFormat(
  1520. "{0,-20} {1,-10} {2,-9} {3,-18} {4,-18} {5,-20}\n",
  1521. "Parcel Name",
  1522. "Local ID",
  1523. "Area",
  1524. "Starts",
  1525. "Ends",
  1526. "Owner");
  1527. lock (m_landList)
  1528. {
  1529. foreach (ILandObject lo in m_landList.Values)
  1530. {
  1531. LandData ld = lo.LandData;
  1532. report.AppendFormat(
  1533. "{0,-20} {1,-10} {2,-9} {3,-18} {4,-18} {5,-20}\n",
  1534. ld.Name, ld.LocalID, ld.Area, lo.StartPoint, lo.EndPoint, m_userManager.GetUserName(ld.OwnerID));
  1535. }
  1536. }
  1537. MainConsole.Instance.Output(report.ToString());
  1538. }
  1539. }
  1540. }