1
0

LandManagementModule.cs 92 KB

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