EstateManagementModule.cs 81 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958
  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.Concurrent;
  29. using System.Collections.Generic;
  30. using System.IO;
  31. using System.Linq;
  32. using System.Reflection;
  33. using System.Security;
  34. using System.Timers;
  35. using log4net;
  36. using Mono.Addins;
  37. using Nini.Config;
  38. using OpenMetaverse;
  39. using OpenMetaverse.StructuredData;
  40. using OpenSim.Framework;
  41. using OpenSim.Framework.Monitoring;
  42. using OpenSim.Region.Framework.Interfaces;
  43. using OpenSim.Region.Framework.Scenes;
  44. using OpenSim.Services.Interfaces;
  45. using RegionFlags = OpenMetaverse.RegionFlags;
  46. using Timer = System.Timers.Timer;
  47. namespace OpenSim.Region.CoreModules.World.Estate
  48. {
  49. [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EstateManagementModule")]
  50. public class EstateManagementModule : IEstateModule, INonSharedRegionModule
  51. {
  52. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  53. private Timer m_regionChangeTimer = new Timer();
  54. public Scene Scene { get; private set; }
  55. public IUserManagement UserManager { get; private set; }
  56. protected EstateManagementCommands m_commands;
  57. /// <summary>
  58. /// If false, region restart requests from the client are blocked even if they are otherwise legitimate.
  59. /// </summary>
  60. public bool AllowRegionRestartFromClient { get; set; }
  61. private bool m_ignoreEstateMinorAccessControl;
  62. private bool m_ignoreEstatePaymentAccessControl;
  63. private EstateTerrainXferHandler TerrainUploader;
  64. public TelehubManager m_Telehub;
  65. public event ChangeDelegate OnRegionInfoChange;
  66. public event ChangeDelegate OnEstateInfoChange;
  67. public event MessageDelegate OnEstateMessage;
  68. public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest;
  69. public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest;
  70. private int m_delayCount = 0;
  71. #region Region Module interface
  72. public string Name { get { return "EstateManagementModule"; } }
  73. public Type ReplaceableInterface { get { return null; } }
  74. public void Initialise(IConfigSource source)
  75. {
  76. AllowRegionRestartFromClient = true;
  77. IConfig config = source.Configs["EstateManagement"];
  78. if (config != null)
  79. {
  80. AllowRegionRestartFromClient = config.GetBoolean("AllowRegionRestartFromClient", true);
  81. m_ignoreEstateMinorAccessControl = config.GetBoolean("IgnoreEstateMinorAccessControl", true);
  82. m_ignoreEstatePaymentAccessControl = config.GetBoolean("IgnoreEstatePaymentAccessControl", true);
  83. }
  84. }
  85. public void AddRegion(Scene scene)
  86. {
  87. Scene = scene;
  88. Scene.RegisterModuleInterface<IEstateModule>(this);
  89. Scene.EventManager.OnNewClient += EventManager_OnNewClient;
  90. Scene.EventManager.OnRequestChangeWaterHeight += ChangeWaterHeight;
  91. m_Telehub = new TelehubManager(scene);
  92. m_commands = new EstateManagementCommands(this);
  93. m_commands.Initialise();
  94. m_regionChangeTimer.Interval = 10000;
  95. m_regionChangeTimer.Elapsed += RaiseRegionInfoChange;
  96. m_regionChangeTimer.AutoReset = false;
  97. }
  98. public void RemoveRegion(Scene scene) {}
  99. public void RegionLoaded(Scene scene)
  100. {
  101. UserManager = scene.RequestModuleInterface<IUserManagement>();
  102. scene.RegionInfo.EstateSettings.DoDenyMinors = !m_ignoreEstateMinorAccessControl;
  103. scene.RegionInfo.EstateSettings.DoDenyAnonymous = !m_ignoreEstatePaymentAccessControl;
  104. }
  105. public void Close()
  106. {
  107. m_commands.Close();
  108. }
  109. #endregion
  110. #region IEstateModule Functions
  111. public uint GetRegionFlags()
  112. {
  113. RegionFlags flags = RegionFlags.None;
  114. // Fully implemented
  115. //
  116. if (Scene.RegionInfo.RegionSettings.AllowDamage)
  117. flags |= RegionFlags.AllowDamage;
  118. if (Scene.RegionInfo.RegionSettings.BlockTerraform)
  119. flags |= RegionFlags.BlockTerraform;
  120. if (!Scene.RegionInfo.RegionSettings.AllowLandResell)
  121. flags |= RegionFlags.BlockLandResell;
  122. if (Scene.RegionInfo.RegionSettings.DisableCollisions)
  123. flags |= RegionFlags.SkipCollisions;
  124. if (Scene.RegionInfo.RegionSettings.DisableScripts)
  125. flags |= RegionFlags.SkipScripts;
  126. if (Scene.RegionInfo.RegionSettings.DisablePhysics)
  127. flags |= RegionFlags.SkipPhysics;
  128. if (Scene.RegionInfo.RegionSettings.BlockFly)
  129. flags |= RegionFlags.NoFly;
  130. if (Scene.RegionInfo.RegionSettings.RestrictPushing)
  131. flags |= RegionFlags.RestrictPushObject;
  132. if (Scene.RegionInfo.RegionSettings.AllowLandJoinDivide)
  133. flags |= RegionFlags.AllowParcelChanges;
  134. if (Scene.RegionInfo.RegionSettings.BlockShowInSearch)
  135. flags |= RegionFlags.BlockParcelSearch;
  136. if (Scene.RegionInfo.RegionSettings.GodBlockSearch)
  137. flags |= (RegionFlags)(1 << 11);
  138. if (Scene.RegionInfo.RegionSettings.Casino)
  139. flags |= (RegionFlags)(1 << 10);
  140. // if (Scene.RegionInfo.RegionSettings.FixedSun)
  141. // flags |= RegionFlags.SunFixed;
  142. if (Scene.RegionInfo.RegionSettings.Sandbox)
  143. flags |= RegionFlags.Sandbox;
  144. if (Scene.RegionInfo.EstateSettings.AllowVoice)
  145. flags |= RegionFlags.AllowVoice;
  146. if (Scene.RegionInfo.EstateSettings.AllowLandmark)
  147. flags |= RegionFlags.AllowLandmark;
  148. if (Scene.RegionInfo.EstateSettings.AllowSetHome)
  149. flags |= RegionFlags.AllowSetHome;
  150. if (Scene.RegionInfo.EstateSettings.BlockDwell)
  151. flags |= RegionFlags.BlockDwell;
  152. if (Scene.RegionInfo.EstateSettings.ResetHomeOnTeleport)
  153. flags |= RegionFlags.ResetHomeOnTeleport;
  154. if (Scene.RegionInfo.EstateSettings.AllowEnvironmentOverride)
  155. flags |= RegionFlags.AllowEnvironmentOverride;
  156. // TODO: SkipUpdateInterestList
  157. // Omitted
  158. //
  159. // Omitted: SkipAgentAction (what does it do?)
  160. return (uint)flags;
  161. }
  162. public bool IsManager(UUID avatarID)
  163. {
  164. if (avatarID == Scene.RegionInfo.EstateSettings.EstateOwner)
  165. return true;
  166. List<UUID> ems = new List<UUID>(Scene.RegionInfo.EstateSettings.EstateManagers);
  167. if (ems.Contains(avatarID))
  168. return true;
  169. return false;
  170. }
  171. public void sendRegionHandshakeToAll()
  172. {
  173. Scene.ForEachClient(SendRegionHandshake);
  174. }
  175. public void TriggerEstateInfoChange()
  176. {
  177. OnEstateInfoChange?.Invoke(Scene.RegionInfo.RegionID);
  178. }
  179. protected void RaiseRegionInfoChange(object sender, ElapsedEventArgs e)
  180. {
  181. OnRegionInfoChange?.Invoke(Scene.RegionInfo.RegionID);
  182. }
  183. public void TriggerRegionInfoChange()
  184. {
  185. m_regionChangeTimer.Stop();
  186. m_regionChangeTimer.Start();
  187. OnRegionInfoChange?.Invoke(Scene.RegionInfo.RegionID);
  188. }
  189. public void setEstateTerrainBaseTexture(int level, UUID texture)
  190. {
  191. SetEstateTerrainBaseTexture(null, level, texture);
  192. }
  193. public void setEstateTerrainTextureHeights(int corner, float lowValue, float highValue)
  194. {
  195. SetEstateTerrainTextureHeights(null, corner, lowValue, highValue);
  196. }
  197. public bool IsTerrainXfer(ulong xferID)
  198. {
  199. lock (this)
  200. {
  201. if (TerrainUploader == null)
  202. return false;
  203. else
  204. return TerrainUploader.XferID == xferID;
  205. }
  206. }
  207. public string SetEstateOwner(int estateID, UserAccount account)
  208. {
  209. string response;
  210. // get the current settings from DB
  211. EstateSettings dbSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
  212. if (dbSettings.EstateID == 0)
  213. {
  214. response = String.Format("No estate found with ID {0}", estateID);
  215. }
  216. else if (account.PrincipalID == dbSettings.EstateOwner)
  217. {
  218. response = String.Format("Estate already belongs to {0} ({1} {2})", account.PrincipalID, account.FirstName, account.LastName);
  219. }
  220. else
  221. {
  222. dbSettings.EstateOwner = account.PrincipalID;
  223. Scene.EstateDataService.StoreEstateSettings(dbSettings);
  224. response = String.Empty;
  225. // make sure there's a log entry to document the change
  226. m_log.InfoFormat("[ESTATE]: Estate Owner for {0} changed to {1} ({2} {3})", dbSettings.EstateName,
  227. account.PrincipalID, account.FirstName, account.LastName);
  228. // propagate the change
  229. List<UUID> regions = Scene.GetEstateRegions(estateID);
  230. UUID regionId = (regions.Count() > 0) ? regions.ElementAt(0) : UUID.Zero;
  231. if (!regionId.IsZero())
  232. {
  233. OnEstateInfoChange?.Invoke(regionId);
  234. }
  235. }
  236. return response;
  237. }
  238. public string SetEstateName(int estateID, string newName)
  239. {
  240. string response;
  241. // get the current settings from DB
  242. EstateSettings dbSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
  243. if (dbSettings.EstateID == 0)
  244. {
  245. response = String.Format("No estate found with ID {0}", estateID);
  246. }
  247. else if (newName == dbSettings.EstateName)
  248. {
  249. response = String.Format("Estate {0} is already named \"{1}\"", estateID, newName);
  250. }
  251. else
  252. {
  253. List<int> estates = Scene.EstateDataService.GetEstates(newName);
  254. if (estates.Count() > 0)
  255. {
  256. response = String.Format("An estate named \"{0}\" already exists.", newName);
  257. }
  258. else
  259. {
  260. string oldName = dbSettings.EstateName;
  261. dbSettings.EstateName = newName;
  262. Scene.EstateDataService.StoreEstateSettings(dbSettings);
  263. response = String.Empty;
  264. // make sure there's a log entry to document the change
  265. m_log.InfoFormat("[ESTATE]: Estate {0} renamed from \"{1}\" to \"{2}\"", estateID, oldName, newName);
  266. // propagate the change
  267. List<UUID> regions = Scene.GetEstateRegions(estateID);
  268. UUID regionId = (regions.Count() > 0) ? regions.ElementAt(0) : UUID.Zero;
  269. if (!regionId.IsZero())
  270. {
  271. OnEstateInfoChange?.Invoke(regionId);
  272. }
  273. }
  274. }
  275. return response;
  276. }
  277. public string SetRegionEstate(RegionInfo regionInfo, int estateID)
  278. {
  279. string response;
  280. if (regionInfo.EstateSettings.EstateID == estateID)
  281. {
  282. response = String.Format("\"{0}\" is already part of estate {1}", regionInfo.RegionName, estateID);
  283. }
  284. else
  285. {
  286. // get the current settings from DB
  287. EstateSettings dbSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
  288. if (dbSettings.EstateID == 0)
  289. {
  290. response = String.Format("No estate found with ID {0}", estateID);
  291. }
  292. else if (Scene.EstateDataService.LinkRegion(regionInfo.RegionID, estateID))
  293. {
  294. // make sure there's a log entry to document the change
  295. m_log.InfoFormat("[ESTATE]: Region {0} ({1}) moved to Estate {2} ({3}).", regionInfo.RegionID, regionInfo.RegionName, estateID, dbSettings.EstateName);
  296. // propagate the change
  297. OnEstateInfoChange?.Invoke(regionInfo.RegionID);
  298. response = String.Empty;
  299. }
  300. else
  301. {
  302. response = String.Format("Could not move \"{0}\" to estate {1}", regionInfo.RegionName, estateID);
  303. }
  304. }
  305. return response;
  306. }
  307. public string CreateEstate(string estateName, UUID ownerID)
  308. {
  309. string response;
  310. if (string.IsNullOrEmpty(estateName))
  311. {
  312. response = "No estate name specified.";
  313. }
  314. else
  315. {
  316. List<int> estates = Scene.EstateDataService.GetEstates(estateName);
  317. if (estates.Count() > 0)
  318. {
  319. response = String.Format("An estate named \"{0}\" already exists.", estateName);
  320. }
  321. else
  322. {
  323. EstateSettings settings = Scene.EstateDataService.CreateNewEstate();
  324. if (settings == null)
  325. response = String.Format("Unable to create estate \"{0}\" at this simulator", estateName);
  326. else
  327. {
  328. settings.EstateOwner = ownerID;
  329. settings.EstateName = estateName;
  330. Scene.EstateDataService.StoreEstateSettings(settings);
  331. response = String.Empty;
  332. }
  333. }
  334. }
  335. return response;
  336. }
  337. #endregion
  338. #region Packet Data Responders
  339. private void ClientSendDetailedEstateData(IClientAPI remote_client, UUID invoice)
  340. {
  341. SendDetailedEstateData(remote_client, invoice);
  342. SendEstateLists(remote_client, invoice);
  343. }
  344. private void SendDetailedEstateData(IClientAPI remote_client, UUID invoice)
  345. {
  346. UUID estateOwner;
  347. estateOwner = Scene.RegionInfo.EstateSettings.EstateOwner;
  348. remote_client.SendDetailedEstateData(invoice,
  349. Scene.RegionInfo.EstateSettings.EstateName,
  350. Scene.RegionInfo.EstateSettings.EstateID,
  351. Scene.RegionInfo.EstateSettings.ParentEstateID,
  352. GetEstateFlags(),
  353. 0,
  354. Scene.RegionInfo.RegionSettings.Covenant,
  355. (uint) Scene.RegionInfo.RegionSettings.CovenantChangedDateTime,
  356. Scene.RegionInfo.EstateSettings.AbuseEmail,
  357. estateOwner);
  358. }
  359. private void SendEstateLists(IClientAPI remote_client, UUID invoice)
  360. {
  361. remote_client.SendEstateList(invoice,
  362. (int)Constants.EstateAccessCodex.EstateManagers,
  363. Scene.RegionInfo.EstateSettings.EstateManagers,
  364. Scene.RegionInfo.EstateSettings.EstateID);
  365. remote_client.SendEstateList(invoice,
  366. (int)Constants.EstateAccessCodex.AllowedAccess,
  367. Scene.RegionInfo.EstateSettings.EstateAccess,
  368. Scene.RegionInfo.EstateSettings.EstateID);
  369. remote_client.SendEstateList(invoice,
  370. (int)Constants.EstateAccessCodex.AllowedGroups,
  371. Scene.RegionInfo.EstateSettings.EstateGroups,
  372. Scene.RegionInfo.EstateSettings.EstateID);
  373. remote_client.SendBannedUserList(invoice,
  374. Scene.RegionInfo.EstateSettings.EstateBans,
  375. Scene.RegionInfo.EstateSettings.EstateID);
  376. }
  377. private void EstateSetRegionInfoHandler(bool blockTerraform, bool noFly, bool allowDamage, bool blockLandResell, int maxAgents, float objectBonusFactor,
  378. int matureLevel, bool restrictPushObject, bool allowParcelChanges)
  379. {
  380. Scene.RegionInfo.RegionSettings.BlockTerraform = blockTerraform;
  381. Scene.RegionInfo.RegionSettings.BlockFly = noFly;
  382. Scene.RegionInfo.RegionSettings.AllowDamage = allowDamage;
  383. Scene.RegionInfo.RegionSettings.AllowLandResell = !blockLandResell;
  384. Scene.RegionInfo.RegionSettings.RestrictPushing = restrictPushObject;
  385. Scene.RegionInfo.RegionSettings.AllowLandJoinDivide = allowParcelChanges;
  386. if (maxAgents > 1 && maxAgents <= Scene.RegionInfo.AgentCapacity)
  387. Scene.RegionInfo.RegionSettings.AgentLimit = maxAgents;
  388. else
  389. Scene.RegionInfo.RegionSettings.AgentLimit = Scene.RegionInfo.AgentCapacity;
  390. Scene.RegionInfo.RegionSettings.ObjectBonus = objectBonusFactor;
  391. if (matureLevel <= 13)
  392. Scene.RegionInfo.RegionSettings.Maturity = 0;
  393. else if (matureLevel <= 21)
  394. Scene.RegionInfo.RegionSettings.Maturity = 1;
  395. else
  396. Scene.RegionInfo.RegionSettings.Maturity = 2;
  397. Scene.RegionInfo.RegionSettings.Save();
  398. TriggerRegionInfoChange();
  399. SendRegionInfoPacketToAll();
  400. }
  401. public bool SetRegionInfobyCap(OSDMap map)
  402. {
  403. if(Scene.RegionInfo == null || Scene.RegionInfo.RegionSettings == null)
  404. return false;
  405. RegionSettings es = Scene.RegionInfo.RegionSettings;
  406. OSD tmp;
  407. //if (map.TryGetValue("", out tmp) && tmp)
  408. if (map.TryGetValue("block_terraform", out tmp) && tmp is not null )
  409. es.BlockTerraform = tmp.AsBoolean();
  410. if (map.TryGetValue("block_fly", out tmp) && tmp is not null)
  411. es.BlockFly = tmp.AsBoolean();
  412. //if (map.TryGetValue("block_fly_over", out tmp) && tmp)
  413. // es.??? = tmp.AsBoolean());
  414. if (map.TryGetValue("allow_damage", out tmp) && tmp is not null)
  415. es.AllowDamage = tmp.AsBoolean();
  416. if (map.TryGetValue("allow_land_resell", out tmp) && tmp is not null)
  417. es.AllowLandResell = tmp.AsBoolean();
  418. if (map.TryGetValue("agent_limit", out tmp) && tmp is not null)
  419. {
  420. int maxagents = tmp.AsInteger();
  421. if (maxagents > 1 && maxagents <= Scene.RegionInfo.AgentCapacity)
  422. Scene.RegionInfo.RegionSettings.AgentLimit = maxagents;
  423. else
  424. Scene.RegionInfo.RegionSettings.AgentLimit = Scene.RegionInfo.AgentCapacity;
  425. }
  426. if (map.TryGetValue("prim_bonus", out tmp) && tmp is not null)
  427. es.ObjectBonus = tmp.AsInteger();
  428. if (map.TryGetValue("sim_access", out tmp) && tmp is not null)
  429. {
  430. int matureLevel = tmp.AsInteger();
  431. if (matureLevel <= 13)
  432. es.Maturity = 0;
  433. else if (matureLevel <= 21)
  434. es.Maturity = 1;
  435. else
  436. es.Maturity = 2;
  437. }
  438. if (map.TryGetValue("restrict_pushobject", out tmp) && tmp is not null)
  439. es.RestrictPushing = tmp.AsBoolean();
  440. if (map.TryGetValue("allow_parcel_changes", out tmp) && tmp is not null)
  441. es.AllowLandJoinDivide = tmp.AsBoolean();
  442. if (map.TryGetValue("block_parcel_search", out tmp) && tmp is not null)
  443. es.BlockShowInSearch = tmp.AsBoolean();
  444. Scene.RegionInfo.RegionSettings.Save();
  445. TriggerRegionInfoChange();
  446. SendRegionInfoPacketToAll();
  447. return true;
  448. }
  449. public void SetEstateTerrainBaseTexture(IClientAPI remoteClient, int level, UUID texture)
  450. {
  451. if (texture.IsZero())
  452. return;
  453. if(remoteClient is not null && (remoteClient.ViewerFlags & ViewerFlags.TPBR) != 0)
  454. {
  455. switch (level)
  456. {
  457. case 0:
  458. Scene.RegionInfo.RegionSettings.TerrainPBR1 = texture;
  459. break;
  460. case 1:
  461. Scene.RegionInfo.RegionSettings.TerrainPBR2 = texture;
  462. break;
  463. case 2:
  464. Scene.RegionInfo.RegionSettings.TerrainPBR3 = texture;
  465. break;
  466. case 3:
  467. Scene.RegionInfo.RegionSettings.TerrainPBR4 = texture;
  468. break;
  469. default:
  470. return;
  471. }
  472. }
  473. else
  474. {
  475. switch (level)
  476. {
  477. case 0:
  478. Scene.RegionInfo.RegionSettings.TerrainTexture1 = texture;
  479. break;
  480. case 1:
  481. Scene.RegionInfo.RegionSettings.TerrainTexture2 = texture;
  482. break;
  483. case 2:
  484. Scene.RegionInfo.RegionSettings.TerrainTexture3 = texture;
  485. break;
  486. case 3:
  487. Scene.RegionInfo.RegionSettings.TerrainTexture4 = texture;
  488. break;
  489. default:
  490. return;
  491. }
  492. }
  493. Scene.RegionInfo.RegionSettings.Save();
  494. TriggerRegionInfoChange();
  495. sendRegionHandshakeToAll();
  496. }
  497. public void SetEstateTerrainTextureHeights(IClientAPI client, int corner, float lowValue, float highValue)
  498. {
  499. switch (corner)
  500. {
  501. case 0:
  502. Scene.RegionInfo.RegionSettings.Elevation1SW = lowValue;
  503. Scene.RegionInfo.RegionSettings.Elevation2SW = highValue;
  504. break;
  505. case 1:
  506. Scene.RegionInfo.RegionSettings.Elevation1NW = lowValue;
  507. Scene.RegionInfo.RegionSettings.Elevation2NW = highValue;
  508. break;
  509. case 2:
  510. Scene.RegionInfo.RegionSettings.Elevation1SE = lowValue;
  511. Scene.RegionInfo.RegionSettings.Elevation2SE = highValue;
  512. break;
  513. case 3:
  514. Scene.RegionInfo.RegionSettings.Elevation1NE = lowValue;
  515. Scene.RegionInfo.RegionSettings.Elevation2NE = highValue;
  516. break;
  517. default:
  518. return;
  519. }
  520. Scene.RegionInfo.RegionSettings.Save();
  521. TriggerRegionInfoChange();
  522. sendRegionHandshakeToAll();
  523. }
  524. private void HandleCommitEstateTerrainTextureRequest(IClientAPI remoteClient)
  525. {
  526. // sendRegionHandshakeToAll();
  527. }
  528. public void SetRegionTerrainSettings(float WaterHeight,
  529. float TerrainRaiseLimit, float TerrainLowerLimit,
  530. bool UseEstateSun, bool UseFixedSun, float SunHour,
  531. bool UseGlobal, bool EstateFixedSun, float EstateSunHour)
  532. {
  533. double lastwaterlevel = Scene.RegionInfo.RegionSettings.WaterHeight;
  534. // Water Height
  535. Scene.RegionInfo.RegionSettings.WaterHeight = WaterHeight;
  536. // Terraforming limits
  537. Scene.RegionInfo.RegionSettings.TerrainRaiseLimit = TerrainRaiseLimit;
  538. Scene.RegionInfo.RegionSettings.TerrainLowerLimit = TerrainLowerLimit;
  539. // Time of day / fixed sun
  540. //Scene.RegionInfo.RegionSettings.UseEstateSun = UseEstateSun;
  541. //Scene.RegionInfo.RegionSettings.FixedSun = UseFixedSun;
  542. //Scene.RegionInfo.RegionSettings.SunPosition = SunHour;
  543. if (Scene.PhysicsEnabled && Scene.PhysicsScene != null && lastwaterlevel != WaterHeight)
  544. Scene.PhysicsScene.SetWaterLevel(WaterHeight);
  545. //m_log.Debug("[ESTATE]: UFS: " + UseFixedSun.ToString());
  546. //m_log.Debug("[ESTATE]: SunHour: " + SunHour.ToString());
  547. SendRegionInfoPacketToAll();
  548. Scene.RegionInfo.RegionSettings.Save();
  549. TriggerRegionInfoChange();
  550. }
  551. private void HandleEstateRestartSimRequest(IClientAPI remoteClient, int timeInSeconds)
  552. {
  553. if (!AllowRegionRestartFromClient)
  554. {
  555. remoteClient.SendAlertMessage("Region restart has been disabled on this simulator.");
  556. return;
  557. }
  558. IRestartModule restartModule = Scene.RequestModuleInterface<IRestartModule>();
  559. if (restartModule != null)
  560. {
  561. if (timeInSeconds == -1)
  562. {
  563. m_delayCount++;
  564. if (m_delayCount > 3)
  565. return;
  566. restartModule.DelayRestart(3600, "Restart delayed by region manager");
  567. return;
  568. }
  569. List<int> times = new List<int>();
  570. while (timeInSeconds > 0)
  571. {
  572. times.Add(timeInSeconds);
  573. if (timeInSeconds > 300)
  574. timeInSeconds -= 120;
  575. else if (timeInSeconds > 30)
  576. timeInSeconds -= 30;
  577. else
  578. timeInSeconds -= 15;
  579. }
  580. restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), false);
  581. m_log.InfoFormat(
  582. "User {0} requested restart of region {1} in {2} seconds",
  583. remoteClient.Name, Scene.Name, times.Count != 0 ? times[0] : 0);
  584. }
  585. }
  586. private void HandleChangeEstateCovenantRequest(IClientAPI remoteClient, UUID estateCovenantID)
  587. {
  588. // m_log.DebugFormat(
  589. // "[ESTATE MANAGEMENT MODULE]: Handling request from {0} to change estate covenant to {1}",
  590. // remoteClient.Name, estateCovenantID);
  591. Scene.RegionInfo.RegionSettings.Covenant = estateCovenantID;
  592. Scene.RegionInfo.RegionSettings.CovenantChangedDateTime = Util.UnixTimeSinceEpoch();
  593. Scene.RegionInfo.RegionSettings.Save();
  594. TriggerRegionInfoChange();
  595. }
  596. private readonly object deltareqLock = new object();
  597. private bool runnigDeltaExec = false;
  598. private class EstateAccessDeltaRequest
  599. {
  600. public IClientAPI remote_client;
  601. public UUID invoice;
  602. public int estateAccessType;
  603. public UUID user;
  604. }
  605. private BlockingCollection<EstateAccessDeltaRequest> deltaRequests = new BlockingCollection<EstateAccessDeltaRequest>();
  606. private void HandleEstateAccessDeltaRequest(IClientAPI _remote_client, UUID _invoice, int _estateAccessType, UUID _user)
  607. {
  608. // EstateAccessDelta handles Estate Managers, Sim Access, Sim Banlist, allowed Groups.. etc.
  609. if (_user == Scene.RegionInfo.EstateSettings.EstateOwner)
  610. return; // never process EO
  611. EstateAccessDeltaRequest newreq = new EstateAccessDeltaRequest()
  612. {
  613. remote_client = _remote_client,
  614. invoice = _invoice,
  615. estateAccessType = _estateAccessType,
  616. user = _user
  617. };
  618. deltaRequests.Add(newreq);
  619. lock(deltareqLock)
  620. {
  621. if(!runnigDeltaExec)
  622. {
  623. runnigDeltaExec = true;
  624. WorkManager.RunInThreadPool(ExecDeltaRequests,null,"execDeltaRequests");
  625. }
  626. }
  627. }
  628. private void ExecDeltaRequests(object o)
  629. {
  630. IClientAPI remote_client;
  631. UUID invoice;
  632. int estateAccessType;
  633. UUID user;
  634. Dictionary<int,EstateSettings> changed = new Dictionary<int,EstateSettings>();
  635. Dictionary<IClientAPI,UUID> sendAllowedOrBanList = new Dictionary<IClientAPI,UUID>();
  636. Dictionary<IClientAPI,UUID> sendManagers = new Dictionary<IClientAPI,UUID>();
  637. Dictionary<IClientAPI,UUID> sendGroups = new Dictionary<IClientAPI,UUID>();
  638. List<EstateSettings> otherEstates = new List<EstateSettings>();
  639. bool sentAllowedFull = false;
  640. bool sentBansFull = false;
  641. bool sentGroupsFull = false;
  642. bool sentManagersFull = false;
  643. EstateAccessDeltaRequest req;
  644. while(Scene.IsRunning)
  645. {
  646. req = null;
  647. deltaRequests.TryTake(out req, 500);
  648. if(!Scene.IsRunning)
  649. break;
  650. if(req == null)
  651. {
  652. if(changed.Count > 0)
  653. {
  654. foreach(EstateSettings est in changed.Values)
  655. Scene.EstateDataService.StoreEstateSettings(est);
  656. TriggerEstateInfoChange();
  657. }
  658. EstateSettings es = Scene.RegionInfo.EstateSettings;
  659. foreach(KeyValuePair<IClientAPI,UUID> kvp in sendAllowedOrBanList)
  660. {
  661. IClientAPI cli = kvp.Key;
  662. UUID invoive = kvp.Value;
  663. cli.SendEstateList(invoive, (int)Constants.EstateAccessCodex.AllowedAccess, es.EstateAccess, es.EstateID);
  664. cli.SendBannedUserList(invoive, es.EstateBans, es.EstateID);
  665. }
  666. sendAllowedOrBanList.Clear();
  667. foreach(KeyValuePair<IClientAPI,UUID> kvp in sendManagers)
  668. {
  669. IClientAPI cli = kvp.Key;
  670. cli.SendEstateList(kvp.Value, (int)Constants.EstateAccessCodex.EstateManagers, es.EstateManagers, es.EstateID);
  671. }
  672. foreach(KeyValuePair<IClientAPI,UUID> kvp in sendGroups)
  673. {
  674. IClientAPI cli = kvp.Key;
  675. cli.SendEstateList(kvp.Value, (int)Constants.EstateAccessCodex.AllowedGroups, es.EstateGroups, es.EstateID);
  676. }
  677. otherEstates.Clear();
  678. sendAllowedOrBanList.Clear();
  679. sendManagers.Clear();
  680. sendGroups.Clear();
  681. changed.Clear();
  682. lock(deltareqLock)
  683. {
  684. if(deltaRequests.Count != 0)
  685. continue;
  686. runnigDeltaExec = false;
  687. return;
  688. }
  689. }
  690. remote_client = req.remote_client;
  691. if(!remote_client.IsActive)
  692. continue;
  693. invoice = req.invoice;
  694. user = req.user;
  695. estateAccessType = req.estateAccessType;
  696. bool needReply = ((estateAccessType & 1024) == 0);
  697. bool doOtherEstates = ((estateAccessType & 3) != 0);
  698. EstateSettings thisSettings = Scene.RegionInfo.EstateSettings;
  699. int thisEstateID =(int)thisSettings.EstateID;
  700. UUID agentID = remote_client.AgentId;
  701. bool isadmin = Scene.Permissions.IsAdministrator(agentID);
  702. // just i case recheck rights
  703. if (!isadmin && !Scene.Permissions.IsEstateManager(agentID))
  704. {
  705. remote_client.SendAlertMessage("Method EstateAccess Failed, you don't have permissions");
  706. continue;
  707. }
  708. otherEstates.Clear();
  709. if(doOtherEstates)
  710. {
  711. UUID thisOwner = Scene.RegionInfo.EstateSettings.EstateOwner;
  712. List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(thisOwner);
  713. foreach (int estateID in estateIDs)
  714. {
  715. if (estateID == thisEstateID)
  716. continue;
  717. EstateSettings estateSettings;
  718. if(changed.ContainsKey(estateID))
  719. estateSettings = changed[estateID];
  720. else
  721. estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
  722. if(!isadmin && !estateSettings.IsEstateManagerOrOwner(agentID))
  723. continue;
  724. otherEstates.Add(estateSettings);
  725. }
  726. estateIDs.Clear();
  727. }
  728. // the commands
  729. // first the ones allowed for estate managers on this region
  730. if ((estateAccessType & 4) != 0) // User add
  731. {
  732. if(thisSettings.EstateUsersCount() >= (int)Constants.EstateAccessLimits.AllowedAccess)
  733. {
  734. if(!sentAllowedFull)
  735. {
  736. sentAllowedFull = true;
  737. remote_client.SendAlertMessage("Estate Allowed users list is full");
  738. }
  739. }
  740. else
  741. {
  742. if (doOtherEstates)
  743. {
  744. foreach (EstateSettings estateSettings in otherEstates)
  745. {
  746. if(!isadmin && !estateSettings.IsEstateManagerOrOwner(agentID))
  747. continue;
  748. if(estateSettings.EstateUsersCount() >= (int)Constants.EstateAccessLimits.AllowedAccess)
  749. continue;
  750. estateSettings.AddEstateUser(user);
  751. estateSettings.RemoveBan(user);
  752. changed[(int)estateSettings.EstateID] = estateSettings;
  753. }
  754. }
  755. thisSettings.AddEstateUser(user);
  756. thisSettings.RemoveBan(user);
  757. changed[thisEstateID] = thisSettings;
  758. if(needReply)
  759. sendAllowedOrBanList[remote_client] = invoice;
  760. }
  761. }
  762. if ((estateAccessType & 8) != 0) // User remove
  763. {
  764. if (doOtherEstates) // All estates
  765. {
  766. foreach (EstateSettings estateSettings in otherEstates)
  767. {
  768. if(!isadmin && !estateSettings.IsEstateManagerOrOwner(agentID))
  769. continue;
  770. estateSettings.RemoveEstateUser(user);
  771. changed[(int)estateSettings.EstateID] = estateSettings;
  772. }
  773. }
  774. thisSettings.RemoveEstateUser(user);
  775. changed[thisEstateID] = thisSettings;
  776. if(needReply)
  777. sendAllowedOrBanList[remote_client] = invoice;
  778. }
  779. if ((estateAccessType & 16) != 0) // Group add
  780. {
  781. if(thisSettings.EstateGroupsCount() >= (int)Constants.EstateAccessLimits.AllowedGroups)
  782. {
  783. if(!sentGroupsFull)
  784. {
  785. sentGroupsFull = true;
  786. remote_client.SendAlertMessage("Estate Allowed groups list is full");
  787. }
  788. }
  789. else
  790. {
  791. if (doOtherEstates) // All estates
  792. {
  793. foreach (EstateSettings estateSettings in otherEstates)
  794. {
  795. if(!isadmin && !estateSettings.IsEstateManagerOrOwner(agentID))
  796. continue;
  797. if(estateSettings.EstateGroupsCount() >= (int)Constants.EstateAccessLimits.AllowedGroups)
  798. continue;
  799. estateSettings.AddEstateGroup(user);
  800. changed[(int)estateSettings.EstateID] = estateSettings;
  801. }
  802. }
  803. thisSettings.AddEstateGroup(user);
  804. changed[thisEstateID] = thisSettings;
  805. sendGroups[remote_client] = invoice;
  806. }
  807. }
  808. if ((estateAccessType & 32) != 0) // Group remove
  809. {
  810. if (doOtherEstates) // All estates
  811. {
  812. foreach (EstateSettings estateSettings in otherEstates)
  813. {
  814. if(!isadmin && !estateSettings.IsEstateManagerOrOwner(agentID))
  815. continue;
  816. estateSettings.RemoveEstateGroup(user);
  817. changed[(int)estateSettings.EstateID] = estateSettings;
  818. }
  819. }
  820. thisSettings.RemoveEstateGroup(user);
  821. changed[thisEstateID] = thisSettings;
  822. sendGroups[remote_client] = invoice;
  823. }
  824. if ((estateAccessType & 64) != 0) // Ban add
  825. {
  826. if(thisSettings.EstateBansCount() >= (int)Constants.EstateAccessLimits.EstateBans)
  827. {
  828. if(!sentBansFull)
  829. {
  830. sentBansFull = true;
  831. remote_client.SendAlertMessage("Estate Ban list is full");
  832. }
  833. }
  834. else
  835. {
  836. EstateBan[] banlistcheck = Scene.RegionInfo.EstateSettings.EstateBans;
  837. bool alreadyInList = false;
  838. for (int i = 0; i < banlistcheck.Length; i++)
  839. {
  840. if (user == banlistcheck[i].BannedUserID)
  841. {
  842. alreadyInList = true;
  843. break;
  844. }
  845. }
  846. if (!alreadyInList)
  847. {
  848. if (doOtherEstates) // All estates
  849. {
  850. foreach (EstateSettings estateSettings in otherEstates)
  851. {
  852. if(!isadmin && !estateSettings.IsEstateManagerOrOwner(agentID))
  853. continue;
  854. if(estateSettings.EstateBansCount() >= (int)Constants.EstateAccessLimits.EstateBans)
  855. continue;
  856. EstateBan bitem = new EstateBan()
  857. {
  858. BannedUserID = user,
  859. EstateID = estateSettings.EstateID,
  860. BannedHostAddress = "0.0.0.0",
  861. BannedHostIPMask = "0.0.0.0",
  862. BanningUserID = remote_client.AgentId,
  863. BanTime = Util.UnixTimeSinceEpoch()
  864. };
  865. estateSettings.AddBan(bitem);
  866. estateSettings.RemoveEstateUser(user);
  867. changed[(int)estateSettings.EstateID] = estateSettings;
  868. }
  869. }
  870. EstateBan item = new EstateBan()
  871. {
  872. BannedUserID = user,
  873. EstateID = Scene.RegionInfo.EstateSettings.EstateID,
  874. BannedHostAddress = "0.0.0.0",
  875. BannedHostIPMask = "0.0.0.0",
  876. BanningUserID = remote_client.AgentId,
  877. BanTime = Util.UnixTimeSinceEpoch()
  878. };
  879. thisSettings.AddBan(item);
  880. thisSettings.RemoveEstateUser(user);
  881. changed[thisEstateID] = thisSettings;
  882. ScenePresence s = Scene.GetScenePresence(user);
  883. if (s != null)
  884. {
  885. if (!s.IsChildAgent)
  886. {
  887. if (!Scene.TeleportClientHome(user, s.ControllingClient))
  888. {
  889. s.ControllingClient.Kick("Your access to the region was revoked and TP home failed - you have been logged out.");
  890. Scene.CloseAgent(s.UUID, false);
  891. }
  892. }
  893. }
  894. }
  895. else
  896. {
  897. remote_client.SendAlertMessage("User is already on the region ban list");
  898. }
  899. //Scene.RegionInfo.regionBanlist.Add(Manager(user);
  900. if(needReply)
  901. sendAllowedOrBanList[remote_client] = invoice;
  902. }
  903. }
  904. if ((estateAccessType & 128) != 0) // Ban remove
  905. {
  906. EstateBan[] banlistcheck = Scene.RegionInfo.EstateSettings.EstateBans;
  907. bool alreadyInList = false;
  908. EstateBan listitem = null;
  909. for (int i = 0; i < banlistcheck.Length; i++)
  910. {
  911. if (user == banlistcheck[i].BannedUserID)
  912. {
  913. alreadyInList = true;
  914. listitem = banlistcheck[i];
  915. break;
  916. }
  917. }
  918. if (alreadyInList && listitem != null)
  919. {
  920. if (doOtherEstates) // All estates
  921. {
  922. foreach (EstateSettings estateSettings in otherEstates)
  923. {
  924. if(!isadmin && !estateSettings.IsEstateManagerOrOwner(agentID))
  925. continue;
  926. estateSettings.RemoveBan(user);
  927. changed[(int)estateSettings.EstateID] = estateSettings;
  928. }
  929. }
  930. thisSettings.RemoveBan(listitem.BannedUserID);
  931. changed[thisEstateID] = thisSettings;
  932. }
  933. else
  934. {
  935. remote_client.SendAlertMessage("User is not on the region ban list");
  936. }
  937. if(needReply)
  938. sendAllowedOrBanList[remote_client] = invoice;
  939. }
  940. // last the ones only for owners of this region
  941. if (!Scene.Permissions.CanIssueEstateCommand(agentID, true))
  942. {
  943. remote_client.SendAlertMessage("Method EstateAccess Failed, you don't have permissions");
  944. continue;
  945. }
  946. if ((estateAccessType & 256) != 0) // Manager add
  947. {
  948. if(thisSettings.EstateManagersCount() >= (int)Constants.EstateAccessLimits.EstateManagers)
  949. {
  950. if(!sentManagersFull)
  951. {
  952. sentManagersFull = true;
  953. remote_client.SendAlertMessage("Estate Managers list is full");
  954. }
  955. }
  956. else
  957. {
  958. if (doOtherEstates) // All estates
  959. {
  960. foreach (EstateSettings estateSettings in otherEstates)
  961. {
  962. if(!isadmin && !estateSettings.IsEstateOwner(agentID)) // redundante check?
  963. continue;
  964. if(estateSettings.EstateManagersCount() >= (int)Constants.EstateAccessLimits.EstateManagers)
  965. continue;
  966. estateSettings.AddEstateManager(user);
  967. changed[(int)estateSettings.EstateID] = estateSettings;
  968. }
  969. }
  970. thisSettings.AddEstateManager(user);
  971. changed[thisEstateID] = thisSettings;
  972. sendManagers[remote_client] = invoice;
  973. }
  974. }
  975. if ((estateAccessType & 512) != 0) // Manager remove
  976. {
  977. if (doOtherEstates) // All estates
  978. {
  979. foreach (EstateSettings estateSettings in otherEstates)
  980. {
  981. if(!isadmin && !estateSettings.IsEstateOwner(agentID))
  982. continue;
  983. estateSettings.RemoveEstateManager(user);
  984. changed[(int)estateSettings.EstateID] = estateSettings;
  985. }
  986. }
  987. thisSettings.RemoveEstateManager(user);
  988. changed[thisEstateID] = thisSettings;
  989. sendManagers[remote_client] = invoice;
  990. }
  991. }
  992. lock(deltareqLock)
  993. runnigDeltaExec = false;
  994. }
  995. public void HandleOnEstateManageTelehub(IClientAPI client, UUID invoice, UUID senderID, string cmd, uint param1)
  996. {
  997. SceneObjectPart part;
  998. switch (cmd)
  999. {
  1000. case "info ui":
  1001. break;
  1002. case "connect":
  1003. // Add the Telehub
  1004. part = Scene.GetSceneObjectPart((uint)param1);
  1005. if (part == null)
  1006. return;
  1007. SceneObjectGroup grp = part.ParentGroup;
  1008. m_Telehub.Connect(grp);
  1009. break;
  1010. case "delete":
  1011. // Disconnect Telehub
  1012. m_Telehub.Disconnect();
  1013. break;
  1014. case "spawnpoint add":
  1015. // Add SpawnPoint to the Telehub
  1016. part = Scene.GetSceneObjectPart((uint)param1);
  1017. if (part == null)
  1018. return;
  1019. m_Telehub.AddSpawnPoint(part.AbsolutePosition);
  1020. break;
  1021. case "spawnpoint remove":
  1022. // Remove SpawnPoint from Telehub
  1023. m_Telehub.RemoveSpawnPoint((int)param1);
  1024. break;
  1025. default:
  1026. break;
  1027. }
  1028. if (client != null)
  1029. SendTelehubInfo(client);
  1030. }
  1031. private void SendSimulatorBlueBoxMessage(
  1032. IClientAPI remote_client, UUID invoice, UUID senderID, UUID sessionID, string senderName, string message)
  1033. {
  1034. IDialogModule dm = Scene.RequestModuleInterface<IDialogModule>();
  1035. if (dm != null)
  1036. dm.SendNotificationToUsersInRegion(senderID, senderName, message);
  1037. }
  1038. private void SendEstateBlueBoxMessage(
  1039. IClientAPI remote_client, UUID invoice, UUID senderID, UUID sessionID, string senderName, string message)
  1040. {
  1041. TriggerEstateMessage(senderID, senderName, message);
  1042. }
  1043. private void HandleEstateDebugRegionRequest(
  1044. IClientAPI remote_client, UUID invoice, UUID senderID,
  1045. bool disableScripts, bool disableCollisions, bool disablePhysics)
  1046. {
  1047. Scene.RegionInfo.RegionSettings.DisablePhysics = disablePhysics;
  1048. Scene.RegionInfo.RegionSettings.DisableScripts = disableScripts;
  1049. Scene.RegionInfo.RegionSettings.DisableCollisions = disableCollisions;
  1050. Scene.RegionInfo.RegionSettings.Save();
  1051. TriggerRegionInfoChange();
  1052. ISceneCommandsModule scm = Scene.RequestModuleInterface<ISceneCommandsModule>();
  1053. if (scm != null)
  1054. {
  1055. scm.SetSceneDebugOptions(
  1056. new Dictionary<string, string>() {
  1057. { "scripting", (!disableScripts).ToString() },
  1058. { "collisions", (!disableCollisions).ToString() },
  1059. { "physics", (!disablePhysics).ToString() }
  1060. }
  1061. );
  1062. }
  1063. }
  1064. private void HandleEstateTeleportOneUserHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID, UUID prey, bool kick)
  1065. {
  1066. if (prey.IsZero())
  1067. return;
  1068. EstateTeleportOneUserHomeRequest evOverride = OnEstateTeleportOneUserHomeRequest;
  1069. if(evOverride != null)
  1070. {
  1071. evOverride(remover_client, invoice, senderID, prey, kick);
  1072. return;
  1073. }
  1074. if (!Scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false))
  1075. return;
  1076. ScenePresence s = Scene.GetScenePresence(prey);
  1077. if (s != null && !s.IsDeleted && !s.IsInTransit)
  1078. {
  1079. if (kick)
  1080. {
  1081. s.ControllingClient.Kick("You have been kicked");
  1082. Scene.CloseAgent(s.UUID, false);
  1083. }
  1084. else if (!Scene.TeleportClientHome(prey, s.ControllingClient))
  1085. {
  1086. s.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed ");
  1087. Scene.CloseAgent(s.UUID, false);
  1088. }
  1089. }
  1090. }
  1091. private void HandleEstateTeleportAllUsersHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID)
  1092. {
  1093. EstateTeleportAllUsersHomeRequest evOverride = OnEstateTeleportAllUsersHomeRequest;
  1094. if(evOverride != null)
  1095. {
  1096. evOverride(remover_client, invoice, senderID);
  1097. return;
  1098. }
  1099. if (!Scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false))
  1100. return;
  1101. Scene.ForEachRootClient(delegate(IClientAPI client)
  1102. {
  1103. if (client.AgentId != senderID)
  1104. {
  1105. // make sure they are still there, we could be working down a long list
  1106. // Also make sure they are actually in the region
  1107. if(Scene.TryGetScenePresence(client.AgentId, out ScenePresence p))
  1108. {
  1109. if (!Scene.TeleportClientHome(p.UUID, p.ControllingClient))
  1110. {
  1111. p.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out.");
  1112. Scene.CloseAgent(p.UUID, false);
  1113. }
  1114. }
  1115. }
  1116. });
  1117. }
  1118. private void AbortTerrainXferHandler(IClientAPI remoteClient, ulong XferID)
  1119. {
  1120. lock (this)
  1121. {
  1122. if ((TerrainUploader != null) && (XferID == TerrainUploader.XferID))
  1123. {
  1124. remoteClient.OnXferReceive -= TerrainUploader.XferReceive;
  1125. remoteClient.OnAbortXfer -= AbortTerrainXferHandler;
  1126. TerrainUploader.TerrainUploadDone -= HandleTerrainApplication;
  1127. TerrainUploader = null;
  1128. remoteClient.SendAlertMessage("Terrain Upload aborted by the client");
  1129. }
  1130. }
  1131. }
  1132. private void HandleTerrainApplication(string filename, byte[] terrainData, IClientAPI remoteClient)
  1133. {
  1134. lock (this)
  1135. {
  1136. remoteClient.OnXferReceive -= TerrainUploader.XferReceive;
  1137. remoteClient.OnAbortXfer -= AbortTerrainXferHandler;
  1138. TerrainUploader.TerrainUploadDone -= HandleTerrainApplication;
  1139. TerrainUploader = null;
  1140. }
  1141. m_log.DebugFormat("[CLIENT]: Terrain upload from {0} to {1} complete.", remoteClient.Name, Scene.Name);
  1142. remoteClient.SendAlertMessage("Terrain Upload Complete. Loading....");
  1143. ITerrainModule terr = Scene.RequestModuleInterface<ITerrainModule>();
  1144. if (terr != null)
  1145. {
  1146. try
  1147. {
  1148. using (MemoryStream terrainStream = new MemoryStream(terrainData))
  1149. terr.LoadFromStream(filename, terrainStream);
  1150. FileInfo x = new FileInfo(filename);
  1151. remoteClient.SendAlertMessage("Your terrain was loaded as a " + x.Extension + " file. It may take a few moments to appear.");
  1152. }
  1153. catch (IOException e)
  1154. {
  1155. m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
  1156. remoteClient.SendAlertMessage("There was an IO Exception loading your terrain. Please check free space.");
  1157. return;
  1158. }
  1159. catch (SecurityException e)
  1160. {
  1161. m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
  1162. remoteClient.SendAlertMessage("There was a security Exception loading your terrain. Please check the security on the simulator drive");
  1163. return;
  1164. }
  1165. catch (UnauthorizedAccessException e)
  1166. {
  1167. m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
  1168. remoteClient.SendAlertMessage("There was a security Exception loading your terrain. Please check the security on the simulator drive");
  1169. return;
  1170. }
  1171. catch (Exception e)
  1172. {
  1173. m_log.ErrorFormat("[TERRAIN]: Error loading a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
  1174. remoteClient.SendAlertMessage("There was a general error loading your terrain. Please fix the terrain file and try again");
  1175. }
  1176. }
  1177. else
  1178. {
  1179. remoteClient.SendAlertMessage("Unable to apply terrain. Cannot get an instance of the terrain module");
  1180. }
  1181. }
  1182. private void HandleUploadTerrain(IClientAPI remote_client, string clientFileName)
  1183. {
  1184. lock (this)
  1185. {
  1186. if (TerrainUploader == null)
  1187. {
  1188. m_log.DebugFormat(
  1189. "[TERRAIN]: Started receiving terrain upload for region {0} from {1}",
  1190. Scene.Name, remote_client.Name);
  1191. TerrainUploader = new EstateTerrainXferHandler(remote_client, clientFileName);
  1192. remote_client.OnXferReceive += TerrainUploader.XferReceive;
  1193. remote_client.OnAbortXfer += AbortTerrainXferHandler;
  1194. TerrainUploader.TerrainUploadDone += HandleTerrainApplication;
  1195. TerrainUploader.RequestStartXfer(remote_client);
  1196. }
  1197. else
  1198. {
  1199. remote_client.SendAlertMessage("Another Terrain Upload is in progress. Please wait your turn!");
  1200. }
  1201. }
  1202. }
  1203. private void HandleTerrainRequest(IClientAPI remote_client, string clientFileName)
  1204. {
  1205. // Save terrain here
  1206. ITerrainModule terr = Scene.RequestModuleInterface<ITerrainModule>();
  1207. if (terr != null)
  1208. {
  1209. // m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + Scene.RegionInfo.RegionName);
  1210. if (File.Exists(Util.dataDir() + "/terrain.raw"))
  1211. {
  1212. File.Delete(Util.dataDir() + "/terrain.raw");
  1213. }
  1214. terr.SaveToFile(Util.dataDir() + "/terrain.raw");
  1215. byte[] bdata;
  1216. using(FileStream input = new FileStream(Util.dataDir() + "/terrain.raw",FileMode.Open))
  1217. {
  1218. bdata = new byte[input.Length];
  1219. input.Read(bdata, 0, (int)input.Length);
  1220. }
  1221. if(bdata == null || bdata.Length == 0)
  1222. {
  1223. remote_client.SendAlertMessage("Terrain error");
  1224. return;
  1225. }
  1226. remote_client.SendAlertMessage("Terrain file written, starting download...");
  1227. string xfername = (UUID.Random()).ToString();
  1228. Scene.XferManager.AddNewFile(xfername, bdata);
  1229. m_log.DebugFormat("[CLIENT]: Sending terrain for region {0} to {1}", Scene.Name, remote_client.Name);
  1230. remote_client.SendInitiateDownload(xfername, clientFileName);
  1231. }
  1232. }
  1233. public void HandleRegionInfoRequest(IClientAPI remote_client)
  1234. {
  1235. RegionInfoForEstateMenuArgs args = new RegionInfoForEstateMenuArgs()
  1236. {
  1237. billableFactor = Scene.RegionInfo.EstateSettings.BillableFactor,
  1238. estateID = Scene.RegionInfo.EstateSettings.EstateID,
  1239. maxAgents = Scene.RegionInfo.RegionSettings.AgentLimit,
  1240. objectBonusFactor = (float)Scene.RegionInfo.RegionSettings.ObjectBonus,
  1241. parentEstateID = Scene.RegionInfo.EstateSettings.ParentEstateID,
  1242. pricePerMeter = Scene.RegionInfo.EstateSettings.PricePerMeter,
  1243. redirectGridX = Scene.RegionInfo.EstateSettings.RedirectGridX,
  1244. redirectGridY = Scene.RegionInfo.EstateSettings.RedirectGridY,
  1245. regionFlags = GetRegionFlags(),
  1246. simAccess = Scene.RegionInfo.AccessLevel,
  1247. sunHour = 0,
  1248. terrainLowerLimit = (float)Scene.RegionInfo.RegionSettings.TerrainLowerLimit,
  1249. terrainRaiseLimit = (float)Scene.RegionInfo.RegionSettings.TerrainRaiseLimit,
  1250. useEstateSun = false,
  1251. waterHeight = (float)Scene.RegionInfo.RegionSettings.WaterHeight,
  1252. simName = Scene.RegionInfo.RegionName,
  1253. regionType = Scene.RegionInfo.RegionType,
  1254. AgentCapacity = Scene.RegionInfo.AgentCapacity,
  1255. ObjectsCapacity = Scene.RegionInfo.ObjectCapacity,
  1256. };
  1257. remote_client.SendRegionInfoToEstateMenu(args);
  1258. }
  1259. private void HandleEstateCovenantRequest(IClientAPI remote_client)
  1260. {
  1261. remote_client.SendEstateCovenantInformation(Scene.RegionInfo.RegionSettings.Covenant);
  1262. }
  1263. private void HandleLandStatRequest(int parcelID, uint reportType, uint requestFlags, string filter, IClientAPI remoteClient)
  1264. {
  1265. if (reportType == 1)
  1266. {
  1267. LandCollidersStatRequest(parcelID, requestFlags, filter, remoteClient);
  1268. return;
  1269. }
  1270. if (reportType != 0)
  1271. remoteClient.SendLandStatReply(reportType, requestFlags, 0, new LandStatReportItem[0]);
  1272. IScriptModule scriptModule = Scene.RequestModuleInterface<IScriptModule>();
  1273. if (scriptModule == null)
  1274. remoteClient.SendLandStatReply(reportType, requestFlags, 0, new LandStatReportItem[0]);
  1275. ICollection<ScriptTopStatsData> sceneData = scriptModule.GetTopObjectStats(
  1276. 0.001f, 1024, out float totaltime, out float totalmemory);
  1277. if(sceneData == null || sceneData.Count == 0)
  1278. remoteClient.SendLandStatReply(0, requestFlags, 0, new LandStatReportItem[0]);
  1279. IUrlModule urlModule = Scene.RequestModuleInterface<IUrlModule>();
  1280. //reformat the name so we don't have to do it on every item
  1281. bool hasfilter = false;
  1282. if ((requestFlags & 0x0e) != 0 && !string.IsNullOrWhiteSpace(filter))
  1283. {
  1284. if ((requestFlags & 0x00000002) != 0)
  1285. {
  1286. int indx = filter.IndexOf('.');
  1287. if(indx > 0)
  1288. {
  1289. string tmp = filter.Substring(0, indx);
  1290. if(indx < filter.Length - 1)
  1291. {
  1292. tmp += " " + filter.Substring(indx +1);
  1293. }
  1294. filter = tmp;
  1295. }
  1296. }
  1297. filter.Trim();
  1298. filter = filter.ToLower();
  1299. hasfilter = filter.Length > 0;
  1300. }
  1301. var sortedSceneData = sceneData.OrderByDescending(e => e.time);
  1302. int items = 0;
  1303. List<LandStatReportItem> SceneReport = new List<LandStatReportItem>();
  1304. foreach (var entry in sortedSceneData)
  1305. {
  1306. // The object may have been deleted since we received the data.
  1307. SceneObjectPart sop = Scene.GetSceneObjectPart(entry.localID);
  1308. if(sop == null)
  1309. continue;
  1310. SceneObjectGroup so = sop.ParentGroup;
  1311. if (so == null || so.IsDeleted || so.inTransit)
  1312. continue;
  1313. int urls_used = 0;
  1314. if (urlModule != null)
  1315. {
  1316. urls_used = urlModule.GetUrlCount(sop.UUID);
  1317. // Don't show scripts that haven't executed or where execution time is below one microsecond in
  1318. // order to produce a more readable report.
  1319. // Unless they are using URLs or using 1024 bytes or more.
  1320. if (entry.time < 0.001 && entry.memory < 1024 && urls_used == 0)
  1321. continue;
  1322. }
  1323. else if (entry.time < 0.001 && entry.memory < 1024)
  1324. continue;
  1325. ILandObject land = Scene.LandChannel.GetLandObject(so.AbsolutePosition);
  1326. if((requestFlags & 1) != 0 && land.LandData.LocalID != parcelID)
  1327. continue;
  1328. string owner_name = UserManager.GetUserName(so.OwnerID);
  1329. string task_name = so.Name;
  1330. string parcel_name = land != null ? land.LandData.Name : "unknown";
  1331. if (hasfilter)
  1332. {
  1333. if ((requestFlags & 0x00000002) != 0)
  1334. {
  1335. if (!owner_name.ToLower().Contains(filter))
  1336. continue;
  1337. }
  1338. else if ((requestFlags & 0x00000004) != 0)
  1339. {
  1340. if (!task_name.ToLower().Contains(filter))
  1341. continue;
  1342. }
  1343. else if ((requestFlags & 0x00000008) != 0)
  1344. {
  1345. if (!parcel_name.ToLower().Contains(filter))
  1346. continue;
  1347. }
  1348. }
  1349. LandStatReportItem lsri = new LandStatReportItem()
  1350. {
  1351. LocationX = so.AbsolutePosition.X,
  1352. LocationY = so.AbsolutePosition.Y,
  1353. LocationZ = so.AbsolutePosition.Z,
  1354. Score = entry.time,
  1355. TaskID = so.UUID,
  1356. TaskLocalID = so.LocalId,
  1357. TaskName = task_name,
  1358. OwnerName = owner_name,
  1359. OwnerID = so.OwnerID,
  1360. Bytes = entry.memory,
  1361. Urls = urls_used,
  1362. Time = Utils.DateTimeToUnixTime(sop.Rezzed),
  1363. Parcel = parcel_name
  1364. };
  1365. items++;
  1366. SceneReport.Add(lsri);
  1367. if (items >= 100)
  1368. break;
  1369. }
  1370. remoteClient.SendLandStatReply(0, requestFlags, (uint)SceneReport.Count,SceneReport.ToArray());
  1371. }
  1372. private void LandCollidersStatRequest(int parcelID, uint requestFlags, string filter, IClientAPI remoteClient)
  1373. {
  1374. if (!Scene.Permissions.CanIssueEstateCommand(remoteClient.AgentId, false))
  1375. remoteClient.SendLandStatReply(1, requestFlags, 0, new LandStatReportItem[0]);
  1376. Dictionary<uint, float> sceneData = Scene.PhysicsScene.GetTopColliders();
  1377. List<LandStatReportItem> SceneReport = new List<LandStatReportItem>();
  1378. if (sceneData != null)
  1379. {
  1380. //reformat the name so we don't have to do it on every item
  1381. bool hasfilter = false;
  1382. if ((requestFlags & 0x0c) != 0 && !string.IsNullOrWhiteSpace(filter))
  1383. {
  1384. if ((requestFlags & 0x00000002) != 0)
  1385. {
  1386. int indx = filter.IndexOf('.');
  1387. if (indx > 0)
  1388. {
  1389. string tmp = filter.Substring(0, indx);
  1390. if (indx < filter.Length - 1)
  1391. {
  1392. tmp += " " + filter.Substring(indx + 1);
  1393. }
  1394. filter = tmp;
  1395. }
  1396. }
  1397. filter.Trim();
  1398. filter = filter.ToLower();
  1399. hasfilter = filter.Length > 0;
  1400. }
  1401. int items = 0;
  1402. foreach (KeyValuePair<uint,float> kvp in sceneData)
  1403. {
  1404. if (kvp.Value < 0.001)
  1405. continue;
  1406. // The object may have been deleted since we received the data.
  1407. SceneObjectPart sop = Scene.GetSceneObjectPart(kvp.Key);
  1408. if(sop == null)
  1409. continue;
  1410. SceneObjectGroup so = sop.ParentGroup;
  1411. if (so == null || so.IsDeleted || so.inTransit)
  1412. continue;
  1413. // Don't show scripts that haven't executed or where execution time is below one microsecond in
  1414. // order to produce a more readable report.
  1415. // Unless they are using URLs or using 1024 bytes or more.
  1416. ILandObject land = Scene.LandChannel.GetLandObject(so.AbsolutePosition);
  1417. if ((requestFlags & 1) != 0 && land.LandData.LocalID != parcelID)
  1418. continue;
  1419. string owner_name = UserManager.GetUserName(so.OwnerID);
  1420. string task_name = so.Name;
  1421. string parcel_name = land != null ? land.LandData.Name : "unknown";
  1422. if (hasfilter)
  1423. {
  1424. if ((requestFlags & 0x00000002) != 0)
  1425. {
  1426. if (!owner_name.ToLower().Contains(filter))
  1427. continue;
  1428. }
  1429. else if ((requestFlags & 0x00000004) != 0)
  1430. {
  1431. if (!task_name.ToLower().Contains(filter))
  1432. continue;
  1433. }
  1434. else if ((requestFlags & 0x00000008) != 0)
  1435. {
  1436. if (!parcel_name.ToLower().Contains(filter))
  1437. continue;
  1438. }
  1439. }
  1440. LandStatReportItem lsri = new LandStatReportItem()
  1441. {
  1442. LocationX = so.AbsolutePosition.X,
  1443. LocationY = so.AbsolutePosition.Y,
  1444. LocationZ = so.AbsolutePosition.Z,
  1445. Score = kvp.Value,
  1446. TaskID = so.UUID,
  1447. TaskLocalID = so.LocalId,
  1448. TaskName = task_name,
  1449. OwnerName = owner_name,
  1450. OwnerID = so.OwnerID,
  1451. Time = Utils.DateTimeToUnixTime(sop.Rezzed),
  1452. Parcel = parcel_name
  1453. };
  1454. items++;
  1455. SceneReport.Add(lsri);
  1456. if (items >= 100)
  1457. break;
  1458. }
  1459. }
  1460. remoteClient.SendLandStatReply(1, requestFlags, (uint)SceneReport.Count, SceneReport.ToArray());
  1461. }
  1462. #endregion
  1463. #region Outgoing Packets
  1464. public void SendRegionInfoPacketToAll()
  1465. {
  1466. // Scene.ForEachRootClient(delegate(IClientAPI client)
  1467. Scene.ForEachClient(delegate(IClientAPI client)
  1468. {
  1469. HandleRegionInfoRequest(client);
  1470. });
  1471. }
  1472. public void SendRegionHandshake(IClientAPI remoteClient)
  1473. {
  1474. remoteClient.SendRegionHandshake();
  1475. }
  1476. public void HandleEstateChangeInfo(IClientAPI remoteClient, UUID invoice, UUID senderID, UInt32 parms1, UInt32 parms2)
  1477. {
  1478. bool lastallowEnvOvr = Scene.RegionInfo.EstateSettings.AllowEnvironmentOverride;
  1479. if ((parms1 & 0x00008000) != 0)
  1480. Scene.RegionInfo.EstateSettings.PublicAccess = true;
  1481. else
  1482. Scene.RegionInfo.EstateSettings.PublicAccess = false;
  1483. // taxfree is now !AllowAccessOverride (note the negate)
  1484. if ((parms1 & 0x00000020) != 0)
  1485. Scene.RegionInfo.EstateSettings.TaxFree = false;
  1486. else
  1487. Scene.RegionInfo.EstateSettings.TaxFree = true;
  1488. if ((parms1 & 0x00000200) != 0)
  1489. Scene.RegionInfo.EstateSettings.AllowEnvironmentOverride = true;
  1490. else
  1491. Scene.RegionInfo.EstateSettings.AllowEnvironmentOverride = false;
  1492. if ((parms1 & 0x00100000) != 0)
  1493. Scene.RegionInfo.EstateSettings.AllowDirectTeleport = true;
  1494. else
  1495. Scene.RegionInfo.EstateSettings.AllowDirectTeleport = false;
  1496. if ((parms1 & 0x00800000) != 0)
  1497. Scene.RegionInfo.EstateSettings.DenyAnonymous = true;
  1498. else
  1499. Scene.RegionInfo.EstateSettings.DenyAnonymous = false;
  1500. // no longer in used, may be reassigned
  1501. if ((parms1 & 0x01000000) != 0)
  1502. Scene.RegionInfo.EstateSettings.DenyIdentified = true;
  1503. else
  1504. Scene.RegionInfo.EstateSettings.DenyIdentified = false;
  1505. // no longer in used, may be reassigned
  1506. if ((parms1 & 0x02000000) != 0)
  1507. Scene.RegionInfo.EstateSettings.DenyTransacted = true;
  1508. else
  1509. Scene.RegionInfo.EstateSettings.DenyTransacted = false;
  1510. if ((parms1 & 0x10000000) != 0)
  1511. Scene.RegionInfo.EstateSettings.AllowVoice = true;
  1512. else
  1513. Scene.RegionInfo.EstateSettings.AllowVoice = false;
  1514. if ((parms1 & 0x40000000) != 0)
  1515. Scene.RegionInfo.EstateSettings.DenyMinors = true;
  1516. else
  1517. Scene.RegionInfo.EstateSettings.DenyMinors = false;
  1518. Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
  1519. if (lastallowEnvOvr && Scene.LandChannel != null && !Scene.RegionInfo.EstateSettings.AllowEnvironmentOverride)
  1520. {
  1521. Scene.ClearAllParcelEnvironments();
  1522. }
  1523. TriggerEstateInfoChange();
  1524. SendDetailedEstateData(remoteClient, invoice);
  1525. }
  1526. public bool handleEstateChangeInfoCap(string estateName, UUID invoice,
  1527. bool externallyVisible,
  1528. bool allowDirectTeleport,
  1529. bool denyAnonymous, bool denyAgeUnverified,
  1530. bool alloVoiceChat, bool overridePublicAccess,
  1531. bool allowEnvironmentOverride)
  1532. {
  1533. bool lastallowEnvOvr = Scene.RegionInfo.EstateSettings.AllowEnvironmentOverride;
  1534. Scene.RegionInfo.EstateSettings.PublicAccess = externallyVisible;
  1535. Scene.RegionInfo.EstateSettings.AllowDirectTeleport = allowDirectTeleport;
  1536. Scene.RegionInfo.EstateSettings.DenyAnonymous = denyAnonymous;
  1537. Scene.RegionInfo.EstateSettings.AllowVoice = alloVoiceChat;
  1538. // taxfree is now !AllowAccessOverride
  1539. Scene.RegionInfo.EstateSettings.TaxFree = overridePublicAccess;
  1540. Scene.RegionInfo.EstateSettings.DenyMinors = denyAgeUnverified;
  1541. Scene.RegionInfo.EstateSettings.AllowEnvironmentOverride = allowEnvironmentOverride;
  1542. Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
  1543. if(lastallowEnvOvr && !allowEnvironmentOverride)
  1544. Scene.ClearAllParcelEnvironments();
  1545. TriggerEstateInfoChange();
  1546. return true;
  1547. }
  1548. #endregion
  1549. #region Other Functions
  1550. public void ChangeWaterHeight(float height)
  1551. {
  1552. SetRegionTerrainSettings(height,
  1553. (float)Scene.RegionInfo.RegionSettings.TerrainRaiseLimit,
  1554. (float)Scene.RegionInfo.RegionSettings.TerrainLowerLimit,
  1555. Scene.RegionInfo.RegionSettings.UseEstateSun,
  1556. Scene.RegionInfo.RegionSettings.FixedSun,
  1557. (float)Scene.RegionInfo.RegionSettings.SunPosition,
  1558. //Scene.RegionInfo.EstateSettings.UseGlobalTime,
  1559. false,
  1560. //Scene.RegionInfo.EstateSettings.FixedSun,
  1561. false,
  1562. (float)Scene.RegionInfo.EstateSettings.SunPosition);
  1563. // sendRegionInfoPacketToAll(); already done by setRegionTerrainSettings
  1564. }
  1565. #endregion
  1566. private void EventManager_OnNewClient(IClientAPI client)
  1567. {
  1568. client.OnDetailedEstateDataRequest += ClientSendDetailedEstateData;
  1569. client.OnSetEstateFlagsRequest += EstateSetRegionInfoHandler;
  1570. client.OnSetEstateTerrainDetailTexture += SetEstateTerrainBaseTexture;
  1571. client.OnSetEstateTerrainTextureHeights += SetEstateTerrainTextureHeights;
  1572. client.OnCommitEstateTerrainTextureRequest += HandleCommitEstateTerrainTextureRequest;
  1573. client.OnSetRegionTerrainSettings += SetRegionTerrainSettings;
  1574. client.OnEstateRestartSimRequest += HandleEstateRestartSimRequest;
  1575. client.OnEstateChangeCovenantRequest += HandleChangeEstateCovenantRequest;
  1576. client.OnEstateChangeInfo += HandleEstateChangeInfo;
  1577. client.OnEstateManageTelehub += HandleOnEstateManageTelehub;
  1578. client.OnUpdateEstateAccessDeltaRequest += HandleEstateAccessDeltaRequest;
  1579. client.OnSimulatorBlueBoxMessageRequest += SendSimulatorBlueBoxMessage;
  1580. client.OnEstateBlueBoxMessageRequest += SendEstateBlueBoxMessage;
  1581. client.OnEstateDebugRegionRequest += HandleEstateDebugRegionRequest;
  1582. client.OnEstateTeleportOneUserHomeRequest += HandleEstateTeleportOneUserHomeRequest;
  1583. client.OnEstateTeleportAllUsersHomeRequest += HandleEstateTeleportAllUsersHomeRequest;
  1584. client.OnRequestTerrain += HandleTerrainRequest;
  1585. client.OnUploadTerrain += HandleUploadTerrain;
  1586. client.OnRegionInfoRequest += HandleRegionInfoRequest;
  1587. client.OnEstateCovenantRequest += HandleEstateCovenantRequest;
  1588. client.OnLandStatRequest += HandleLandStatRequest;
  1589. }
  1590. public uint GetEstateFlags()
  1591. {
  1592. RegionFlags flags = RegionFlags.None;
  1593. if (Scene.RegionInfo.EstateSettings.AllowLandmark)
  1594. flags |= RegionFlags.AllowLandmark;
  1595. if (Scene.RegionInfo.EstateSettings.AllowSetHome)
  1596. flags |= RegionFlags.AllowSetHome;
  1597. if (Scene.RegionInfo.EstateSettings.ResetHomeOnTeleport)
  1598. flags |= RegionFlags.ResetHomeOnTeleport;
  1599. //if (Scene.RegionInfo.EstateSettings.FixedSun)
  1600. // flags |= RegionFlags.SunFixed;
  1601. if (!Scene.RegionInfo.EstateSettings.TaxFree) // this is now wrong means !ALLOW_ACCESS_OVERRIDE
  1602. flags |= RegionFlags.AllowParcelAccessOverride;
  1603. if (Scene.RegionInfo.EstateSettings.PublicAccess) //??
  1604. flags |= (RegionFlags.PublicAllowed | RegionFlags.ExternallyVisible);
  1605. if (Scene.RegionInfo.EstateSettings.BlockDwell)
  1606. flags |= RegionFlags.BlockDwell;
  1607. if (Scene.RegionInfo.EstateSettings.AllowDirectTeleport)
  1608. flags |= RegionFlags.AllowDirectTeleport;
  1609. if (Scene.RegionInfo.EstateSettings.EstateSkipScripts)
  1610. flags |= RegionFlags.EstateSkipScripts;
  1611. if (Scene.RegionInfo.EstateSettings.DenyAnonymous)
  1612. flags |= RegionFlags.DenyAnonymous;
  1613. if (Scene.RegionInfo.EstateSettings.DenyIdentified) // unused?
  1614. flags |= RegionFlags.DenyIdentified;
  1615. if (Scene.RegionInfo.EstateSettings.DenyTransacted) // unused?
  1616. flags |= RegionFlags.DenyTransacted;
  1617. if (Scene.RegionInfo.EstateSettings.AllowParcelChanges)
  1618. flags |= RegionFlags.AllowParcelChanges;
  1619. if (Scene.RegionInfo.EstateSettings.AbuseEmailToEstateOwner) // now is block fly
  1620. flags |= RegionFlags.AbuseEmailToEstateOwner;
  1621. if (Scene.RegionInfo.EstateSettings.AllowVoice)
  1622. flags |= RegionFlags.AllowVoice;
  1623. if (Scene.RegionInfo.EstateSettings.DenyMinors)
  1624. flags |= RegionFlags.DenyAgeUnverified;
  1625. if (Scene.RegionInfo.EstateSettings.AllowEnvironmentOverride)
  1626. flags |= RegionFlags.AllowEnvironmentOverride;
  1627. return (uint)flags;
  1628. }
  1629. public void TriggerEstateMessage(UUID fromID, string fromName, string message)
  1630. {
  1631. OnEstateMessage?.Invoke(Scene.RegionInfo.RegionID, fromID, fromName, message);
  1632. }
  1633. private void SendTelehubInfo(IClientAPI client)
  1634. {
  1635. RegionSettings settings =
  1636. this.Scene.RegionInfo.RegionSettings;
  1637. SceneObjectGroup telehub = null;
  1638. if (!settings.TelehubObject.IsZero() &&
  1639. (telehub = Scene.GetSceneObjectGroup(settings.TelehubObject)) != null)
  1640. {
  1641. List<Vector3> spawnPoints = new List<Vector3>();
  1642. foreach (SpawnPoint sp in settings.SpawnPoints())
  1643. {
  1644. spawnPoints.Add(sp.GetLocation(Vector3.Zero, Quaternion.Identity));
  1645. }
  1646. client.SendTelehubInfo(settings.TelehubObject,
  1647. telehub.Name,
  1648. telehub.AbsolutePosition,
  1649. telehub.GroupRotation,
  1650. spawnPoints);
  1651. }
  1652. else
  1653. {
  1654. client.SendTelehubInfo(UUID.Zero,
  1655. String.Empty,
  1656. Vector3.Zero,
  1657. Quaternion.Identity,
  1658. new List<Vector3>());
  1659. }
  1660. }
  1661. }
  1662. }