EstateManagementModule.cs 73 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758
  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)
  1020. {
  1021. EstateTeleportOneUserHomeRequest evOverride = OnEstateTeleportOneUserHomeRequest;
  1022. if(evOverride != null)
  1023. {
  1024. evOverride(remover_client, invoice, senderID, prey);
  1025. return;
  1026. }
  1027. if (!Scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false))
  1028. return;
  1029. if (prey != UUID.Zero)
  1030. {
  1031. ScenePresence s = Scene.GetScenePresence(prey);
  1032. if (s != null && !s.IsDeleted && !s.IsInTransit)
  1033. {
  1034. if (!Scene.TeleportClientHome(prey, s.ControllingClient))
  1035. {
  1036. s.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out.");
  1037. Scene.CloseAgent(s.UUID, false);
  1038. }
  1039. }
  1040. }
  1041. }
  1042. private void handleEstateTeleportAllUsersHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID)
  1043. {
  1044. EstateTeleportAllUsersHomeRequest evOverride = OnEstateTeleportAllUsersHomeRequest;
  1045. if(evOverride != null)
  1046. {
  1047. evOverride(remover_client, invoice, senderID);
  1048. return;
  1049. }
  1050. if (!Scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false))
  1051. return;
  1052. Scene.ForEachRootClient(delegate(IClientAPI client)
  1053. {
  1054. if (client.AgentId != senderID)
  1055. {
  1056. // make sure they are still there, we could be working down a long list
  1057. // Also make sure they are actually in the region
  1058. ScenePresence p;
  1059. if(Scene.TryGetScenePresence(client.AgentId, out p))
  1060. {
  1061. if (!Scene.TeleportClientHome(p.UUID, p.ControllingClient))
  1062. {
  1063. p.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out.");
  1064. Scene.CloseAgent(p.UUID, false);
  1065. }
  1066. }
  1067. }
  1068. });
  1069. }
  1070. private void AbortTerrainXferHandler(IClientAPI remoteClient, ulong XferID)
  1071. {
  1072. lock (this)
  1073. {
  1074. if ((TerrainUploader != null) && (XferID == TerrainUploader.XferID))
  1075. {
  1076. remoteClient.OnXferReceive -= TerrainUploader.XferReceive;
  1077. remoteClient.OnAbortXfer -= AbortTerrainXferHandler;
  1078. TerrainUploader.TerrainUploadDone -= HandleTerrainApplication;
  1079. TerrainUploader = null;
  1080. remoteClient.SendAlertMessage("Terrain Upload aborted by the client");
  1081. }
  1082. }
  1083. }
  1084. private void HandleTerrainApplication(string filename, byte[] terrainData, IClientAPI remoteClient)
  1085. {
  1086. lock (this)
  1087. {
  1088. remoteClient.OnXferReceive -= TerrainUploader.XferReceive;
  1089. remoteClient.OnAbortXfer -= AbortTerrainXferHandler;
  1090. TerrainUploader.TerrainUploadDone -= HandleTerrainApplication;
  1091. TerrainUploader = null;
  1092. }
  1093. m_log.DebugFormat("[CLIENT]: Terrain upload from {0} to {1} complete.", remoteClient.Name, Scene.Name);
  1094. remoteClient.SendAlertMessage("Terrain Upload Complete. Loading....");
  1095. ITerrainModule terr = Scene.RequestModuleInterface<ITerrainModule>();
  1096. if (terr != null)
  1097. {
  1098. try
  1099. {
  1100. using (MemoryStream terrainStream = new MemoryStream(terrainData))
  1101. terr.LoadFromStream(filename, terrainStream);
  1102. FileInfo x = new FileInfo(filename);
  1103. remoteClient.SendAlertMessage("Your terrain was loaded as a " + x.Extension + " file. It may take a few moments to appear.");
  1104. }
  1105. catch (IOException e)
  1106. {
  1107. m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
  1108. remoteClient.SendAlertMessage("There was an IO Exception loading your terrain. Please check free space.");
  1109. return;
  1110. }
  1111. catch (SecurityException e)
  1112. {
  1113. m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
  1114. remoteClient.SendAlertMessage("There was a security Exception loading your terrain. Please check the security on the simulator drive");
  1115. return;
  1116. }
  1117. catch (UnauthorizedAccessException e)
  1118. {
  1119. m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
  1120. remoteClient.SendAlertMessage("There was a security Exception loading your terrain. Please check the security on the simulator drive");
  1121. return;
  1122. }
  1123. catch (Exception e)
  1124. {
  1125. m_log.ErrorFormat("[TERRAIN]: Error loading a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
  1126. remoteClient.SendAlertMessage("There was a general error loading your terrain. Please fix the terrain file and try again");
  1127. }
  1128. }
  1129. else
  1130. {
  1131. remoteClient.SendAlertMessage("Unable to apply terrain. Cannot get an instance of the terrain module");
  1132. }
  1133. }
  1134. private void handleUploadTerrain(IClientAPI remote_client, string clientFileName)
  1135. {
  1136. lock (this)
  1137. {
  1138. if (TerrainUploader == null)
  1139. {
  1140. m_log.DebugFormat(
  1141. "[TERRAIN]: Started receiving terrain upload for region {0} from {1}",
  1142. Scene.Name, remote_client.Name);
  1143. TerrainUploader = new EstateTerrainXferHandler(remote_client, clientFileName);
  1144. remote_client.OnXferReceive += TerrainUploader.XferReceive;
  1145. remote_client.OnAbortXfer += AbortTerrainXferHandler;
  1146. TerrainUploader.TerrainUploadDone += HandleTerrainApplication;
  1147. TerrainUploader.RequestStartXfer(remote_client);
  1148. }
  1149. else
  1150. {
  1151. remote_client.SendAlertMessage("Another Terrain Upload is in progress. Please wait your turn!");
  1152. }
  1153. }
  1154. }
  1155. private void handleTerrainRequest(IClientAPI remote_client, string clientFileName)
  1156. {
  1157. // Save terrain here
  1158. ITerrainModule terr = Scene.RequestModuleInterface<ITerrainModule>();
  1159. if (terr != null)
  1160. {
  1161. // m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + Scene.RegionInfo.RegionName);
  1162. if (File.Exists(Util.dataDir() + "/terrain.raw"))
  1163. {
  1164. File.Delete(Util.dataDir() + "/terrain.raw");
  1165. }
  1166. terr.SaveToFile(Util.dataDir() + "/terrain.raw");
  1167. byte[] bdata;
  1168. using(FileStream input = new FileStream(Util.dataDir() + "/terrain.raw",FileMode.Open))
  1169. {
  1170. bdata = new byte[input.Length];
  1171. input.Read(bdata, 0, (int)input.Length);
  1172. }
  1173. if(bdata == null || bdata.Length == 0)
  1174. {
  1175. remote_client.SendAlertMessage("Terrain error");
  1176. return;
  1177. }
  1178. remote_client.SendAlertMessage("Terrain file written, starting download...");
  1179. string xfername = (UUID.Random()).ToString();
  1180. Scene.XferManager.AddNewFile(xfername, bdata);
  1181. m_log.DebugFormat("[CLIENT]: Sending terrain for region {0} to {1}", Scene.Name, remote_client.Name);
  1182. remote_client.SendInitiateDownload(xfername, clientFileName);
  1183. }
  1184. }
  1185. private void HandleRegionInfoRequest(IClientAPI remote_client)
  1186. {
  1187. RegionInfoForEstateMenuArgs args = new RegionInfoForEstateMenuArgs();
  1188. args.billableFactor = Scene.RegionInfo.EstateSettings.BillableFactor;
  1189. args.estateID = Scene.RegionInfo.EstateSettings.EstateID;
  1190. args.maxAgents = (byte)Scene.RegionInfo.RegionSettings.AgentLimit;
  1191. args.objectBonusFactor = (float)Scene.RegionInfo.RegionSettings.ObjectBonus;
  1192. args.parentEstateID = Scene.RegionInfo.EstateSettings.ParentEstateID;
  1193. args.pricePerMeter = Scene.RegionInfo.EstateSettings.PricePerMeter;
  1194. args.redirectGridX = Scene.RegionInfo.EstateSettings.RedirectGridX;
  1195. args.redirectGridY = Scene.RegionInfo.EstateSettings.RedirectGridY;
  1196. args.regionFlags = GetRegionFlags();
  1197. args.simAccess = Scene.RegionInfo.AccessLevel;
  1198. args.sunHour = (float)Scene.RegionInfo.RegionSettings.SunPosition;
  1199. args.terrainLowerLimit = (float)Scene.RegionInfo.RegionSettings.TerrainLowerLimit;
  1200. args.terrainRaiseLimit = (float)Scene.RegionInfo.RegionSettings.TerrainRaiseLimit;
  1201. args.useEstateSun = Scene.RegionInfo.RegionSettings.UseEstateSun;
  1202. args.waterHeight = (float)Scene.RegionInfo.RegionSettings.WaterHeight;
  1203. args.simName = Scene.RegionInfo.RegionName;
  1204. args.regionType = Scene.RegionInfo.RegionType;
  1205. remote_client.SendRegionInfoToEstateMenu(args);
  1206. }
  1207. private void HandleEstateCovenantRequest(IClientAPI remote_client)
  1208. {
  1209. remote_client.SendEstateCovenantInformation(Scene.RegionInfo.RegionSettings.Covenant);
  1210. }
  1211. private void HandleLandStatRequest(int parcelID, uint reportType, uint requestFlags, string filter, IClientAPI remoteClient)
  1212. {
  1213. if (!Scene.Permissions.CanIssueEstateCommand(remoteClient.AgentId, false))
  1214. return;
  1215. Dictionary<uint, float> sceneData = null;
  1216. if (reportType == 1)
  1217. {
  1218. sceneData = Scene.PhysicsScene.GetTopColliders();
  1219. }
  1220. else if (reportType == 0)
  1221. {
  1222. IScriptModule scriptModule = Scene.RequestModuleInterface<IScriptModule>();
  1223. if (scriptModule != null)
  1224. sceneData = scriptModule.GetObjectScriptsExecutionTimes();
  1225. }
  1226. List<LandStatReportItem> SceneReport = new List<LandStatReportItem>();
  1227. if (sceneData != null)
  1228. {
  1229. var sortedSceneData
  1230. = sceneData.Select(
  1231. item => new { Measurement = item.Value, Part = Scene.GetSceneObjectPart(item.Key) });
  1232. sortedSceneData.OrderBy(item => item.Measurement);
  1233. int items = 0;
  1234. foreach (var entry in sortedSceneData)
  1235. {
  1236. // The object may have been deleted since we received the data.
  1237. if (entry.Part == null)
  1238. continue;
  1239. // Don't show scripts that haven't executed or where execution time is below one microsecond in
  1240. // order to produce a more readable report.
  1241. if (entry.Measurement < 0.001)
  1242. continue;
  1243. items++;
  1244. SceneObjectGroup so = entry.Part.ParentGroup;
  1245. LandStatReportItem lsri = new LandStatReportItem();
  1246. lsri.LocationX = so.AbsolutePosition.X;
  1247. lsri.LocationY = so.AbsolutePosition.Y;
  1248. lsri.LocationZ = so.AbsolutePosition.Z;
  1249. lsri.Score = entry.Measurement;
  1250. lsri.TaskID = so.UUID;
  1251. lsri.TaskLocalID = so.LocalId;
  1252. lsri.TaskName = entry.Part.Name;
  1253. lsri.OwnerName = UserManager.GetUserName(so.OwnerID);
  1254. if (filter.Length != 0)
  1255. {
  1256. if ((lsri.OwnerName.Contains(filter) || lsri.TaskName.Contains(filter)))
  1257. {
  1258. }
  1259. else
  1260. {
  1261. continue;
  1262. }
  1263. }
  1264. SceneReport.Add(lsri);
  1265. if (items >= 100)
  1266. break;
  1267. }
  1268. }
  1269. remoteClient.SendLandStatReply(reportType, requestFlags, (uint)SceneReport.Count,SceneReport.ToArray());
  1270. }
  1271. #endregion
  1272. #region Outgoing Packets
  1273. public void sendRegionInfoPacketToAll()
  1274. {
  1275. // Scene.ForEachRootClient(delegate(IClientAPI client)
  1276. Scene.ForEachClient(delegate(IClientAPI client)
  1277. {
  1278. HandleRegionInfoRequest(client);
  1279. });
  1280. }
  1281. public void sendRegionHandshake(IClientAPI remoteClient)
  1282. {
  1283. RegionHandshakeArgs args = new RegionHandshakeArgs();
  1284. args.isEstateManager = Scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(remoteClient.AgentId);
  1285. if (Scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero && Scene.RegionInfo.EstateSettings.EstateOwner == remoteClient.AgentId)
  1286. args.isEstateManager = true;
  1287. args.billableFactor = Scene.RegionInfo.EstateSettings.BillableFactor;
  1288. args.terrainStartHeight0 = (float)Scene.RegionInfo.RegionSettings.Elevation1SW;
  1289. args.terrainHeightRange0 = (float)Scene.RegionInfo.RegionSettings.Elevation2SW;
  1290. args.terrainStartHeight1 = (float)Scene.RegionInfo.RegionSettings.Elevation1NW;
  1291. args.terrainHeightRange1 = (float)Scene.RegionInfo.RegionSettings.Elevation2NW;
  1292. args.terrainStartHeight2 = (float)Scene.RegionInfo.RegionSettings.Elevation1SE;
  1293. args.terrainHeightRange2 = (float)Scene.RegionInfo.RegionSettings.Elevation2SE;
  1294. args.terrainStartHeight3 = (float)Scene.RegionInfo.RegionSettings.Elevation1NE;
  1295. args.terrainHeightRange3 = (float)Scene.RegionInfo.RegionSettings.Elevation2NE;
  1296. args.simAccess = Scene.RegionInfo.AccessLevel;
  1297. args.waterHeight = (float)Scene.RegionInfo.RegionSettings.WaterHeight;
  1298. args.regionFlags = GetRegionFlags();
  1299. args.regionName = Scene.RegionInfo.RegionName;
  1300. args.SimOwner = Scene.RegionInfo.EstateSettings.EstateOwner;
  1301. args.terrainBase0 = UUID.Zero;
  1302. args.terrainBase1 = UUID.Zero;
  1303. args.terrainBase2 = UUID.Zero;
  1304. args.terrainBase3 = UUID.Zero;
  1305. args.terrainDetail0 = Scene.RegionInfo.RegionSettings.TerrainTexture1;
  1306. args.terrainDetail1 = Scene.RegionInfo.RegionSettings.TerrainTexture2;
  1307. args.terrainDetail2 = Scene.RegionInfo.RegionSettings.TerrainTexture3;
  1308. args.terrainDetail3 = Scene.RegionInfo.RegionSettings.TerrainTexture4;
  1309. // m_log.DebugFormat("[ESTATE MANAGEMENT MODULE]: Sending terrain texture 1 {0} for region {1}", args.terrainDetail0, Scene.RegionInfo.RegionName);
  1310. // m_log.DebugFormat("[ESTATE MANAGEMENT MODULE]: Sending terrain texture 2 {0} for region {1}", args.terrainDetail1, Scene.RegionInfo.RegionName);
  1311. // m_log.DebugFormat("[ESTATE MANAGEMENT MODULE]: Sending terrain texture 3 {0} for region {1}", args.terrainDetail2, Scene.RegionInfo.RegionName);
  1312. // m_log.DebugFormat("[ESTATE MANAGEMENT MODULE]: Sending terrain texture 4 {0} for region {1}", args.terrainDetail3, Scene.RegionInfo.RegionName);
  1313. remoteClient.SendRegionHandshake(Scene.RegionInfo,args);
  1314. }
  1315. public void handleEstateChangeInfo(IClientAPI remoteClient, UUID invoice, UUID senderID, UInt32 parms1, UInt32 parms2)
  1316. {
  1317. if (parms2 == 0)
  1318. {
  1319. Scene.RegionInfo.EstateSettings.UseGlobalTime = true;
  1320. Scene.RegionInfo.EstateSettings.SunPosition = 0.0;
  1321. }
  1322. else
  1323. {
  1324. Scene.RegionInfo.EstateSettings.UseGlobalTime = false;
  1325. Scene.RegionInfo.EstateSettings.SunPosition = (parms2 - 0x1800)/1024.0;
  1326. // Warning: FixedSun should be set to True, otherwise this sun position won't be used.
  1327. }
  1328. if ((parms1 & 0x00008000) != 0)
  1329. Scene.RegionInfo.EstateSettings.PublicAccess = true;
  1330. else
  1331. Scene.RegionInfo.EstateSettings.PublicAccess = false;
  1332. if ((parms1 & 0x00000010) != 0)
  1333. Scene.RegionInfo.EstateSettings.FixedSun = true;
  1334. else
  1335. Scene.RegionInfo.EstateSettings.FixedSun = false;
  1336. // taxfree is now AllowAccessOverride
  1337. if ((parms1 & 0x00000020) != 0)
  1338. Scene.RegionInfo.EstateSettings.TaxFree = true;
  1339. else
  1340. Scene.RegionInfo.EstateSettings.TaxFree = false;
  1341. if ((parms1 & 0x00100000) != 0)
  1342. Scene.RegionInfo.EstateSettings.AllowDirectTeleport = true;
  1343. else
  1344. Scene.RegionInfo.EstateSettings.AllowDirectTeleport = false;
  1345. if ((parms1 & 0x00800000) != 0)
  1346. Scene.RegionInfo.EstateSettings.DenyAnonymous = true;
  1347. else
  1348. Scene.RegionInfo.EstateSettings.DenyAnonymous = false;
  1349. // no longer in used, may be reassigned
  1350. if ((parms1 & 0x01000000) != 0)
  1351. Scene.RegionInfo.EstateSettings.DenyIdentified = true;
  1352. else
  1353. Scene.RegionInfo.EstateSettings.DenyIdentified = false;
  1354. // no longer in used, may be reassigned
  1355. if ((parms1 & 0x02000000) != 0)
  1356. Scene.RegionInfo.EstateSettings.DenyTransacted = true;
  1357. else
  1358. Scene.RegionInfo.EstateSettings.DenyTransacted = false;
  1359. if ((parms1 & 0x10000000) != 0)
  1360. Scene.RegionInfo.EstateSettings.AllowVoice = true;
  1361. else
  1362. Scene.RegionInfo.EstateSettings.AllowVoice = false;
  1363. if ((parms1 & 0x40000000) != 0)
  1364. Scene.RegionInfo.EstateSettings.DenyMinors = true;
  1365. else
  1366. Scene.RegionInfo.EstateSettings.DenyMinors = false;
  1367. Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
  1368. TriggerEstateInfoChange();
  1369. Scene.TriggerEstateSunUpdate();
  1370. sendDetailedEstateData(remoteClient, invoice);
  1371. }
  1372. #endregion
  1373. #region Other Functions
  1374. public void changeWaterHeight(float height)
  1375. {
  1376. setRegionTerrainSettings(height,
  1377. (float)Scene.RegionInfo.RegionSettings.TerrainRaiseLimit,
  1378. (float)Scene.RegionInfo.RegionSettings.TerrainLowerLimit,
  1379. Scene.RegionInfo.RegionSettings.UseEstateSun,
  1380. Scene.RegionInfo.RegionSettings.FixedSun,
  1381. (float)Scene.RegionInfo.RegionSettings.SunPosition,
  1382. Scene.RegionInfo.EstateSettings.UseGlobalTime,
  1383. Scene.RegionInfo.EstateSettings.FixedSun,
  1384. (float)Scene.RegionInfo.EstateSettings.SunPosition);
  1385. // sendRegionInfoPacketToAll(); already done by setRegionTerrainSettings
  1386. }
  1387. #endregion
  1388. private void EventManager_OnNewClient(IClientAPI client)
  1389. {
  1390. client.OnDetailedEstateDataRequest += clientSendDetailedEstateData;
  1391. client.OnSetEstateFlagsRequest += estateSetRegionInfoHandler;
  1392. // client.OnSetEstateTerrainBaseTexture += setEstateTerrainBaseTexture;
  1393. client.OnSetEstateTerrainDetailTexture += setEstateTerrainBaseTexture;
  1394. client.OnSetEstateTerrainTextureHeights += setEstateTerrainTextureHeights;
  1395. client.OnCommitEstateTerrainTextureRequest += handleCommitEstateTerrainTextureRequest;
  1396. client.OnSetRegionTerrainSettings += setRegionTerrainSettings;
  1397. client.OnEstateRestartSimRequest += handleEstateRestartSimRequest;
  1398. client.OnEstateChangeCovenantRequest += handleChangeEstateCovenantRequest;
  1399. client.OnEstateChangeInfo += handleEstateChangeInfo;
  1400. client.OnEstateManageTelehub += HandleOnEstateManageTelehub;
  1401. client.OnUpdateEstateAccessDeltaRequest += handleEstateAccessDeltaRequest;
  1402. client.OnSimulatorBlueBoxMessageRequest += SendSimulatorBlueBoxMessage;
  1403. client.OnEstateBlueBoxMessageRequest += SendEstateBlueBoxMessage;
  1404. client.OnEstateDebugRegionRequest += handleEstateDebugRegionRequest;
  1405. client.OnEstateTeleportOneUserHomeRequest += handleEstateTeleportOneUserHomeRequest;
  1406. client.OnEstateTeleportAllUsersHomeRequest += handleEstateTeleportAllUsersHomeRequest;
  1407. client.OnRequestTerrain += handleTerrainRequest;
  1408. client.OnUploadTerrain += handleUploadTerrain;
  1409. client.OnRegionInfoRequest += HandleRegionInfoRequest;
  1410. client.OnEstateCovenantRequest += HandleEstateCovenantRequest;
  1411. client.OnLandStatRequest += HandleLandStatRequest;
  1412. sendRegionHandshake(client);
  1413. }
  1414. public uint GetEstateFlags()
  1415. {
  1416. RegionFlags flags = RegionFlags.None;
  1417. if (Scene.RegionInfo.EstateSettings.FixedSun)
  1418. flags |= RegionFlags.SunFixed;
  1419. if (Scene.RegionInfo.EstateSettings.PublicAccess)
  1420. flags |= (RegionFlags.PublicAllowed |
  1421. RegionFlags.ExternallyVisible);
  1422. if (Scene.RegionInfo.EstateSettings.AllowVoice)
  1423. flags |= RegionFlags.AllowVoice;
  1424. if (Scene.RegionInfo.EstateSettings.AllowDirectTeleport)
  1425. flags |= RegionFlags.AllowDirectTeleport;
  1426. if (Scene.RegionInfo.EstateSettings.DenyAnonymous)
  1427. flags |= RegionFlags.DenyAnonymous;
  1428. if (Scene.RegionInfo.EstateSettings.DenyIdentified)
  1429. flags |= RegionFlags.DenyIdentified;
  1430. if (Scene.RegionInfo.EstateSettings.DenyTransacted)
  1431. flags |= RegionFlags.DenyTransacted;
  1432. if (Scene.RegionInfo.EstateSettings.AbuseEmailToEstateOwner)
  1433. flags |= RegionFlags.AbuseEmailToEstateOwner;
  1434. if (Scene.RegionInfo.EstateSettings.BlockDwell)
  1435. flags |= RegionFlags.BlockDwell;
  1436. if (Scene.RegionInfo.EstateSettings.EstateSkipScripts)
  1437. flags |= RegionFlags.EstateSkipScripts;
  1438. if (Scene.RegionInfo.EstateSettings.ResetHomeOnTeleport)
  1439. flags |= RegionFlags.ResetHomeOnTeleport;
  1440. if (Scene.RegionInfo.EstateSettings.TaxFree)
  1441. flags |= RegionFlags.TaxFree;
  1442. if (Scene.RegionInfo.EstateSettings.AllowLandmark)
  1443. flags |= RegionFlags.AllowLandmark;
  1444. if (Scene.RegionInfo.EstateSettings.AllowParcelChanges)
  1445. flags |= RegionFlags.AllowParcelChanges;
  1446. if (Scene.RegionInfo.EstateSettings.AllowSetHome)
  1447. flags |= RegionFlags.AllowSetHome;
  1448. if (Scene.RegionInfo.EstateSettings.DenyMinors)
  1449. flags |= (RegionFlags)(1 << 30);
  1450. return (uint)flags;
  1451. }
  1452. public void TriggerEstateMessage(UUID fromID, string fromName, string message)
  1453. {
  1454. MessageDelegate onmessage = OnEstateMessage;
  1455. if (onmessage != null)
  1456. onmessage(Scene.RegionInfo.RegionID, fromID, fromName, message);
  1457. }
  1458. private void SendTelehubInfo(IClientAPI client)
  1459. {
  1460. RegionSettings settings =
  1461. this.Scene.RegionInfo.RegionSettings;
  1462. SceneObjectGroup telehub = null;
  1463. if (settings.TelehubObject != UUID.Zero &&
  1464. (telehub = Scene.GetSceneObjectGroup(settings.TelehubObject)) != null)
  1465. {
  1466. List<Vector3> spawnPoints = new List<Vector3>();
  1467. foreach (SpawnPoint sp in settings.SpawnPoints())
  1468. {
  1469. spawnPoints.Add(sp.GetLocation(Vector3.Zero, Quaternion.Identity));
  1470. }
  1471. client.SendTelehubInfo(settings.TelehubObject,
  1472. telehub.Name,
  1473. telehub.AbsolutePosition,
  1474. telehub.GroupRotation,
  1475. spawnPoints);
  1476. }
  1477. else
  1478. {
  1479. client.SendTelehubInfo(UUID.Zero,
  1480. String.Empty,
  1481. Vector3.Zero,
  1482. Quaternion.Identity,
  1483. new List<Vector3>());
  1484. }
  1485. }
  1486. }
  1487. }