EstateManagementModule.cs 78 KB

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