EstateManagementModule.cs 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. using System.IO;
  30. using System.Reflection;
  31. using System.Security;
  32. using log4net;
  33. using Mono.Addins;
  34. using Nini.Config;
  35. using OpenMetaverse;
  36. using OpenSim.Framework;
  37. using OpenSim.Region.Framework.Interfaces;
  38. using OpenSim.Region.Framework.Scenes;
  39. namespace OpenSim.Region.CoreModules.World.Estate
  40. {
  41. [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EstateManagementModule")]
  42. public class EstateManagementModule : IEstateModule, INonSharedRegionModule
  43. {
  44. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  45. private delegate void LookupUUIDS(List<UUID> uuidLst);
  46. public Scene Scene { get; private set; }
  47. public IUserManagement UserManager { get; private set; }
  48. protected EstateManagementCommands m_commands;
  49. private EstateTerrainXferHandler TerrainUploader;
  50. public event ChangeDelegate OnRegionInfoChange;
  51. public event ChangeDelegate OnEstateInfoChange;
  52. public event MessageDelegate OnEstateMessage;
  53. #region Packet Data Responders
  54. private void sendDetailedEstateData(IClientAPI remote_client, UUID invoice)
  55. {
  56. uint sun = 0;
  57. if (!Scene.RegionInfo.EstateSettings.UseGlobalTime)
  58. sun = (uint)(Scene.RegionInfo.EstateSettings.SunPosition * 1024.0) + 0x1800;
  59. UUID estateOwner;
  60. estateOwner = Scene.RegionInfo.EstateSettings.EstateOwner;
  61. if (Scene.Permissions.IsGod(remote_client.AgentId))
  62. estateOwner = remote_client.AgentId;
  63. remote_client.SendDetailedEstateData(invoice,
  64. Scene.RegionInfo.EstateSettings.EstateName,
  65. Scene.RegionInfo.EstateSettings.EstateID,
  66. Scene.RegionInfo.EstateSettings.ParentEstateID,
  67. GetEstateFlags(),
  68. sun,
  69. Scene.RegionInfo.RegionSettings.Covenant,
  70. Scene.RegionInfo.EstateSettings.AbuseEmail,
  71. estateOwner);
  72. remote_client.SendEstateList(invoice,
  73. (int)Constants.EstateAccessCodex.EstateManagers,
  74. Scene.RegionInfo.EstateSettings.EstateManagers,
  75. Scene.RegionInfo.EstateSettings.EstateID);
  76. remote_client.SendEstateList(invoice,
  77. (int)Constants.EstateAccessCodex.AccessOptions,
  78. Scene.RegionInfo.EstateSettings.EstateAccess,
  79. Scene.RegionInfo.EstateSettings.EstateID);
  80. remote_client.SendEstateList(invoice,
  81. (int)Constants.EstateAccessCodex.AllowedGroups,
  82. Scene.RegionInfo.EstateSettings.EstateGroups,
  83. Scene.RegionInfo.EstateSettings.EstateID);
  84. remote_client.SendBannedUserList(invoice,
  85. Scene.RegionInfo.EstateSettings.EstateBans,
  86. Scene.RegionInfo.EstateSettings.EstateID);
  87. }
  88. private void estateSetRegionInfoHandler(bool blockTerraform, bool noFly, bool allowDamage, bool blockLandResell, int maxAgents, float objectBonusFactor,
  89. int matureLevel, bool restrictPushObject, bool allowParcelChanges)
  90. {
  91. if (blockTerraform)
  92. Scene.RegionInfo.RegionSettings.BlockTerraform = true;
  93. else
  94. Scene.RegionInfo.RegionSettings.BlockTerraform = false;
  95. if (noFly)
  96. Scene.RegionInfo.RegionSettings.BlockFly = true;
  97. else
  98. Scene.RegionInfo.RegionSettings.BlockFly = false;
  99. if (allowDamage)
  100. Scene.RegionInfo.RegionSettings.AllowDamage = true;
  101. else
  102. Scene.RegionInfo.RegionSettings.AllowDamage = false;
  103. if (blockLandResell)
  104. Scene.RegionInfo.RegionSettings.AllowLandResell = false;
  105. else
  106. Scene.RegionInfo.RegionSettings.AllowLandResell = true;
  107. if((byte)maxAgents <= Scene.RegionInfo.AgentCapacity)
  108. Scene.RegionInfo.RegionSettings.AgentLimit = (byte) maxAgents;
  109. else
  110. Scene.RegionInfo.RegionSettings.AgentLimit = Scene.RegionInfo.AgentCapacity;
  111. Scene.RegionInfo.RegionSettings.ObjectBonus = objectBonusFactor;
  112. if (matureLevel <= 13)
  113. Scene.RegionInfo.RegionSettings.Maturity = 0;
  114. else if (matureLevel <= 21)
  115. Scene.RegionInfo.RegionSettings.Maturity = 1;
  116. else
  117. Scene.RegionInfo.RegionSettings.Maturity = 2;
  118. if (restrictPushObject)
  119. Scene.RegionInfo.RegionSettings.RestrictPushing = true;
  120. else
  121. Scene.RegionInfo.RegionSettings.RestrictPushing = false;
  122. if (allowParcelChanges)
  123. Scene.RegionInfo.RegionSettings.AllowLandJoinDivide = true;
  124. else
  125. Scene.RegionInfo.RegionSettings.AllowLandJoinDivide = false;
  126. Scene.RegionInfo.RegionSettings.Save();
  127. TriggerRegionInfoChange();
  128. sendRegionInfoPacketToAll();
  129. }
  130. public void setEstateTerrainBaseTexture(IClientAPI remoteClient, int corner, UUID texture)
  131. {
  132. if (texture == UUID.Zero)
  133. return;
  134. switch (corner)
  135. {
  136. case 0:
  137. Scene.RegionInfo.RegionSettings.TerrainTexture1 = texture;
  138. break;
  139. case 1:
  140. Scene.RegionInfo.RegionSettings.TerrainTexture2 = texture;
  141. break;
  142. case 2:
  143. Scene.RegionInfo.RegionSettings.TerrainTexture3 = texture;
  144. break;
  145. case 3:
  146. Scene.RegionInfo.RegionSettings.TerrainTexture4 = texture;
  147. break;
  148. }
  149. Scene.RegionInfo.RegionSettings.Save();
  150. TriggerRegionInfoChange();
  151. sendRegionInfoPacketToAll();
  152. }
  153. public void setEstateTerrainTextureHeights(IClientAPI client, int corner, float lowValue, float highValue)
  154. {
  155. switch (corner)
  156. {
  157. case 0:
  158. Scene.RegionInfo.RegionSettings.Elevation1SW = lowValue;
  159. Scene.RegionInfo.RegionSettings.Elevation2SW = highValue;
  160. break;
  161. case 1:
  162. Scene.RegionInfo.RegionSettings.Elevation1NW = lowValue;
  163. Scene.RegionInfo.RegionSettings.Elevation2NW = highValue;
  164. break;
  165. case 2:
  166. Scene.RegionInfo.RegionSettings.Elevation1SE = lowValue;
  167. Scene.RegionInfo.RegionSettings.Elevation2SE = highValue;
  168. break;
  169. case 3:
  170. Scene.RegionInfo.RegionSettings.Elevation1NE = lowValue;
  171. Scene.RegionInfo.RegionSettings.Elevation2NE = highValue;
  172. break;
  173. }
  174. Scene.RegionInfo.RegionSettings.Save();
  175. TriggerRegionInfoChange();
  176. sendRegionHandshakeToAll();
  177. sendRegionInfoPacketToAll();
  178. }
  179. private void handleCommitEstateTerrainTextureRequest(IClientAPI remoteClient)
  180. {
  181. // sendRegionHandshakeToAll();
  182. }
  183. public void setRegionTerrainSettings(float WaterHeight,
  184. float TerrainRaiseLimit, float TerrainLowerLimit,
  185. bool UseEstateSun, bool UseFixedSun, float SunHour,
  186. bool UseGlobal, bool EstateFixedSun, float EstateSunHour)
  187. {
  188. // Water Height
  189. Scene.RegionInfo.RegionSettings.WaterHeight = WaterHeight;
  190. // Terraforming limits
  191. Scene.RegionInfo.RegionSettings.TerrainRaiseLimit = TerrainRaiseLimit;
  192. Scene.RegionInfo.RegionSettings.TerrainLowerLimit = TerrainLowerLimit;
  193. // Time of day / fixed sun
  194. Scene.RegionInfo.RegionSettings.UseEstateSun = UseEstateSun;
  195. Scene.RegionInfo.RegionSettings.FixedSun = UseFixedSun;
  196. Scene.RegionInfo.RegionSettings.SunPosition = SunHour;
  197. Scene.TriggerEstateSunUpdate();
  198. //m_log.Debug("[ESTATE]: UFS: " + UseFixedSun.ToString());
  199. //m_log.Debug("[ESTATE]: SunHour: " + SunHour.ToString());
  200. sendRegionInfoPacketToAll();
  201. Scene.RegionInfo.RegionSettings.Save();
  202. TriggerRegionInfoChange();
  203. }
  204. private void handleEstateRestartSimRequest(IClientAPI remoteClient, int timeInSeconds)
  205. {
  206. IRestartModule restartModule = Scene.RequestModuleInterface<IRestartModule>();
  207. if (restartModule != null)
  208. {
  209. List<int> times = new List<int>();
  210. while (timeInSeconds > 0)
  211. {
  212. times.Add(timeInSeconds);
  213. if (timeInSeconds > 300)
  214. timeInSeconds -= 120;
  215. else if (timeInSeconds > 30)
  216. timeInSeconds -= 30;
  217. else
  218. timeInSeconds -= 15;
  219. }
  220. restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true);
  221. }
  222. }
  223. private void handleChangeEstateCovenantRequest(IClientAPI remoteClient, UUID estateCovenantID)
  224. {
  225. // m_log.DebugFormat(
  226. // "[ESTATE MANAGEMENT MODULE]: Handling request from {0} to change estate covenant to {1}",
  227. // remoteClient.Name, estateCovenantID);
  228. Scene.RegionInfo.RegionSettings.Covenant = estateCovenantID;
  229. Scene.RegionInfo.RegionSettings.Save();
  230. TriggerRegionInfoChange();
  231. }
  232. private void handleEstateAccessDeltaRequest(IClientAPI remote_client, UUID invoice, int estateAccessType, UUID user)
  233. {
  234. // EstateAccessDelta handles Estate Managers, Sim Access, Sim Banlist, allowed Groups.. etc.
  235. if (user == Scene.RegionInfo.EstateSettings.EstateOwner)
  236. return; // never process EO
  237. if ((estateAccessType & 4) != 0) // User add
  238. {
  239. if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
  240. {
  241. if ((estateAccessType & 1) != 0) // All estates
  242. {
  243. List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
  244. EstateSettings estateSettings;
  245. foreach (int estateID in estateIDs)
  246. {
  247. if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
  248. {
  249. estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
  250. estateSettings.AddEstateUser(user);
  251. estateSettings.Save();
  252. }
  253. }
  254. }
  255. Scene.RegionInfo.EstateSettings.AddEstateUser(user);
  256. Scene.RegionInfo.EstateSettings.Save();
  257. TriggerEstateInfoChange();
  258. remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, Scene.RegionInfo.EstateSettings.EstateAccess, Scene.RegionInfo.EstateSettings.EstateID);
  259. }
  260. else
  261. {
  262. remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
  263. }
  264. }
  265. if ((estateAccessType & 8) != 0) // User remove
  266. {
  267. if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
  268. {
  269. if ((estateAccessType & 1) != 0) // All estates
  270. {
  271. List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
  272. EstateSettings estateSettings;
  273. foreach (int estateID in estateIDs)
  274. {
  275. if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
  276. {
  277. estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
  278. estateSettings.RemoveEstateUser(user);
  279. estateSettings.Save();
  280. }
  281. }
  282. }
  283. Scene.RegionInfo.EstateSettings.RemoveEstateUser(user);
  284. Scene.RegionInfo.EstateSettings.Save();
  285. TriggerEstateInfoChange();
  286. remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, Scene.RegionInfo.EstateSettings.EstateAccess, Scene.RegionInfo.EstateSettings.EstateID);
  287. }
  288. else
  289. {
  290. remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
  291. }
  292. }
  293. if ((estateAccessType & 16) != 0) // Group add
  294. {
  295. if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
  296. {
  297. if ((estateAccessType & 1) != 0) // All estates
  298. {
  299. List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
  300. EstateSettings estateSettings;
  301. foreach (int estateID in estateIDs)
  302. {
  303. if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
  304. {
  305. estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
  306. estateSettings.AddEstateGroup(user);
  307. estateSettings.Save();
  308. }
  309. }
  310. }
  311. Scene.RegionInfo.EstateSettings.AddEstateGroup(user);
  312. Scene.RegionInfo.EstateSettings.Save();
  313. TriggerEstateInfoChange();
  314. remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, Scene.RegionInfo.EstateSettings.EstateGroups, Scene.RegionInfo.EstateSettings.EstateID);
  315. }
  316. else
  317. {
  318. remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
  319. }
  320. }
  321. if ((estateAccessType & 32) != 0) // Group remove
  322. {
  323. if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
  324. {
  325. if ((estateAccessType & 1) != 0) // All estates
  326. {
  327. List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
  328. EstateSettings estateSettings;
  329. foreach (int estateID in estateIDs)
  330. {
  331. if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
  332. {
  333. estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
  334. estateSettings.RemoveEstateGroup(user);
  335. estateSettings.Save();
  336. }
  337. }
  338. }
  339. Scene.RegionInfo.EstateSettings.RemoveEstateGroup(user);
  340. Scene.RegionInfo.EstateSettings.Save();
  341. TriggerEstateInfoChange();
  342. remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, Scene.RegionInfo.EstateSettings.EstateGroups, Scene.RegionInfo.EstateSettings.EstateID);
  343. }
  344. else
  345. {
  346. remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
  347. }
  348. }
  349. if ((estateAccessType & 64) != 0) // Ban add
  350. {
  351. if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || Scene.Permissions.BypassPermissions())
  352. {
  353. EstateBan[] banlistcheck = Scene.RegionInfo.EstateSettings.EstateBans;
  354. bool alreadyInList = false;
  355. for (int i = 0; i < banlistcheck.Length; i++)
  356. {
  357. if (user == banlistcheck[i].BannedUserID)
  358. {
  359. alreadyInList = true;
  360. break;
  361. }
  362. }
  363. if (!alreadyInList)
  364. {
  365. if ((estateAccessType & 1) != 0) // All estates
  366. {
  367. List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
  368. EstateSettings estateSettings;
  369. foreach (int estateID in estateIDs)
  370. {
  371. if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
  372. {
  373. EstateBan bitem = new EstateBan();
  374. bitem.BannedUserID = user;
  375. bitem.EstateID = (uint)estateID;
  376. bitem.BannedHostAddress = "0.0.0.0";
  377. bitem.BannedHostIPMask = "0.0.0.0";
  378. estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
  379. estateSettings.AddBan(bitem);
  380. estateSettings.Save();
  381. }
  382. }
  383. }
  384. EstateBan item = new EstateBan();
  385. item.BannedUserID = user;
  386. item.EstateID = Scene.RegionInfo.EstateSettings.EstateID;
  387. item.BannedHostAddress = "0.0.0.0";
  388. item.BannedHostIPMask = "0.0.0.0";
  389. Scene.RegionInfo.EstateSettings.AddBan(item);
  390. Scene.RegionInfo.EstateSettings.Save();
  391. TriggerEstateInfoChange();
  392. ScenePresence s = Scene.GetScenePresence(user);
  393. if (s != null)
  394. {
  395. if (!s.IsChildAgent)
  396. {
  397. Scene.TeleportClientHome(user, s.ControllingClient);
  398. }
  399. }
  400. }
  401. else
  402. {
  403. remote_client.SendAlertMessage("User is already on the region ban list");
  404. }
  405. //m_scene.RegionInfo.regionBanlist.Add(Manager(user);
  406. remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID);
  407. }
  408. else
  409. {
  410. remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
  411. }
  412. }
  413. if ((estateAccessType & 128) != 0) // Ban remove
  414. {
  415. if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || Scene.Permissions.BypassPermissions())
  416. {
  417. EstateBan[] banlistcheck = Scene.RegionInfo.EstateSettings.EstateBans;
  418. bool alreadyInList = false;
  419. EstateBan listitem = null;
  420. for (int i = 0; i < banlistcheck.Length; i++)
  421. {
  422. if (user == banlistcheck[i].BannedUserID)
  423. {
  424. alreadyInList = true;
  425. listitem = banlistcheck[i];
  426. break;
  427. }
  428. }
  429. if (alreadyInList && listitem != null)
  430. {
  431. if ((estateAccessType & 1) != 0) // All estates
  432. {
  433. List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
  434. EstateSettings estateSettings;
  435. foreach (int estateID in estateIDs)
  436. {
  437. if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
  438. {
  439. estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
  440. estateSettings.RemoveBan(user);
  441. estateSettings.Save();
  442. }
  443. }
  444. }
  445. Scene.RegionInfo.EstateSettings.RemoveBan(listitem.BannedUserID);
  446. Scene.RegionInfo.EstateSettings.Save();
  447. TriggerEstateInfoChange();
  448. }
  449. else
  450. {
  451. remote_client.SendAlertMessage("User is not on the region ban list");
  452. }
  453. //m_scene.RegionInfo.regionBanlist.Add(Manager(user);
  454. remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID);
  455. }
  456. else
  457. {
  458. remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
  459. }
  460. }
  461. if ((estateAccessType & 256) != 0) // Manager add
  462. {
  463. if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
  464. {
  465. if ((estateAccessType & 1) != 0) // All estates
  466. {
  467. List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
  468. EstateSettings estateSettings;
  469. foreach (int estateID in estateIDs)
  470. {
  471. if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
  472. {
  473. estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
  474. estateSettings.AddEstateManager(user);
  475. estateSettings.Save();
  476. }
  477. }
  478. }
  479. Scene.RegionInfo.EstateSettings.AddEstateManager(user);
  480. Scene.RegionInfo.EstateSettings.Save();
  481. TriggerEstateInfoChange();
  482. remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, Scene.RegionInfo.EstateSettings.EstateManagers, Scene.RegionInfo.EstateSettings.EstateID);
  483. }
  484. else
  485. {
  486. remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
  487. }
  488. }
  489. if ((estateAccessType & 512) != 0) // Manager remove
  490. {
  491. if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions())
  492. {
  493. if ((estateAccessType & 1) != 0) // All estates
  494. {
  495. List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
  496. EstateSettings estateSettings;
  497. foreach (int estateID in estateIDs)
  498. {
  499. if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
  500. {
  501. estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
  502. estateSettings.RemoveEstateManager(user);
  503. estateSettings.Save();
  504. }
  505. }
  506. }
  507. Scene.RegionInfo.EstateSettings.RemoveEstateManager(user);
  508. Scene.RegionInfo.EstateSettings.Save();
  509. TriggerEstateInfoChange();
  510. remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, Scene.RegionInfo.EstateSettings.EstateManagers, Scene.RegionInfo.EstateSettings.EstateID);
  511. }
  512. else
  513. {
  514. remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
  515. }
  516. }
  517. }
  518. private void SendSimulatorBlueBoxMessage(
  519. IClientAPI remote_client, UUID invoice, UUID senderID, UUID sessionID, string senderName, string message)
  520. {
  521. IDialogModule dm = Scene.RequestModuleInterface<IDialogModule>();
  522. if (dm != null)
  523. dm.SendNotificationToUsersInRegion(senderID, senderName, message);
  524. }
  525. private void SendEstateBlueBoxMessage(
  526. IClientAPI remote_client, UUID invoice, UUID senderID, UUID sessionID, string senderName, string message)
  527. {
  528. TriggerEstateMessage(senderID, senderName, message);
  529. }
  530. private void handleEstateDebugRegionRequest(IClientAPI remote_client, UUID invoice, UUID senderID, bool scripted, bool collisionEvents, bool physics)
  531. {
  532. if (physics)
  533. Scene.RegionInfo.RegionSettings.DisablePhysics = true;
  534. else
  535. Scene.RegionInfo.RegionSettings.DisablePhysics = false;
  536. if (scripted)
  537. Scene.RegionInfo.RegionSettings.DisableScripts = true;
  538. else
  539. Scene.RegionInfo.RegionSettings.DisableScripts = false;
  540. if (collisionEvents)
  541. Scene.RegionInfo.RegionSettings.DisableCollisions = true;
  542. else
  543. Scene.RegionInfo.RegionSettings.DisableCollisions = false;
  544. Scene.RegionInfo.RegionSettings.Save();
  545. TriggerRegionInfoChange();
  546. Scene.SetSceneCoreDebug(scripted, collisionEvents, physics);
  547. }
  548. private void handleEstateTeleportOneUserHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID, UUID prey)
  549. {
  550. if (!Scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false))
  551. return;
  552. if (prey != UUID.Zero)
  553. {
  554. ScenePresence s = Scene.GetScenePresence(prey);
  555. if (s != null)
  556. {
  557. Scene.TeleportClientHome(prey, s.ControllingClient);
  558. }
  559. }
  560. }
  561. private void handleEstateTeleportAllUsersHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID)
  562. {
  563. if (!Scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false))
  564. return;
  565. Scene.ForEachScenePresence(delegate(ScenePresence sp)
  566. {
  567. if (sp.UUID != senderID)
  568. {
  569. ScenePresence p = Scene.GetScenePresence(sp.UUID);
  570. // make sure they are still there, we could be working down a long list
  571. // Also make sure they are actually in the region
  572. if (p != null && !p.IsChildAgent)
  573. {
  574. Scene.TeleportClientHome(p.UUID, p.ControllingClient);
  575. }
  576. }
  577. });
  578. }
  579. private void AbortTerrainXferHandler(IClientAPI remoteClient, ulong XferID)
  580. {
  581. if (TerrainUploader != null)
  582. {
  583. lock (TerrainUploader)
  584. {
  585. if (XferID == TerrainUploader.XferID)
  586. {
  587. remoteClient.OnXferReceive -= TerrainUploader.XferReceive;
  588. remoteClient.OnAbortXfer -= AbortTerrainXferHandler;
  589. TerrainUploader.TerrainUploadDone -= HandleTerrainApplication;
  590. TerrainUploader = null;
  591. remoteClient.SendAlertMessage("Terrain Upload aborted by the client");
  592. }
  593. }
  594. }
  595. }
  596. private void HandleTerrainApplication(string filename, byte[] terrainData, IClientAPI remoteClient)
  597. {
  598. lock (TerrainUploader)
  599. {
  600. remoteClient.OnXferReceive -= TerrainUploader.XferReceive;
  601. remoteClient.OnAbortXfer -= AbortTerrainXferHandler;
  602. TerrainUploader.TerrainUploadDone -= HandleTerrainApplication;
  603. TerrainUploader = null;
  604. }
  605. remoteClient.SendAlertMessage("Terrain Upload Complete. Loading....");
  606. ITerrainModule terr = Scene.RequestModuleInterface<ITerrainModule>();
  607. if (terr != null)
  608. {
  609. m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + Scene.RegionInfo.RegionName);
  610. try
  611. {
  612. MemoryStream terrainStream = new MemoryStream(terrainData);
  613. terr.LoadFromStream(filename, terrainStream);
  614. terrainStream.Close();
  615. FileInfo x = new FileInfo(filename);
  616. remoteClient.SendAlertMessage("Your terrain was loaded as a " + x.Extension + " file. It may take a few moments to appear.");
  617. }
  618. catch (IOException e)
  619. {
  620. m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
  621. remoteClient.SendAlertMessage("There was an IO Exception loading your terrain. Please check free space.");
  622. return;
  623. }
  624. catch (SecurityException e)
  625. {
  626. m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
  627. remoteClient.SendAlertMessage("There was a security Exception loading your terrain. Please check the security on the simulator drive");
  628. return;
  629. }
  630. catch (UnauthorizedAccessException e)
  631. {
  632. m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
  633. remoteClient.SendAlertMessage("There was a security Exception loading your terrain. Please check the security on the simulator drive");
  634. return;
  635. }
  636. catch (Exception e)
  637. {
  638. m_log.ErrorFormat("[TERRAIN]: Error loading a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
  639. remoteClient.SendAlertMessage("There was a general error loading your terrain. Please fix the terrain file and try again");
  640. }
  641. }
  642. else
  643. {
  644. remoteClient.SendAlertMessage("Unable to apply terrain. Cannot get an instance of the terrain module");
  645. }
  646. }
  647. private void handleUploadTerrain(IClientAPI remote_client, string clientFileName)
  648. {
  649. if (TerrainUploader == null)
  650. {
  651. TerrainUploader = new EstateTerrainXferHandler(remote_client, clientFileName);
  652. lock (TerrainUploader)
  653. {
  654. remote_client.OnXferReceive += TerrainUploader.XferReceive;
  655. remote_client.OnAbortXfer += AbortTerrainXferHandler;
  656. TerrainUploader.TerrainUploadDone += HandleTerrainApplication;
  657. }
  658. TerrainUploader.RequestStartXfer(remote_client);
  659. }
  660. else
  661. {
  662. remote_client.SendAlertMessage("Another Terrain Upload is in progress. Please wait your turn!");
  663. }
  664. }
  665. private void handleTerrainRequest(IClientAPI remote_client, string clientFileName)
  666. {
  667. // Save terrain here
  668. ITerrainModule terr = Scene.RequestModuleInterface<ITerrainModule>();
  669. if (terr != null)
  670. {
  671. m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + Scene.RegionInfo.RegionName);
  672. if (File.Exists(Util.dataDir() + "/terrain.raw"))
  673. {
  674. File.Delete(Util.dataDir() + "/terrain.raw");
  675. }
  676. terr.SaveToFile(Util.dataDir() + "/terrain.raw");
  677. FileStream input = new FileStream(Util.dataDir() + "/terrain.raw", FileMode.Open);
  678. byte[] bdata = new byte[input.Length];
  679. input.Read(bdata, 0, (int)input.Length);
  680. remote_client.SendAlertMessage("Terrain file written, starting download...");
  681. Scene.XferManager.AddNewFile("terrain.raw", bdata);
  682. // Tell client about it
  683. m_log.Warn("[CLIENT]: Sending Terrain to " + remote_client.Name);
  684. remote_client.SendInitiateDownload("terrain.raw", clientFileName);
  685. }
  686. }
  687. private void HandleRegionInfoRequest(IClientAPI remote_client)
  688. {
  689. RegionInfoForEstateMenuArgs args = new RegionInfoForEstateMenuArgs();
  690. args.billableFactor = Scene.RegionInfo.EstateSettings.BillableFactor;
  691. args.estateID = Scene.RegionInfo.EstateSettings.EstateID;
  692. args.maxAgents = (byte)Scene.RegionInfo.RegionSettings.AgentLimit;
  693. args.objectBonusFactor = (float)Scene.RegionInfo.RegionSettings.ObjectBonus;
  694. args.parentEstateID = Scene.RegionInfo.EstateSettings.ParentEstateID;
  695. args.pricePerMeter = Scene.RegionInfo.EstateSettings.PricePerMeter;
  696. args.redirectGridX = Scene.RegionInfo.EstateSettings.RedirectGridX;
  697. args.redirectGridY = Scene.RegionInfo.EstateSettings.RedirectGridY;
  698. args.regionFlags = GetRegionFlags();
  699. args.simAccess = Scene.RegionInfo.AccessLevel;
  700. args.sunHour = (float)Scene.RegionInfo.RegionSettings.SunPosition;
  701. args.terrainLowerLimit = (float)Scene.RegionInfo.RegionSettings.TerrainLowerLimit;
  702. args.terrainRaiseLimit = (float)Scene.RegionInfo.RegionSettings.TerrainRaiseLimit;
  703. args.useEstateSun = Scene.RegionInfo.RegionSettings.UseEstateSun;
  704. args.waterHeight = (float)Scene.RegionInfo.RegionSettings.WaterHeight;
  705. args.simName = Scene.RegionInfo.RegionName;
  706. args.regionType = Scene.RegionInfo.RegionType;
  707. remote_client.SendRegionInfoToEstateMenu(args);
  708. }
  709. private void HandleEstateCovenantRequest(IClientAPI remote_client)
  710. {
  711. remote_client.SendEstateCovenantInformation(Scene.RegionInfo.RegionSettings.Covenant);
  712. }
  713. private void HandleLandStatRequest(int parcelID, uint reportType, uint requestFlags, string filter, IClientAPI remoteClient)
  714. {
  715. if (!Scene.Permissions.CanIssueEstateCommand(remoteClient.AgentId, false))
  716. return;
  717. Dictionary<uint, float> SceneData = new Dictionary<uint,float>();
  718. List<UUID> uuidNameLookupList = new List<UUID>();
  719. if (reportType == 1)
  720. {
  721. SceneData = Scene.PhysicsScene.GetTopColliders();
  722. }
  723. else if (reportType == 0)
  724. {
  725. SceneData = Scene.SceneGraph.GetTopScripts();
  726. }
  727. List<LandStatReportItem> SceneReport = new List<LandStatReportItem>();
  728. lock (SceneData)
  729. {
  730. foreach (uint obj in SceneData.Keys)
  731. {
  732. SceneObjectPart prt = Scene.GetSceneObjectPart(obj);
  733. if (prt != null)
  734. {
  735. SceneObjectGroup sog = prt.ParentGroup;
  736. LandStatReportItem lsri = new LandStatReportItem();
  737. lsri.LocationX = sog.AbsolutePosition.X;
  738. lsri.LocationY = sog.AbsolutePosition.Y;
  739. lsri.LocationZ = sog.AbsolutePosition.Z;
  740. lsri.Score = SceneData[obj];
  741. lsri.TaskID = sog.UUID;
  742. lsri.TaskLocalID = sog.LocalId;
  743. lsri.TaskName = sog.GetPartName(obj);
  744. lsri.OwnerName = "waiting";
  745. lock (uuidNameLookupList)
  746. uuidNameLookupList.Add(sog.OwnerID);
  747. if (filter.Length != 0)
  748. {
  749. if ((lsri.OwnerName.Contains(filter) || lsri.TaskName.Contains(filter)))
  750. {
  751. }
  752. else
  753. {
  754. continue;
  755. }
  756. }
  757. SceneReport.Add(lsri);
  758. }
  759. }
  760. }
  761. remoteClient.SendLandStatReply(reportType, requestFlags, (uint)SceneReport.Count,SceneReport.ToArray());
  762. if (uuidNameLookupList.Count > 0)
  763. LookupUUID(uuidNameLookupList);
  764. }
  765. private static void LookupUUIDSCompleted(IAsyncResult iar)
  766. {
  767. LookupUUIDS icon = (LookupUUIDS)iar.AsyncState;
  768. icon.EndInvoke(iar);
  769. }
  770. private void LookupUUID(List<UUID> uuidLst)
  771. {
  772. LookupUUIDS d = LookupUUIDsAsync;
  773. d.BeginInvoke(uuidLst,
  774. LookupUUIDSCompleted,
  775. d);
  776. }
  777. private void LookupUUIDsAsync(List<UUID> uuidLst)
  778. {
  779. UUID[] uuidarr;
  780. lock (uuidLst)
  781. {
  782. uuidarr = uuidLst.ToArray();
  783. }
  784. for (int i = 0; i < uuidarr.Length; i++)
  785. {
  786. // string lookupname = m_scene.CommsManager.UUIDNameRequestString(uuidarr[i]);
  787. IUserManagement userManager = Scene.RequestModuleInterface<IUserManagement>();
  788. if (userManager != null)
  789. userManager.GetUserName(uuidarr[i]);
  790. // we drop it. It gets cached though... so we're ready for the next request.
  791. // diva commnent 11/21/2010: uh?!? wft?
  792. // justincc comment 21/01/2011: A side effect of userManager.GetUserName() I presume.
  793. }
  794. }
  795. #endregion
  796. #region Outgoing Packets
  797. public void sendRegionInfoPacketToAll()
  798. {
  799. Scene.ForEachScenePresence(delegate(ScenePresence sp)
  800. {
  801. if (!sp.IsChildAgent)
  802. HandleRegionInfoRequest(sp.ControllingClient);
  803. });
  804. }
  805. public void sendRegionHandshake(IClientAPI remoteClient)
  806. {
  807. RegionHandshakeArgs args = new RegionHandshakeArgs();
  808. args.isEstateManager = Scene.RegionInfo.EstateSettings.IsEstateManager(remoteClient.AgentId);
  809. if (Scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero && Scene.RegionInfo.EstateSettings.EstateOwner == remoteClient.AgentId)
  810. args.isEstateManager = true;
  811. args.billableFactor = Scene.RegionInfo.EstateSettings.BillableFactor;
  812. args.terrainStartHeight0 = (float)Scene.RegionInfo.RegionSettings.Elevation1SW;
  813. args.terrainHeightRange0 = (float)Scene.RegionInfo.RegionSettings.Elevation2SW;
  814. args.terrainStartHeight1 = (float)Scene.RegionInfo.RegionSettings.Elevation1NW;
  815. args.terrainHeightRange1 = (float)Scene.RegionInfo.RegionSettings.Elevation2NW;
  816. args.terrainStartHeight2 = (float)Scene.RegionInfo.RegionSettings.Elevation1SE;
  817. args.terrainHeightRange2 = (float)Scene.RegionInfo.RegionSettings.Elevation2SE;
  818. args.terrainStartHeight3 = (float)Scene.RegionInfo.RegionSettings.Elevation1NE;
  819. args.terrainHeightRange3 = (float)Scene.RegionInfo.RegionSettings.Elevation2NE;
  820. args.simAccess = Scene.RegionInfo.AccessLevel;
  821. args.waterHeight = (float)Scene.RegionInfo.RegionSettings.WaterHeight;
  822. args.regionFlags = GetRegionFlags();
  823. args.regionName = Scene.RegionInfo.RegionName;
  824. args.SimOwner = Scene.RegionInfo.EstateSettings.EstateOwner;
  825. args.terrainBase0 = UUID.Zero;
  826. args.terrainBase1 = UUID.Zero;
  827. args.terrainBase2 = UUID.Zero;
  828. args.terrainBase3 = UUID.Zero;
  829. args.terrainDetail0 = Scene.RegionInfo.RegionSettings.TerrainTexture1;
  830. args.terrainDetail1 = Scene.RegionInfo.RegionSettings.TerrainTexture2;
  831. args.terrainDetail2 = Scene.RegionInfo.RegionSettings.TerrainTexture3;
  832. args.terrainDetail3 = Scene.RegionInfo.RegionSettings.TerrainTexture4;
  833. // m_log.DebugFormat("[ESTATE MANAGEMENT MODULE]: Sending terrain texture 1 {0} for region {1}", args.terrainDetail0, Scene.RegionInfo.RegionName);
  834. // m_log.DebugFormat("[ESTATE MANAGEMENT MODULE]: Sending terrain texture 2 {0} for region {1}", args.terrainDetail1, Scene.RegionInfo.RegionName);
  835. // m_log.DebugFormat("[ESTATE MANAGEMENT MODULE]: Sending terrain texture 3 {0} for region {1}", args.terrainDetail2, Scene.RegionInfo.RegionName);
  836. // m_log.DebugFormat("[ESTATE MANAGEMENT MODULE]: Sending terrain texture 4 {0} for region {1}", args.terrainDetail3, Scene.RegionInfo.RegionName);
  837. remoteClient.SendRegionHandshake(Scene.RegionInfo,args);
  838. }
  839. public void sendRegionHandshakeToAll()
  840. {
  841. Scene.ForEachClient(sendRegionHandshake);
  842. }
  843. public void handleEstateChangeInfo(IClientAPI remoteClient, UUID invoice, UUID senderID, UInt32 parms1, UInt32 parms2)
  844. {
  845. if (parms2 == 0)
  846. {
  847. Scene.RegionInfo.EstateSettings.UseGlobalTime = true;
  848. Scene.RegionInfo.EstateSettings.SunPosition = 0.0;
  849. }
  850. else
  851. {
  852. Scene.RegionInfo.EstateSettings.UseGlobalTime = false;
  853. Scene.RegionInfo.EstateSettings.SunPosition = (parms2 - 0x1800)/1024.0;
  854. }
  855. if ((parms1 & 0x00000010) != 0)
  856. Scene.RegionInfo.EstateSettings.FixedSun = true;
  857. else
  858. Scene.RegionInfo.EstateSettings.FixedSun = false;
  859. if ((parms1 & 0x00008000) != 0)
  860. Scene.RegionInfo.EstateSettings.PublicAccess = true;
  861. else
  862. Scene.RegionInfo.EstateSettings.PublicAccess = false;
  863. if ((parms1 & 0x10000000) != 0)
  864. Scene.RegionInfo.EstateSettings.AllowVoice = true;
  865. else
  866. Scene.RegionInfo.EstateSettings.AllowVoice = false;
  867. if ((parms1 & 0x00100000) != 0)
  868. Scene.RegionInfo.EstateSettings.AllowDirectTeleport = true;
  869. else
  870. Scene.RegionInfo.EstateSettings.AllowDirectTeleport = false;
  871. if ((parms1 & 0x00800000) != 0)
  872. Scene.RegionInfo.EstateSettings.DenyAnonymous = true;
  873. else
  874. Scene.RegionInfo.EstateSettings.DenyAnonymous = false;
  875. if ((parms1 & 0x01000000) != 0)
  876. Scene.RegionInfo.EstateSettings.DenyIdentified = true;
  877. else
  878. Scene.RegionInfo.EstateSettings.DenyIdentified = false;
  879. if ((parms1 & 0x02000000) != 0)
  880. Scene.RegionInfo.EstateSettings.DenyTransacted = true;
  881. else
  882. Scene.RegionInfo.EstateSettings.DenyTransacted = false;
  883. if ((parms1 & 0x40000000) != 0)
  884. Scene.RegionInfo.EstateSettings.DenyMinors = true;
  885. else
  886. Scene.RegionInfo.EstateSettings.DenyMinors = false;
  887. Scene.RegionInfo.EstateSettings.Save();
  888. TriggerEstateInfoChange();
  889. Scene.TriggerEstateSunUpdate();
  890. sendDetailedEstateData(remoteClient, invoice);
  891. }
  892. #endregion
  893. #region IRegionModule Members
  894. public string Name { get { return "EstateManagementModule"; } }
  895. public Type ReplaceableInterface { get { return null; } }
  896. public void Initialise(IConfigSource source) {}
  897. public void AddRegion(Scene scene)
  898. {
  899. Scene = scene;
  900. Scene.RegisterModuleInterface<IEstateModule>(this);
  901. Scene.EventManager.OnNewClient += EventManager_OnNewClient;
  902. Scene.EventManager.OnRequestChangeWaterHeight += changeWaterHeight;
  903. m_commands = new EstateManagementCommands(this);
  904. m_commands.Initialise();
  905. }
  906. public void RemoveRegion(Scene scene) {}
  907. public void RegionLoaded(Scene scene)
  908. {
  909. // Sets up the sun module based no the saved Estate and Region Settings
  910. // DO NOT REMOVE or the sun will stop working
  911. scene.TriggerEstateSunUpdate();
  912. UserManager = scene.RequestModuleInterface<IUserManagement>();
  913. }
  914. public void Close()
  915. {
  916. m_commands.Close();
  917. }
  918. #endregion
  919. #region Other Functions
  920. public void changeWaterHeight(float height)
  921. {
  922. setRegionTerrainSettings(height,
  923. (float)Scene.RegionInfo.RegionSettings.TerrainRaiseLimit,
  924. (float)Scene.RegionInfo.RegionSettings.TerrainLowerLimit,
  925. Scene.RegionInfo.RegionSettings.UseEstateSun,
  926. Scene.RegionInfo.RegionSettings.FixedSun,
  927. (float)Scene.RegionInfo.RegionSettings.SunPosition,
  928. Scene.RegionInfo.EstateSettings.UseGlobalTime,
  929. Scene.RegionInfo.EstateSettings.FixedSun,
  930. (float)Scene.RegionInfo.EstateSettings.SunPosition);
  931. sendRegionInfoPacketToAll();
  932. }
  933. #endregion
  934. private void EventManager_OnNewClient(IClientAPI client)
  935. {
  936. client.OnDetailedEstateDataRequest += sendDetailedEstateData;
  937. client.OnSetEstateFlagsRequest += estateSetRegionInfoHandler;
  938. // client.OnSetEstateTerrainBaseTexture += setEstateTerrainBaseTexture;
  939. client.OnSetEstateTerrainDetailTexture += setEstateTerrainBaseTexture;
  940. client.OnSetEstateTerrainTextureHeights += setEstateTerrainTextureHeights;
  941. client.OnCommitEstateTerrainTextureRequest += handleCommitEstateTerrainTextureRequest;
  942. client.OnSetRegionTerrainSettings += setRegionTerrainSettings;
  943. client.OnEstateRestartSimRequest += handleEstateRestartSimRequest;
  944. client.OnEstateChangeCovenantRequest += handleChangeEstateCovenantRequest;
  945. client.OnEstateChangeInfo += handleEstateChangeInfo;
  946. client.OnUpdateEstateAccessDeltaRequest += handleEstateAccessDeltaRequest;
  947. client.OnSimulatorBlueBoxMessageRequest += SendSimulatorBlueBoxMessage;
  948. client.OnEstateBlueBoxMessageRequest += SendEstateBlueBoxMessage;
  949. client.OnEstateDebugRegionRequest += handleEstateDebugRegionRequest;
  950. client.OnEstateTeleportOneUserHomeRequest += handleEstateTeleportOneUserHomeRequest;
  951. client.OnEstateTeleportAllUsersHomeRequest += handleEstateTeleportAllUsersHomeRequest;
  952. client.OnRequestTerrain += handleTerrainRequest;
  953. client.OnUploadTerrain += handleUploadTerrain;
  954. client.OnRegionInfoRequest += HandleRegionInfoRequest;
  955. client.OnEstateCovenantRequest += HandleEstateCovenantRequest;
  956. client.OnLandStatRequest += HandleLandStatRequest;
  957. sendRegionHandshake(client);
  958. }
  959. public uint GetRegionFlags()
  960. {
  961. RegionFlags flags = RegionFlags.None;
  962. // Fully implemented
  963. //
  964. if (Scene.RegionInfo.RegionSettings.AllowDamage)
  965. flags |= RegionFlags.AllowDamage;
  966. if (Scene.RegionInfo.RegionSettings.BlockTerraform)
  967. flags |= RegionFlags.BlockTerraform;
  968. if (!Scene.RegionInfo.RegionSettings.AllowLandResell)
  969. flags |= RegionFlags.BlockLandResell;
  970. if (Scene.RegionInfo.RegionSettings.DisableCollisions)
  971. flags |= RegionFlags.SkipCollisions;
  972. if (Scene.RegionInfo.RegionSettings.DisableScripts)
  973. flags |= RegionFlags.SkipScripts;
  974. if (Scene.RegionInfo.RegionSettings.DisablePhysics)
  975. flags |= RegionFlags.SkipPhysics;
  976. if (Scene.RegionInfo.RegionSettings.BlockFly)
  977. flags |= RegionFlags.NoFly;
  978. if (Scene.RegionInfo.RegionSettings.RestrictPushing)
  979. flags |= RegionFlags.RestrictPushObject;
  980. if (Scene.RegionInfo.RegionSettings.AllowLandJoinDivide)
  981. flags |= RegionFlags.AllowParcelChanges;
  982. if (Scene.RegionInfo.RegionSettings.BlockShowInSearch)
  983. flags |= RegionFlags.BlockParcelSearch;
  984. if (Scene.RegionInfo.RegionSettings.FixedSun)
  985. flags |= RegionFlags.SunFixed;
  986. if (Scene.RegionInfo.RegionSettings.Sandbox)
  987. flags |= RegionFlags.Sandbox;
  988. if (Scene.RegionInfo.EstateSettings.AllowVoice)
  989. flags |= RegionFlags.AllowVoice;
  990. // Fudge these to always on, so the menu options activate
  991. //
  992. flags |= RegionFlags.AllowLandmark;
  993. flags |= RegionFlags.AllowSetHome;
  994. // TODO: SkipUpdateInterestList
  995. // Omitted
  996. //
  997. // Omitted: NullLayer (what is that?)
  998. // Omitted: SkipAgentAction (what does it do?)
  999. return (uint)flags;
  1000. }
  1001. public uint GetEstateFlags()
  1002. {
  1003. RegionFlags flags = RegionFlags.None;
  1004. if (Scene.RegionInfo.EstateSettings.FixedSun)
  1005. flags |= RegionFlags.SunFixed;
  1006. if (Scene.RegionInfo.EstateSettings.PublicAccess)
  1007. flags |= (RegionFlags.PublicAllowed |
  1008. RegionFlags.ExternallyVisible);
  1009. if (Scene.RegionInfo.EstateSettings.AllowVoice)
  1010. flags |= RegionFlags.AllowVoice;
  1011. if (Scene.RegionInfo.EstateSettings.AllowDirectTeleport)
  1012. flags |= RegionFlags.AllowDirectTeleport;
  1013. if (Scene.RegionInfo.EstateSettings.DenyAnonymous)
  1014. flags |= RegionFlags.DenyAnonymous;
  1015. if (Scene.RegionInfo.EstateSettings.DenyIdentified)
  1016. flags |= RegionFlags.DenyIdentified;
  1017. if (Scene.RegionInfo.EstateSettings.DenyTransacted)
  1018. flags |= RegionFlags.DenyTransacted;
  1019. if (Scene.RegionInfo.EstateSettings.AbuseEmailToEstateOwner)
  1020. flags |= RegionFlags.AbuseEmailToEstateOwner;
  1021. if (Scene.RegionInfo.EstateSettings.BlockDwell)
  1022. flags |= RegionFlags.BlockDwell;
  1023. if (Scene.RegionInfo.EstateSettings.EstateSkipScripts)
  1024. flags |= RegionFlags.EstateSkipScripts;
  1025. if (Scene.RegionInfo.EstateSettings.ResetHomeOnTeleport)
  1026. flags |= RegionFlags.ResetHomeOnTeleport;
  1027. if (Scene.RegionInfo.EstateSettings.TaxFree)
  1028. flags |= RegionFlags.TaxFree;
  1029. if (Scene.RegionInfo.EstateSettings.DenyMinors)
  1030. flags |= (RegionFlags)(1 << 30);
  1031. return (uint)flags;
  1032. }
  1033. public bool IsManager(UUID avatarID)
  1034. {
  1035. if (avatarID == Scene.RegionInfo.EstateSettings.EstateOwner)
  1036. return true;
  1037. List<UUID> ems = new List<UUID>(Scene.RegionInfo.EstateSettings.EstateManagers);
  1038. if (ems.Contains(avatarID))
  1039. return true;
  1040. return false;
  1041. }
  1042. public void TriggerRegionInfoChange()
  1043. {
  1044. ChangeDelegate change = OnRegionInfoChange;
  1045. if (change != null)
  1046. change(Scene.RegionInfo.RegionID);
  1047. }
  1048. public void TriggerEstateInfoChange()
  1049. {
  1050. ChangeDelegate change = OnEstateInfoChange;
  1051. if (change != null)
  1052. change(Scene.RegionInfo.RegionID);
  1053. }
  1054. public void TriggerEstateMessage(UUID fromID, string fromName, string message)
  1055. {
  1056. MessageDelegate onmessage = OnEstateMessage;
  1057. if (onmessage != null)
  1058. onmessage(Scene.RegionInfo.RegionID, fromID, fromName, message);
  1059. }
  1060. }
  1061. }