EstateManagementModule.cs 73 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773
  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. bitem.BanningUserID = remote_client.AgentId;
  825. bitem.BanTime = Util.UnixTimeSinceEpoch();
  826. estateSettings.AddBan(bitem);
  827. estateSettings.RemoveEstateUser(user);
  828. changed[(int)estateSettings.EstateID] = estateSettings;
  829. }
  830. }
  831. EstateBan item = new EstateBan();
  832. item.BannedUserID = user;
  833. item.EstateID = Scene.RegionInfo.EstateSettings.EstateID;
  834. item.BannedHostAddress = "0.0.0.0";
  835. item.BannedHostIPMask = "0.0.0.0";
  836. item.BanningUserID = remote_client.AgentId;
  837. item.BanTime = Util.UnixTimeSinceEpoch();
  838. thisSettings.AddBan(item);
  839. thisSettings.RemoveEstateUser(user);
  840. changed[thisEstateID] = thisSettings;
  841. ScenePresence s = Scene.GetScenePresence(user);
  842. if (s != null)
  843. {
  844. if (!s.IsChildAgent)
  845. {
  846. if (!Scene.TeleportClientHome(user, s.ControllingClient))
  847. {
  848. s.ControllingClient.Kick("Your access to the region was revoked and TP home failed - you have been logged out.");
  849. Scene.CloseAgent(s.UUID, false);
  850. }
  851. }
  852. }
  853. }
  854. else
  855. {
  856. remote_client.SendAlertMessage("User is already on the region ban list");
  857. }
  858. //Scene.RegionInfo.regionBanlist.Add(Manager(user);
  859. if(needReply)
  860. sendAllowedOrBanList[remote_client] = invoice;
  861. }
  862. }
  863. if ((estateAccessType & 128) != 0) // Ban remove
  864. {
  865. EstateBan[] banlistcheck = Scene.RegionInfo.EstateSettings.EstateBans;
  866. bool alreadyInList = false;
  867. EstateBan listitem = null;
  868. for (int i = 0; i < banlistcheck.Length; i++)
  869. {
  870. if (user == banlistcheck[i].BannedUserID)
  871. {
  872. alreadyInList = true;
  873. listitem = banlistcheck[i];
  874. break;
  875. }
  876. }
  877. if (alreadyInList && listitem != null)
  878. {
  879. if (doOtherEstates) // All estates
  880. {
  881. foreach (EstateSettings estateSettings in otherEstates)
  882. {
  883. if(!isadmin && !estateSettings.IsEstateManagerOrOwner(agentID))
  884. continue;
  885. estateSettings.RemoveBan(user);
  886. changed[(int)estateSettings.EstateID] = estateSettings;
  887. }
  888. }
  889. thisSettings.RemoveBan(listitem.BannedUserID);
  890. changed[thisEstateID] = thisSettings;
  891. }
  892. else
  893. {
  894. remote_client.SendAlertMessage("User is not on the region ban list");
  895. }
  896. if(needReply)
  897. sendAllowedOrBanList[remote_client] = invoice;
  898. }
  899. // last the ones only for owners of this region
  900. if (!Scene.Permissions.CanIssueEstateCommand(agentID, true))
  901. {
  902. remote_client.SendAlertMessage("Method EstateAccess Failed, you don't have permissions");
  903. continue;
  904. }
  905. if ((estateAccessType & 256) != 0) // Manager add
  906. {
  907. if(thisSettings.EstateManagersCount() >= (int)Constants.EstateAccessLimits.EstateManagers)
  908. {
  909. if(!sentManagersFull)
  910. {
  911. sentManagersFull = true;
  912. remote_client.SendAlertMessage("Estate Managers list is full");
  913. }
  914. }
  915. else
  916. {
  917. if (doOtherEstates) // All estates
  918. {
  919. foreach (EstateSettings estateSettings in otherEstates)
  920. {
  921. if(!isadmin && !estateSettings.IsEstateOwner(agentID)) // redundante check?
  922. continue;
  923. if(estateSettings.EstateManagersCount() >= (int)Constants.EstateAccessLimits.EstateManagers)
  924. continue;
  925. estateSettings.AddEstateManager(user);
  926. changed[(int)estateSettings.EstateID] = estateSettings;
  927. }
  928. }
  929. thisSettings.AddEstateManager(user);
  930. changed[thisEstateID] = thisSettings;
  931. sendManagers[remote_client] = invoice;
  932. }
  933. }
  934. if ((estateAccessType & 512) != 0) // Manager remove
  935. {
  936. if (doOtherEstates) // All estates
  937. {
  938. foreach (EstateSettings estateSettings in otherEstates)
  939. {
  940. if(!isadmin && !estateSettings.IsEstateOwner(agentID))
  941. continue;
  942. estateSettings.RemoveEstateManager(user);
  943. changed[(int)estateSettings.EstateID] = estateSettings;
  944. }
  945. }
  946. thisSettings.RemoveEstateManager(user);
  947. changed[thisEstateID] = thisSettings;
  948. sendManagers[remote_client] = invoice;
  949. }
  950. }
  951. lock(deltareqLock)
  952. runnigDeltaExec = false;
  953. }
  954. public void HandleOnEstateManageTelehub(IClientAPI client, UUID invoice, UUID senderID, string cmd, uint param1)
  955. {
  956. SceneObjectPart part;
  957. switch (cmd)
  958. {
  959. case "info ui":
  960. break;
  961. case "connect":
  962. // Add the Telehub
  963. part = Scene.GetSceneObjectPart((uint)param1);
  964. if (part == null)
  965. return;
  966. SceneObjectGroup grp = part.ParentGroup;
  967. m_Telehub.Connect(grp);
  968. break;
  969. case "delete":
  970. // Disconnect Telehub
  971. m_Telehub.Disconnect();
  972. break;
  973. case "spawnpoint add":
  974. // Add SpawnPoint to the Telehub
  975. part = Scene.GetSceneObjectPart((uint)param1);
  976. if (part == null)
  977. return;
  978. m_Telehub.AddSpawnPoint(part.AbsolutePosition);
  979. break;
  980. case "spawnpoint remove":
  981. // Remove SpawnPoint from Telehub
  982. m_Telehub.RemoveSpawnPoint((int)param1);
  983. break;
  984. default:
  985. break;
  986. }
  987. if (client != null)
  988. SendTelehubInfo(client);
  989. }
  990. private void SendSimulatorBlueBoxMessage(
  991. IClientAPI remote_client, UUID invoice, UUID senderID, UUID sessionID, string senderName, string message)
  992. {
  993. IDialogModule dm = Scene.RequestModuleInterface<IDialogModule>();
  994. if (dm != null)
  995. dm.SendNotificationToUsersInRegion(senderID, senderName, message);
  996. }
  997. private void SendEstateBlueBoxMessage(
  998. IClientAPI remote_client, UUID invoice, UUID senderID, UUID sessionID, string senderName, string message)
  999. {
  1000. TriggerEstateMessage(senderID, senderName, message);
  1001. }
  1002. private void handleEstateDebugRegionRequest(
  1003. IClientAPI remote_client, UUID invoice, UUID senderID,
  1004. bool disableScripts, bool disableCollisions, bool disablePhysics)
  1005. {
  1006. Scene.RegionInfo.RegionSettings.DisablePhysics = disablePhysics;
  1007. Scene.RegionInfo.RegionSettings.DisableScripts = disableScripts;
  1008. Scene.RegionInfo.RegionSettings.DisableCollisions = disableCollisions;
  1009. Scene.RegionInfo.RegionSettings.Save();
  1010. TriggerRegionInfoChange();
  1011. ISceneCommandsModule scm = Scene.RequestModuleInterface<ISceneCommandsModule>();
  1012. if (scm != null)
  1013. {
  1014. scm.SetSceneDebugOptions(
  1015. new Dictionary<string, string>() {
  1016. { "scripting", (!disableScripts).ToString() },
  1017. { "collisions", (!disableCollisions).ToString() },
  1018. { "physics", (!disablePhysics).ToString() }
  1019. }
  1020. );
  1021. }
  1022. }
  1023. private void handleEstateTeleportOneUserHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID, UUID prey, bool kick)
  1024. {
  1025. if (prey == UUID.Zero)
  1026. return;
  1027. EstateTeleportOneUserHomeRequest evOverride = OnEstateTeleportOneUserHomeRequest;
  1028. if(evOverride != null)
  1029. {
  1030. evOverride(remover_client, invoice, senderID, prey, kick);
  1031. return;
  1032. }
  1033. if (!Scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false))
  1034. return;
  1035. ScenePresence s = Scene.GetScenePresence(prey);
  1036. if (s != null && !s.IsDeleted && !s.IsInTransit)
  1037. {
  1038. if (kick)
  1039. {
  1040. s.ControllingClient.Kick("You have been kicked");
  1041. Scene.CloseAgent(s.UUID, false);
  1042. }
  1043. else if (!Scene.TeleportClientHome(prey, s.ControllingClient))
  1044. {
  1045. s.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed ");
  1046. Scene.CloseAgent(s.UUID, false);
  1047. }
  1048. }
  1049. }
  1050. private void handleEstateTeleportAllUsersHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID)
  1051. {
  1052. EstateTeleportAllUsersHomeRequest evOverride = OnEstateTeleportAllUsersHomeRequest;
  1053. if(evOverride != null)
  1054. {
  1055. evOverride(remover_client, invoice, senderID);
  1056. return;
  1057. }
  1058. if (!Scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false))
  1059. return;
  1060. Scene.ForEachRootClient(delegate(IClientAPI client)
  1061. {
  1062. if (client.AgentId != senderID)
  1063. {
  1064. // make sure they are still there, we could be working down a long list
  1065. // Also make sure they are actually in the region
  1066. ScenePresence p;
  1067. if(Scene.TryGetScenePresence(client.AgentId, out p))
  1068. {
  1069. if (!Scene.TeleportClientHome(p.UUID, p.ControllingClient))
  1070. {
  1071. p.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out.");
  1072. Scene.CloseAgent(p.UUID, false);
  1073. }
  1074. }
  1075. }
  1076. });
  1077. }
  1078. private void AbortTerrainXferHandler(IClientAPI remoteClient, ulong XferID)
  1079. {
  1080. lock (this)
  1081. {
  1082. if ((TerrainUploader != null) && (XferID == TerrainUploader.XferID))
  1083. {
  1084. remoteClient.OnXferReceive -= TerrainUploader.XferReceive;
  1085. remoteClient.OnAbortXfer -= AbortTerrainXferHandler;
  1086. TerrainUploader.TerrainUploadDone -= HandleTerrainApplication;
  1087. TerrainUploader = null;
  1088. remoteClient.SendAlertMessage("Terrain Upload aborted by the client");
  1089. }
  1090. }
  1091. }
  1092. private void HandleTerrainApplication(string filename, byte[] terrainData, IClientAPI remoteClient)
  1093. {
  1094. lock (this)
  1095. {
  1096. remoteClient.OnXferReceive -= TerrainUploader.XferReceive;
  1097. remoteClient.OnAbortXfer -= AbortTerrainXferHandler;
  1098. TerrainUploader.TerrainUploadDone -= HandleTerrainApplication;
  1099. TerrainUploader = null;
  1100. }
  1101. m_log.DebugFormat("[CLIENT]: Terrain upload from {0} to {1} complete.", remoteClient.Name, Scene.Name);
  1102. remoteClient.SendAlertMessage("Terrain Upload Complete. Loading....");
  1103. ITerrainModule terr = Scene.RequestModuleInterface<ITerrainModule>();
  1104. if (terr != null)
  1105. {
  1106. try
  1107. {
  1108. using (MemoryStream terrainStream = new MemoryStream(terrainData))
  1109. terr.LoadFromStream(filename, terrainStream);
  1110. FileInfo x = new FileInfo(filename);
  1111. remoteClient.SendAlertMessage("Your terrain was loaded as a " + x.Extension + " file. It may take a few moments to appear.");
  1112. }
  1113. catch (IOException e)
  1114. {
  1115. m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
  1116. remoteClient.SendAlertMessage("There was an IO Exception loading your terrain. Please check free space.");
  1117. return;
  1118. }
  1119. catch (SecurityException e)
  1120. {
  1121. m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
  1122. remoteClient.SendAlertMessage("There was a security Exception loading your terrain. Please check the security on the simulator drive");
  1123. return;
  1124. }
  1125. catch (UnauthorizedAccessException e)
  1126. {
  1127. m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
  1128. remoteClient.SendAlertMessage("There was a security Exception loading your terrain. Please check the security on the simulator drive");
  1129. return;
  1130. }
  1131. catch (Exception e)
  1132. {
  1133. m_log.ErrorFormat("[TERRAIN]: Error loading a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
  1134. remoteClient.SendAlertMessage("There was a general error loading your terrain. Please fix the terrain file and try again");
  1135. }
  1136. }
  1137. else
  1138. {
  1139. remoteClient.SendAlertMessage("Unable to apply terrain. Cannot get an instance of the terrain module");
  1140. }
  1141. }
  1142. private void handleUploadTerrain(IClientAPI remote_client, string clientFileName)
  1143. {
  1144. lock (this)
  1145. {
  1146. if (TerrainUploader == null)
  1147. {
  1148. m_log.DebugFormat(
  1149. "[TERRAIN]: Started receiving terrain upload for region {0} from {1}",
  1150. Scene.Name, remote_client.Name);
  1151. TerrainUploader = new EstateTerrainXferHandler(remote_client, clientFileName);
  1152. remote_client.OnXferReceive += TerrainUploader.XferReceive;
  1153. remote_client.OnAbortXfer += AbortTerrainXferHandler;
  1154. TerrainUploader.TerrainUploadDone += HandleTerrainApplication;
  1155. TerrainUploader.RequestStartXfer(remote_client);
  1156. }
  1157. else
  1158. {
  1159. remote_client.SendAlertMessage("Another Terrain Upload is in progress. Please wait your turn!");
  1160. }
  1161. }
  1162. }
  1163. private void handleTerrainRequest(IClientAPI remote_client, string clientFileName)
  1164. {
  1165. // Save terrain here
  1166. ITerrainModule terr = Scene.RequestModuleInterface<ITerrainModule>();
  1167. if (terr != null)
  1168. {
  1169. // m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + Scene.RegionInfo.RegionName);
  1170. if (File.Exists(Util.dataDir() + "/terrain.raw"))
  1171. {
  1172. File.Delete(Util.dataDir() + "/terrain.raw");
  1173. }
  1174. terr.SaveToFile(Util.dataDir() + "/terrain.raw");
  1175. byte[] bdata;
  1176. using(FileStream input = new FileStream(Util.dataDir() + "/terrain.raw",FileMode.Open))
  1177. {
  1178. bdata = new byte[input.Length];
  1179. input.Read(bdata, 0, (int)input.Length);
  1180. }
  1181. if(bdata == null || bdata.Length == 0)
  1182. {
  1183. remote_client.SendAlertMessage("Terrain error");
  1184. return;
  1185. }
  1186. remote_client.SendAlertMessage("Terrain file written, starting download...");
  1187. string xfername = (UUID.Random()).ToString();
  1188. Scene.XferManager.AddNewFile(xfername, bdata);
  1189. m_log.DebugFormat("[CLIENT]: Sending terrain for region {0} to {1}", Scene.Name, remote_client.Name);
  1190. remote_client.SendInitiateDownload(xfername, clientFileName);
  1191. }
  1192. }
  1193. private void HandleRegionInfoRequest(IClientAPI remote_client)
  1194. {
  1195. RegionInfoForEstateMenuArgs args = new RegionInfoForEstateMenuArgs();
  1196. args.billableFactor = Scene.RegionInfo.EstateSettings.BillableFactor;
  1197. args.estateID = Scene.RegionInfo.EstateSettings.EstateID;
  1198. args.maxAgents = Scene.RegionInfo.RegionSettings.AgentLimit;
  1199. args.objectBonusFactor = (float)Scene.RegionInfo.RegionSettings.ObjectBonus;
  1200. args.parentEstateID = Scene.RegionInfo.EstateSettings.ParentEstateID;
  1201. args.pricePerMeter = Scene.RegionInfo.EstateSettings.PricePerMeter;
  1202. args.redirectGridX = Scene.RegionInfo.EstateSettings.RedirectGridX;
  1203. args.redirectGridY = Scene.RegionInfo.EstateSettings.RedirectGridY;
  1204. args.regionFlags = GetRegionFlags();
  1205. args.simAccess = Scene.RegionInfo.AccessLevel;
  1206. args.sunHour = (float)Scene.RegionInfo.RegionSettings.SunPosition;
  1207. args.terrainLowerLimit = (float)Scene.RegionInfo.RegionSettings.TerrainLowerLimit;
  1208. args.terrainRaiseLimit = (float)Scene.RegionInfo.RegionSettings.TerrainRaiseLimit;
  1209. args.useEstateSun = Scene.RegionInfo.RegionSettings.UseEstateSun;
  1210. args.waterHeight = (float)Scene.RegionInfo.RegionSettings.WaterHeight;
  1211. args.simName = Scene.RegionInfo.RegionName;
  1212. args.regionType = Scene.RegionInfo.RegionType;
  1213. args.AgentCapacity = Scene.RegionInfo.AgentCapacity;
  1214. args.ObjectsCapacity = Scene.RegionInfo.ObjectCapacity;
  1215. remote_client.SendRegionInfoToEstateMenu(args);
  1216. }
  1217. private void HandleEstateCovenantRequest(IClientAPI remote_client)
  1218. {
  1219. remote_client.SendEstateCovenantInformation(Scene.RegionInfo.RegionSettings.Covenant);
  1220. }
  1221. private void HandleLandStatRequest(int parcelID, uint reportType, uint requestFlags, string filter, IClientAPI remoteClient)
  1222. {
  1223. if (!Scene.Permissions.CanIssueEstateCommand(remoteClient.AgentId, false))
  1224. return;
  1225. Dictionary<uint, float> sceneData = null;
  1226. if (reportType == 1)
  1227. {
  1228. sceneData = Scene.PhysicsScene.GetTopColliders();
  1229. }
  1230. else if (reportType == 0)
  1231. {
  1232. IScriptModule scriptModule = Scene.RequestModuleInterface<IScriptModule>();
  1233. if (scriptModule != null)
  1234. sceneData = scriptModule.GetObjectScriptsExecutionTimes();
  1235. }
  1236. List<LandStatReportItem> SceneReport = new List<LandStatReportItem>();
  1237. if (sceneData != null)
  1238. {
  1239. var sortedSceneData
  1240. = sceneData.Select(
  1241. item => new { Measurement = item.Value, Part = Scene.GetSceneObjectPart(item.Key) });
  1242. sortedSceneData.OrderBy(item => item.Measurement);
  1243. int items = 0;
  1244. foreach (var entry in sortedSceneData)
  1245. {
  1246. // The object may have been deleted since we received the data.
  1247. if (entry.Part == null)
  1248. continue;
  1249. // Don't show scripts that haven't executed or where execution time is below one microsecond in
  1250. // order to produce a more readable report.
  1251. if (entry.Measurement < 0.001)
  1252. continue;
  1253. items++;
  1254. SceneObjectGroup so = entry.Part.ParentGroup;
  1255. LandStatReportItem lsri = new LandStatReportItem();
  1256. lsri.LocationX = so.AbsolutePosition.X;
  1257. lsri.LocationY = so.AbsolutePosition.Y;
  1258. lsri.LocationZ = so.AbsolutePosition.Z;
  1259. lsri.Score = entry.Measurement;
  1260. lsri.TaskID = so.UUID;
  1261. lsri.TaskLocalID = so.LocalId;
  1262. lsri.TaskName = entry.Part.Name;
  1263. lsri.OwnerName = UserManager.GetUserName(so.OwnerID);
  1264. if (filter.Length != 0)
  1265. {
  1266. if ((lsri.OwnerName.Contains(filter) || lsri.TaskName.Contains(filter)))
  1267. {
  1268. }
  1269. else
  1270. {
  1271. continue;
  1272. }
  1273. }
  1274. SceneReport.Add(lsri);
  1275. if (items >= 100)
  1276. break;
  1277. }
  1278. }
  1279. remoteClient.SendLandStatReply(reportType, requestFlags, (uint)SceneReport.Count,SceneReport.ToArray());
  1280. }
  1281. #endregion
  1282. #region Outgoing Packets
  1283. public void sendRegionInfoPacketToAll()
  1284. {
  1285. // Scene.ForEachRootClient(delegate(IClientAPI client)
  1286. Scene.ForEachClient(delegate(IClientAPI client)
  1287. {
  1288. HandleRegionInfoRequest(client);
  1289. });
  1290. }
  1291. public void sendRegionHandshake(IClientAPI remoteClient)
  1292. {
  1293. remoteClient.SendRegionHandshake();
  1294. }
  1295. public void handleEstateChangeInfo(IClientAPI remoteClient, UUID invoice, UUID senderID, UInt32 parms1, UInt32 parms2)
  1296. {
  1297. if (parms2 == 0)
  1298. {
  1299. Scene.RegionInfo.EstateSettings.UseGlobalTime = true;
  1300. Scene.RegionInfo.EstateSettings.SunPosition = 0.0;
  1301. }
  1302. else
  1303. {
  1304. Scene.RegionInfo.EstateSettings.UseGlobalTime = false;
  1305. Scene.RegionInfo.EstateSettings.SunPosition = (parms2 - 0x1800)/1024.0;
  1306. // Warning: FixedSun should be set to True, otherwise this sun position won't be used.
  1307. }
  1308. if ((parms1 & 0x00008000) != 0)
  1309. Scene.RegionInfo.EstateSettings.PublicAccess = true;
  1310. else
  1311. Scene.RegionInfo.EstateSettings.PublicAccess = false;
  1312. if ((parms1 & 0x00000010) != 0)
  1313. Scene.RegionInfo.EstateSettings.FixedSun = true;
  1314. else
  1315. Scene.RegionInfo.EstateSettings.FixedSun = false;
  1316. // taxfree is now AllowAccessOverride
  1317. if ((parms1 & 0x00000020) != 0)
  1318. Scene.RegionInfo.EstateSettings.TaxFree = true;
  1319. else
  1320. Scene.RegionInfo.EstateSettings.TaxFree = false;
  1321. if ((parms1 & 0x00100000) != 0)
  1322. Scene.RegionInfo.EstateSettings.AllowDirectTeleport = true;
  1323. else
  1324. Scene.RegionInfo.EstateSettings.AllowDirectTeleport = false;
  1325. if ((parms1 & 0x00800000) != 0)
  1326. Scene.RegionInfo.EstateSettings.DenyAnonymous = true;
  1327. else
  1328. Scene.RegionInfo.EstateSettings.DenyAnonymous = false;
  1329. // no longer in used, may be reassigned
  1330. if ((parms1 & 0x01000000) != 0)
  1331. Scene.RegionInfo.EstateSettings.DenyIdentified = true;
  1332. else
  1333. Scene.RegionInfo.EstateSettings.DenyIdentified = false;
  1334. // no longer in used, may be reassigned
  1335. if ((parms1 & 0x02000000) != 0)
  1336. Scene.RegionInfo.EstateSettings.DenyTransacted = true;
  1337. else
  1338. Scene.RegionInfo.EstateSettings.DenyTransacted = false;
  1339. if ((parms1 & 0x10000000) != 0)
  1340. Scene.RegionInfo.EstateSettings.AllowVoice = true;
  1341. else
  1342. Scene.RegionInfo.EstateSettings.AllowVoice = false;
  1343. if ((parms1 & 0x40000000) != 0)
  1344. Scene.RegionInfo.EstateSettings.DenyMinors = true;
  1345. else
  1346. Scene.RegionInfo.EstateSettings.DenyMinors = false;
  1347. Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
  1348. TriggerEstateInfoChange();
  1349. Scene.TriggerEstateSunUpdate();
  1350. sendDetailedEstateData(remoteClient, invoice);
  1351. }
  1352. public bool handleEstateChangeInfoCap(string estateName, UUID invoice,
  1353. int sunHour, bool sunFixed,
  1354. bool externallyVisible,
  1355. bool allowDirectTeleport,
  1356. bool denyAnonymous, bool denyAgeUnverified,
  1357. bool alloVoiceChat, bool overridePublicAccess)
  1358. {
  1359. if (sunHour == 0)
  1360. {
  1361. Scene.RegionInfo.EstateSettings.UseGlobalTime = true;
  1362. Scene.RegionInfo.EstateSettings.SunPosition = 0.0;
  1363. }
  1364. else
  1365. {
  1366. Scene.RegionInfo.EstateSettings.UseGlobalTime = false;
  1367. Scene.RegionInfo.EstateSettings.SunPosition = (sunHour - 0x1800) / 1024.0;
  1368. // Warning: FixedSun should be set to True, otherwise this sun position won't be used.
  1369. }
  1370. Scene.RegionInfo.EstateSettings.PublicAccess = externallyVisible;
  1371. Scene.RegionInfo.EstateSettings.FixedSun = sunFixed;
  1372. Scene.RegionInfo.EstateSettings.AllowDirectTeleport = allowDirectTeleport;
  1373. Scene.RegionInfo.EstateSettings.DenyAnonymous = denyAnonymous;
  1374. Scene.RegionInfo.EstateSettings.AllowVoice = alloVoiceChat;
  1375. // taxfree is now AllowAccessOverride
  1376. Scene.RegionInfo.EstateSettings.TaxFree = overridePublicAccess;
  1377. Scene.RegionInfo.EstateSettings.DenyMinors = denyAgeUnverified;
  1378. Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
  1379. TriggerEstateInfoChange();
  1380. Scene.TriggerEstateSunUpdate();
  1381. return true;
  1382. }
  1383. #endregion
  1384. #region Other Functions
  1385. public void changeWaterHeight(float height)
  1386. {
  1387. setRegionTerrainSettings(height,
  1388. (float)Scene.RegionInfo.RegionSettings.TerrainRaiseLimit,
  1389. (float)Scene.RegionInfo.RegionSettings.TerrainLowerLimit,
  1390. Scene.RegionInfo.RegionSettings.UseEstateSun,
  1391. Scene.RegionInfo.RegionSettings.FixedSun,
  1392. (float)Scene.RegionInfo.RegionSettings.SunPosition,
  1393. Scene.RegionInfo.EstateSettings.UseGlobalTime,
  1394. Scene.RegionInfo.EstateSettings.FixedSun,
  1395. (float)Scene.RegionInfo.EstateSettings.SunPosition);
  1396. // sendRegionInfoPacketToAll(); already done by setRegionTerrainSettings
  1397. }
  1398. #endregion
  1399. private void EventManager_OnNewClient(IClientAPI client)
  1400. {
  1401. client.OnDetailedEstateDataRequest += clientSendDetailedEstateData;
  1402. client.OnSetEstateFlagsRequest += estateSetRegionInfoHandler;
  1403. // client.OnSetEstateTerrainBaseTexture += setEstateTerrainBaseTexture;
  1404. client.OnSetEstateTerrainDetailTexture += setEstateTerrainBaseTexture;
  1405. client.OnSetEstateTerrainTextureHeights += setEstateTerrainTextureHeights;
  1406. client.OnCommitEstateTerrainTextureRequest += handleCommitEstateTerrainTextureRequest;
  1407. client.OnSetRegionTerrainSettings += setRegionTerrainSettings;
  1408. client.OnEstateRestartSimRequest += handleEstateRestartSimRequest;
  1409. client.OnEstateChangeCovenantRequest += handleChangeEstateCovenantRequest;
  1410. client.OnEstateChangeInfo += handleEstateChangeInfo;
  1411. client.OnEstateManageTelehub += HandleOnEstateManageTelehub;
  1412. client.OnUpdateEstateAccessDeltaRequest += handleEstateAccessDeltaRequest;
  1413. client.OnSimulatorBlueBoxMessageRequest += SendSimulatorBlueBoxMessage;
  1414. client.OnEstateBlueBoxMessageRequest += SendEstateBlueBoxMessage;
  1415. client.OnEstateDebugRegionRequest += handleEstateDebugRegionRequest;
  1416. client.OnEstateTeleportOneUserHomeRequest += handleEstateTeleportOneUserHomeRequest;
  1417. client.OnEstateTeleportAllUsersHomeRequest += handleEstateTeleportAllUsersHomeRequest;
  1418. client.OnRequestTerrain += handleTerrainRequest;
  1419. client.OnUploadTerrain += handleUploadTerrain;
  1420. client.OnRegionInfoRequest += HandleRegionInfoRequest;
  1421. client.OnEstateCovenantRequest += HandleEstateCovenantRequest;
  1422. client.OnLandStatRequest += HandleLandStatRequest;
  1423. }
  1424. public uint GetEstateFlags()
  1425. {
  1426. RegionFlags flags = RegionFlags.None;
  1427. if (Scene.RegionInfo.EstateSettings.AllowLandmark)
  1428. flags |= RegionFlags.AllowLandmark;
  1429. if (Scene.RegionInfo.EstateSettings.AllowSetHome)
  1430. flags |= RegionFlags.AllowSetHome;
  1431. if (Scene.RegionInfo.EstateSettings.ResetHomeOnTeleport)
  1432. flags |= RegionFlags.ResetHomeOnTeleport;
  1433. if (Scene.RegionInfo.EstateSettings.FixedSun)
  1434. flags |= RegionFlags.SunFixed;
  1435. if (Scene.RegionInfo.EstateSettings.TaxFree) // this is now wrong means ALLOW_ACCESS_OVERRIDE
  1436. flags |= RegionFlags.TaxFree;
  1437. if (Scene.RegionInfo.EstateSettings.PublicAccess) //??
  1438. flags |= (RegionFlags.PublicAllowed | RegionFlags.ExternallyVisible);
  1439. if (Scene.RegionInfo.EstateSettings.BlockDwell)
  1440. flags |= RegionFlags.BlockDwell;
  1441. if (Scene.RegionInfo.EstateSettings.AllowDirectTeleport)
  1442. flags |= RegionFlags.AllowDirectTeleport;
  1443. if (Scene.RegionInfo.EstateSettings.EstateSkipScripts)
  1444. flags |= RegionFlags.EstateSkipScripts;
  1445. if (Scene.RegionInfo.EstateSettings.DenyAnonymous)
  1446. flags |= RegionFlags.DenyAnonymous;
  1447. if (Scene.RegionInfo.EstateSettings.DenyIdentified) // unused?
  1448. flags |= RegionFlags.DenyIdentified;
  1449. if (Scene.RegionInfo.EstateSettings.DenyTransacted) // unused?
  1450. flags |= RegionFlags.DenyTransacted;
  1451. if (Scene.RegionInfo.EstateSettings.AllowParcelChanges)
  1452. flags |= RegionFlags.AllowParcelChanges;
  1453. if (Scene.RegionInfo.EstateSettings.AbuseEmailToEstateOwner) // now is block fly
  1454. flags |= RegionFlags.AbuseEmailToEstateOwner;
  1455. if (Scene.RegionInfo.EstateSettings.AllowVoice)
  1456. flags |= RegionFlags.AllowVoice;
  1457. if (Scene.RegionInfo.EstateSettings.DenyMinors)
  1458. flags |= RegionFlags.DenyAgeUnverified;
  1459. return (uint)flags;
  1460. }
  1461. public void TriggerEstateMessage(UUID fromID, string fromName, string message)
  1462. {
  1463. MessageDelegate onmessage = OnEstateMessage;
  1464. if (onmessage != null)
  1465. onmessage(Scene.RegionInfo.RegionID, fromID, fromName, message);
  1466. }
  1467. private void SendTelehubInfo(IClientAPI client)
  1468. {
  1469. RegionSettings settings =
  1470. this.Scene.RegionInfo.RegionSettings;
  1471. SceneObjectGroup telehub = null;
  1472. if (settings.TelehubObject != UUID.Zero &&
  1473. (telehub = Scene.GetSceneObjectGroup(settings.TelehubObject)) != null)
  1474. {
  1475. List<Vector3> spawnPoints = new List<Vector3>();
  1476. foreach (SpawnPoint sp in settings.SpawnPoints())
  1477. {
  1478. spawnPoints.Add(sp.GetLocation(Vector3.Zero, Quaternion.Identity));
  1479. }
  1480. client.SendTelehubInfo(settings.TelehubObject,
  1481. telehub.Name,
  1482. telehub.AbsolutePosition,
  1483. telehub.GroupRotation,
  1484. spawnPoints);
  1485. }
  1486. else
  1487. {
  1488. client.SendTelehubInfo(UUID.Zero,
  1489. String.Empty,
  1490. Vector3.Zero,
  1491. Quaternion.Identity,
  1492. new List<Vector3>());
  1493. }
  1494. }
  1495. }
  1496. }