EstateManagementModule.cs 73 KB

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