EstateManagementModule.cs 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352
  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;
  29. using System.Collections.Generic;
  30. using System.IO;
  31. using System.Linq;
  32. using System.Reflection;
  33. using System.Security;
  34. using log4net;
  35. using Mono.Addins;
  36. using Nini.Config;
  37. using OpenMetaverse;
  38. using OpenSim.Framework;
  39. using OpenSim.Region.Framework.Interfaces;
  40. using OpenSim.Region.Framework.Scenes;
  41. using RegionFlags = OpenMetaverse.RegionFlags;
  42. namespace OpenSim.Region.CoreModules.World.Estate
  43. {
  44. [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EstateManagementModule")]
  45. public class EstateManagementModule : IEstateModule, INonSharedRegionModule
  46. {
  47. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  48. public Scene Scene { get; private set; }
  49. public IUserManagement UserManager { get; private set; }
  50. protected EstateManagementCommands m_commands;
  51. /// <summary>
  52. /// If false, region restart requests from the client are blocked even if they are otherwise legitimate.
  53. /// </summary>
  54. public bool AllowRegionRestartFromClient { get; set; }
  55. private EstateTerrainXferHandler TerrainUploader;
  56. public TelehubManager m_Telehub;
  57. public event ChangeDelegate OnRegionInfoChange;
  58. public event ChangeDelegate OnEstateInfoChange;
  59. public event MessageDelegate OnEstateMessage;
  60. #region Region Module interface
  61. public string Name { get { return "EstateManagementModule"; } }
  62. public Type ReplaceableInterface { get { return null; } }
  63. public void Initialise(IConfigSource source)
  64. {
  65. AllowRegionRestartFromClient = true;
  66. IConfig config = source.Configs["EstateManagement"];
  67. if (config != null)
  68. AllowRegionRestartFromClient = config.GetBoolean("AllowRegionRestartFromClient", true);
  69. }
  70. public void AddRegion(Scene scene)
  71. {
  72. Scene = scene;
  73. Scene.RegisterModuleInterface<IEstateModule>(this);
  74. Scene.EventManager.OnNewClient += EventManager_OnNewClient;
  75. Scene.EventManager.OnRequestChangeWaterHeight += changeWaterHeight;
  76. m_Telehub = new TelehubManager(scene);
  77. m_commands = new EstateManagementCommands(this);
  78. m_commands.Initialise();
  79. }
  80. public void RemoveRegion(Scene scene) {}
  81. public void RegionLoaded(Scene scene)
  82. {
  83. // Sets up the sun module based no the saved Estate and Region Settings
  84. // DO NOT REMOVE or the sun will stop working
  85. scene.TriggerEstateSunUpdate();
  86. UserManager = scene.RequestModuleInterface<IUserManagement>();
  87. }
  88. public void Close()
  89. {
  90. m_commands.Close();
  91. }
  92. #endregion
  93. #region Packet Data Responders
  94. private void sendDetailedEstateData(IClientAPI remote_client, UUID invoice)
  95. {
  96. uint sun = 0;
  97. if (!Scene.RegionInfo.EstateSettings.UseGlobalTime)
  98. sun = (uint)(Scene.RegionInfo.EstateSettings.SunPosition * 1024.0) + 0x1800;
  99. UUID estateOwner;
  100. estateOwner = Scene.RegionInfo.EstateSettings.EstateOwner;
  101. if (Scene.Permissions.IsGod(remote_client.AgentId))
  102. estateOwner = remote_client.AgentId;
  103. remote_client.SendDetailedEstateData(invoice,
  104. Scene.RegionInfo.EstateSettings.EstateName,
  105. Scene.RegionInfo.EstateSettings.EstateID,
  106. Scene.RegionInfo.EstateSettings.ParentEstateID,
  107. GetEstateFlags(),
  108. sun,
  109. Scene.RegionInfo.RegionSettings.Covenant,
  110. (uint) Scene.RegionInfo.RegionSettings.CovenantChangedDateTime,
  111. Scene.RegionInfo.EstateSettings.AbuseEmail,
  112. estateOwner);
  113. remote_client.SendEstateList(invoice,
  114. (int)Constants.EstateAccessCodex.EstateManagers,
  115. Scene.RegionInfo.EstateSettings.EstateManagers,
  116. Scene.RegionInfo.EstateSettings.EstateID);
  117. remote_client.SendEstateList(invoice,
  118. (int)Constants.EstateAccessCodex.AccessOptions,
  119. Scene.RegionInfo.EstateSettings.EstateAccess,
  120. Scene.RegionInfo.EstateSettings.EstateID);
  121. remote_client.SendEstateList(invoice,
  122. (int)Constants.EstateAccessCodex.AllowedGroups,
  123. Scene.RegionInfo.EstateSettings.EstateGroups,
  124. Scene.RegionInfo.EstateSettings.EstateID);
  125. remote_client.SendBannedUserList(invoice,
  126. Scene.RegionInfo.EstateSettings.EstateBans,
  127. Scene.RegionInfo.EstateSettings.EstateID);
  128. }
  129. private void estateSetRegionInfoHandler(bool blockTerraform, bool noFly, bool allowDamage, bool blockLandResell, int maxAgents, float objectBonusFactor,
  130. int matureLevel, bool restrictPushObject, bool allowParcelChanges)
  131. {
  132. if (blockTerraform)
  133. Scene.RegionInfo.RegionSettings.BlockTerraform = true;
  134. else
  135. Scene.RegionInfo.RegionSettings.BlockTerraform = false;
  136. if (noFly)
  137. Scene.RegionInfo.RegionSettings.BlockFly = true;
  138. else
  139. Scene.RegionInfo.RegionSettings.BlockFly = false;
  140. if (allowDamage)
  141. Scene.RegionInfo.RegionSettings.AllowDamage = true;
  142. else
  143. Scene.RegionInfo.RegionSettings.AllowDamage = false;
  144. if (blockLandResell)
  145. Scene.RegionInfo.RegionSettings.AllowLandResell = false;
  146. else
  147. Scene.RegionInfo.RegionSettings.AllowLandResell = true;
  148. if((byte)maxAgents <= Scene.RegionInfo.AgentCapacity)
  149. Scene.RegionInfo.RegionSettings.AgentLimit = (byte) maxAgents;
  150. else
  151. Scene.RegionInfo.RegionSettings.AgentLimit = Scene.RegionInfo.AgentCapacity;
  152. Scene.RegionInfo.RegionSettings.ObjectBonus = objectBonusFactor;
  153. if (matureLevel <= 13)
  154. Scene.RegionInfo.RegionSettings.Maturity = 0;
  155. else if (matureLevel <= 21)
  156. Scene.RegionInfo.RegionSettings.Maturity = 1;
  157. else
  158. Scene.RegionInfo.RegionSettings.Maturity = 2;
  159. if (restrictPushObject)
  160. Scene.RegionInfo.RegionSettings.RestrictPushing = true;
  161. else
  162. Scene.RegionInfo.RegionSettings.RestrictPushing = false;
  163. if (allowParcelChanges)
  164. Scene.RegionInfo.RegionSettings.AllowLandJoinDivide = true;
  165. else
  166. Scene.RegionInfo.RegionSettings.AllowLandJoinDivide = false;
  167. Scene.RegionInfo.RegionSettings.Save();
  168. TriggerRegionInfoChange();
  169. sendRegionInfoPacketToAll();
  170. }
  171. public void setEstateTerrainBaseTexture(int level, UUID texture)
  172. {
  173. setEstateTerrainBaseTexture(null, level, texture);
  174. sendRegionHandshakeToAll();
  175. }
  176. public void setEstateTerrainBaseTexture(IClientAPI remoteClient, int level, UUID texture)
  177. {
  178. if (texture == UUID.Zero)
  179. return;
  180. switch (level)
  181. {
  182. case 0:
  183. Scene.RegionInfo.RegionSettings.TerrainTexture1 = texture;
  184. break;
  185. case 1:
  186. Scene.RegionInfo.RegionSettings.TerrainTexture2 = texture;
  187. break;
  188. case 2:
  189. Scene.RegionInfo.RegionSettings.TerrainTexture3 = texture;
  190. break;
  191. case 3:
  192. Scene.RegionInfo.RegionSettings.TerrainTexture4 = texture;
  193. break;
  194. }
  195. Scene.RegionInfo.RegionSettings.Save();
  196. TriggerRegionInfoChange();
  197. sendRegionInfoPacketToAll();
  198. }
  199. public void setEstateTerrainTextureHeights(int corner, float lowValue, float highValue)
  200. {
  201. setEstateTerrainTextureHeights(null, corner, lowValue, highValue);
  202. }
  203. public void setEstateTerrainTextureHeights(IClientAPI client, int corner, float lowValue, float highValue)
  204. {
  205. switch (corner)
  206. {
  207. case 0:
  208. Scene.RegionInfo.RegionSettings.Elevation1SW = lowValue;
  209. Scene.RegionInfo.RegionSettings.Elevation2SW = highValue;
  210. break;
  211. case 1:
  212. Scene.RegionInfo.RegionSettings.Elevation1NW = lowValue;
  213. Scene.RegionInfo.RegionSettings.Elevation2NW = highValue;
  214. break;
  215. case 2:
  216. Scene.RegionInfo.RegionSettings.Elevation1SE = lowValue;
  217. Scene.RegionInfo.RegionSettings.Elevation2SE = highValue;
  218. break;
  219. case 3:
  220. Scene.RegionInfo.RegionSettings.Elevation1NE = lowValue;
  221. Scene.RegionInfo.RegionSettings.Elevation2NE = highValue;
  222. break;
  223. }
  224. Scene.RegionInfo.RegionSettings.Save();
  225. TriggerRegionInfoChange();
  226. sendRegionHandshakeToAll();
  227. sendRegionInfoPacketToAll();
  228. }
  229. private void handleCommitEstateTerrainTextureRequest(IClientAPI remoteClient)
  230. {
  231. // sendRegionHandshakeToAll();
  232. }
  233. public void setRegionTerrainSettings(float WaterHeight,
  234. float TerrainRaiseLimit, float TerrainLowerLimit,
  235. bool UseEstateSun, bool UseFixedSun, float SunHour,
  236. bool UseGlobal, bool EstateFixedSun, float EstateSunHour)
  237. {
  238. // Water Height
  239. Scene.RegionInfo.RegionSettings.WaterHeight = WaterHeight;
  240. // Terraforming limits
  241. Scene.RegionInfo.RegionSettings.TerrainRaiseLimit = TerrainRaiseLimit;
  242. Scene.RegionInfo.RegionSettings.TerrainLowerLimit = TerrainLowerLimit;
  243. // Time of day / fixed sun
  244. Scene.RegionInfo.RegionSettings.UseEstateSun = UseEstateSun;
  245. Scene.RegionInfo.RegionSettings.FixedSun = UseFixedSun;
  246. Scene.RegionInfo.RegionSettings.SunPosition = SunHour;
  247. Scene.TriggerEstateSunUpdate();
  248. //m_log.Debug("[ESTATE]: UFS: " + UseFixedSun.ToString());
  249. //m_log.Debug("[ESTATE]: SunHour: " + SunHour.ToString());
  250. sendRegionInfoPacketToAll();
  251. Scene.RegionInfo.RegionSettings.Save();
  252. TriggerRegionInfoChange();
  253. }
  254. private void handleEstateRestartSimRequest(IClientAPI remoteClient, int timeInSeconds)
  255. {
  256. if (!AllowRegionRestartFromClient)
  257. {
  258. remoteClient.SendAlertMessage("Region restart has been disabled on this simulator.");
  259. return;
  260. }
  261. IRestartModule restartModule = Scene.RequestModuleInterface<IRestartModule>();
  262. if (restartModule != null)
  263. {
  264. List<int> times = new List<int>();
  265. while (timeInSeconds > 0)
  266. {
  267. times.Add(timeInSeconds);
  268. if (timeInSeconds > 300)
  269. timeInSeconds -= 120;
  270. else if (timeInSeconds > 30)
  271. timeInSeconds -= 30;
  272. else
  273. timeInSeconds -= 15;
  274. }
  275. restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true);
  276. m_log.InfoFormat(
  277. "User {0} requested restart of region {1} in {2} seconds",
  278. remoteClient.Name, Scene.Name, times.Count != 0 ? times[0] : 0);
  279. }
  280. }
  281. private void handleChangeEstateCovenantRequest(IClientAPI remoteClient, UUID estateCovenantID)
  282. {
  283. // m_log.DebugFormat(
  284. // "[ESTATE MANAGEMENT MODULE]: Handling request from {0} to change estate covenant to {1}",
  285. // remoteClient.Name, estateCovenantID);
  286. Scene.RegionInfo.RegionSettings.Covenant = estateCovenantID;
  287. Scene.RegionInfo.RegionSettings.CovenantChangedDateTime = Util.UnixTimeSinceEpoch();
  288. Scene.RegionInfo.RegionSettings.Save();
  289. TriggerRegionInfoChange();
  290. }
  291. private void handleEstateAccessDeltaRequest(IClientAPI remote_client, UUID invoice, int estateAccessType, UUID user)
  292. {
  293. // EstateAccessDelta handles Estate Managers, Sim Access, Sim Banlist, allowed Groups.. etc.
  294. if (user == Scene.RegionInfo.EstateSettings.EstateOwner)
  295. return; // never process EO
  296. if ((estateAccessType & 4) != 0) // User add
  297. {
  298. if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true))
  299. {
  300. if ((estateAccessType & 1) != 0) // All estates
  301. {
  302. List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
  303. EstateSettings estateSettings;
  304. foreach (int estateID in estateIDs)
  305. {
  306. if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
  307. {
  308. estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
  309. estateSettings.AddEstateUser(user);
  310. estateSettings.Save();
  311. }
  312. }
  313. }
  314. Scene.RegionInfo.EstateSettings.AddEstateUser(user);
  315. Scene.RegionInfo.EstateSettings.Save();
  316. TriggerEstateInfoChange();
  317. remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, Scene.RegionInfo.EstateSettings.EstateAccess, Scene.RegionInfo.EstateSettings.EstateID);
  318. }
  319. else
  320. {
  321. remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
  322. }
  323. }
  324. if ((estateAccessType & 8) != 0) // User remove
  325. {
  326. if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true))
  327. {
  328. if ((estateAccessType & 1) != 0) // All estates
  329. {
  330. List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
  331. EstateSettings estateSettings;
  332. foreach (int estateID in estateIDs)
  333. {
  334. if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
  335. {
  336. estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
  337. estateSettings.RemoveEstateUser(user);
  338. estateSettings.Save();
  339. }
  340. }
  341. }
  342. Scene.RegionInfo.EstateSettings.RemoveEstateUser(user);
  343. Scene.RegionInfo.EstateSettings.Save();
  344. TriggerEstateInfoChange();
  345. remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, Scene.RegionInfo.EstateSettings.EstateAccess, Scene.RegionInfo.EstateSettings.EstateID);
  346. }
  347. else
  348. {
  349. remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
  350. }
  351. }
  352. if ((estateAccessType & 16) != 0) // Group add
  353. {
  354. if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true))
  355. {
  356. if ((estateAccessType & 1) != 0) // All estates
  357. {
  358. List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
  359. EstateSettings estateSettings;
  360. foreach (int estateID in estateIDs)
  361. {
  362. if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
  363. {
  364. estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
  365. estateSettings.AddEstateGroup(user);
  366. estateSettings.Save();
  367. }
  368. }
  369. }
  370. Scene.RegionInfo.EstateSettings.AddEstateGroup(user);
  371. Scene.RegionInfo.EstateSettings.Save();
  372. TriggerEstateInfoChange();
  373. remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, Scene.RegionInfo.EstateSettings.EstateGroups, Scene.RegionInfo.EstateSettings.EstateID);
  374. }
  375. else
  376. {
  377. remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
  378. }
  379. }
  380. if ((estateAccessType & 32) != 0) // Group remove
  381. {
  382. if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true))
  383. {
  384. if ((estateAccessType & 1) != 0) // All estates
  385. {
  386. List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
  387. EstateSettings estateSettings;
  388. foreach (int estateID in estateIDs)
  389. {
  390. if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
  391. {
  392. estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
  393. estateSettings.RemoveEstateGroup(user);
  394. estateSettings.Save();
  395. }
  396. }
  397. }
  398. Scene.RegionInfo.EstateSettings.RemoveEstateGroup(user);
  399. Scene.RegionInfo.EstateSettings.Save();
  400. TriggerEstateInfoChange();
  401. remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, Scene.RegionInfo.EstateSettings.EstateGroups, Scene.RegionInfo.EstateSettings.EstateID);
  402. }
  403. else
  404. {
  405. remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
  406. }
  407. }
  408. if ((estateAccessType & 64) != 0) // Ban add
  409. {
  410. if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false))
  411. {
  412. EstateBan[] banlistcheck = Scene.RegionInfo.EstateSettings.EstateBans;
  413. bool alreadyInList = false;
  414. for (int i = 0; i < banlistcheck.Length; i++)
  415. {
  416. if (user == banlistcheck[i].BannedUserID)
  417. {
  418. alreadyInList = true;
  419. break;
  420. }
  421. }
  422. if (!alreadyInList)
  423. {
  424. if ((estateAccessType & 1) != 0) // All estates
  425. {
  426. List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
  427. EstateSettings estateSettings;
  428. foreach (int estateID in estateIDs)
  429. {
  430. if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
  431. {
  432. EstateBan bitem = new EstateBan();
  433. bitem.BannedUserID = user;
  434. bitem.EstateID = (uint)estateID;
  435. bitem.BannedHostAddress = "0.0.0.0";
  436. bitem.BannedHostIPMask = "0.0.0.0";
  437. estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
  438. estateSettings.AddBan(bitem);
  439. estateSettings.Save();
  440. }
  441. }
  442. }
  443. EstateBan item = new EstateBan();
  444. item.BannedUserID = user;
  445. item.EstateID = Scene.RegionInfo.EstateSettings.EstateID;
  446. item.BannedHostAddress = "0.0.0.0";
  447. item.BannedHostIPMask = "0.0.0.0";
  448. Scene.RegionInfo.EstateSettings.AddBan(item);
  449. Scene.RegionInfo.EstateSettings.Save();
  450. TriggerEstateInfoChange();
  451. ScenePresence s = Scene.GetScenePresence(user);
  452. if (s != null)
  453. {
  454. if (!s.IsChildAgent)
  455. {
  456. Scene.TeleportClientHome(user, s.ControllingClient);
  457. }
  458. }
  459. }
  460. else
  461. {
  462. remote_client.SendAlertMessage("User is already on the region ban list");
  463. }
  464. //m_scene.RegionInfo.regionBanlist.Add(Manager(user);
  465. remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID);
  466. }
  467. else
  468. {
  469. remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
  470. }
  471. }
  472. if ((estateAccessType & 128) != 0) // Ban remove
  473. {
  474. if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false))
  475. {
  476. EstateBan[] banlistcheck = Scene.RegionInfo.EstateSettings.EstateBans;
  477. bool alreadyInList = false;
  478. EstateBan listitem = null;
  479. for (int i = 0; i < banlistcheck.Length; i++)
  480. {
  481. if (user == banlistcheck[i].BannedUserID)
  482. {
  483. alreadyInList = true;
  484. listitem = banlistcheck[i];
  485. break;
  486. }
  487. }
  488. if (alreadyInList && listitem != null)
  489. {
  490. if ((estateAccessType & 1) != 0) // All estates
  491. {
  492. List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
  493. EstateSettings estateSettings;
  494. foreach (int estateID in estateIDs)
  495. {
  496. if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
  497. {
  498. estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
  499. estateSettings.RemoveBan(user);
  500. estateSettings.Save();
  501. }
  502. }
  503. }
  504. Scene.RegionInfo.EstateSettings.RemoveBan(listitem.BannedUserID);
  505. Scene.RegionInfo.EstateSettings.Save();
  506. TriggerEstateInfoChange();
  507. }
  508. else
  509. {
  510. remote_client.SendAlertMessage("User is not on the region ban list");
  511. }
  512. //m_scene.RegionInfo.regionBanlist.Add(Manager(user);
  513. remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID);
  514. }
  515. else
  516. {
  517. remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
  518. }
  519. }
  520. if ((estateAccessType & 256) != 0) // Manager add
  521. {
  522. if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true))
  523. {
  524. if ((estateAccessType & 1) != 0) // All estates
  525. {
  526. List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
  527. EstateSettings estateSettings;
  528. foreach (int estateID in estateIDs)
  529. {
  530. if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
  531. {
  532. estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
  533. estateSettings.AddEstateManager(user);
  534. estateSettings.Save();
  535. }
  536. }
  537. }
  538. Scene.RegionInfo.EstateSettings.AddEstateManager(user);
  539. Scene.RegionInfo.EstateSettings.Save();
  540. TriggerEstateInfoChange();
  541. remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, Scene.RegionInfo.EstateSettings.EstateManagers, Scene.RegionInfo.EstateSettings.EstateID);
  542. }
  543. else
  544. {
  545. remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
  546. }
  547. }
  548. if ((estateAccessType & 512) != 0) // Manager remove
  549. {
  550. if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true))
  551. {
  552. if ((estateAccessType & 1) != 0) // All estates
  553. {
  554. List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
  555. EstateSettings estateSettings;
  556. foreach (int estateID in estateIDs)
  557. {
  558. if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
  559. {
  560. estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
  561. estateSettings.RemoveEstateManager(user);
  562. estateSettings.Save();
  563. }
  564. }
  565. }
  566. Scene.RegionInfo.EstateSettings.RemoveEstateManager(user);
  567. Scene.RegionInfo.EstateSettings.Save();
  568. TriggerEstateInfoChange();
  569. remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, Scene.RegionInfo.EstateSettings.EstateManagers, Scene.RegionInfo.EstateSettings.EstateID);
  570. }
  571. else
  572. {
  573. remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
  574. }
  575. }
  576. }
  577. public void handleOnEstateManageTelehub(IClientAPI client, UUID invoice, UUID senderID, string cmd, uint param1)
  578. {
  579. SceneObjectPart part;
  580. switch (cmd)
  581. {
  582. case "info ui":
  583. break;
  584. case "connect":
  585. // Add the Telehub
  586. part = Scene.GetSceneObjectPart((uint)param1);
  587. if (part == null)
  588. return;
  589. SceneObjectGroup grp = part.ParentGroup;
  590. m_Telehub.Connect(grp);
  591. break;
  592. case "delete":
  593. // Disconnect Telehub
  594. m_Telehub.Disconnect();
  595. break;
  596. case "spawnpoint add":
  597. // Add SpawnPoint to the Telehub
  598. part = Scene.GetSceneObjectPart((uint)param1);
  599. if (part == null)
  600. return;
  601. m_Telehub.AddSpawnPoint(part.AbsolutePosition);
  602. break;
  603. case "spawnpoint remove":
  604. // Remove SpawnPoint from Telehub
  605. m_Telehub.RemoveSpawnPoint((int)param1);
  606. break;
  607. default:
  608. break;
  609. }
  610. SendTelehubInfo(client);
  611. }
  612. private void SendSimulatorBlueBoxMessage(
  613. IClientAPI remote_client, UUID invoice, UUID senderID, UUID sessionID, string senderName, string message)
  614. {
  615. IDialogModule dm = Scene.RequestModuleInterface<IDialogModule>();
  616. if (dm != null)
  617. dm.SendNotificationToUsersInRegion(senderID, senderName, message);
  618. }
  619. private void SendEstateBlueBoxMessage(
  620. IClientAPI remote_client, UUID invoice, UUID senderID, UUID sessionID, string senderName, string message)
  621. {
  622. TriggerEstateMessage(senderID, senderName, message);
  623. }
  624. private void handleEstateDebugRegionRequest(
  625. IClientAPI remote_client, UUID invoice, UUID senderID,
  626. bool disableScripts, bool disableCollisions, bool disablePhysics)
  627. {
  628. Scene.RegionInfo.RegionSettings.DisablePhysics = disablePhysics;
  629. Scene.RegionInfo.RegionSettings.DisableScripts = disableScripts;
  630. Scene.RegionInfo.RegionSettings.DisableCollisions = disableCollisions;
  631. Scene.RegionInfo.RegionSettings.Save();
  632. TriggerRegionInfoChange();
  633. ISceneCommandsModule scm = Scene.RequestModuleInterface<ISceneCommandsModule>();
  634. if (scm != null)
  635. {
  636. scm.SetSceneDebugOptions(
  637. new Dictionary<string, string>() {
  638. { "scripting", (!disableScripts).ToString() },
  639. { "collisions", (!disableCollisions).ToString() },
  640. { "physics", (!disablePhysics).ToString() }
  641. }
  642. );
  643. }
  644. }
  645. private void handleEstateTeleportOneUserHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID, UUID prey)
  646. {
  647. if (!Scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false))
  648. return;
  649. if (prey != UUID.Zero)
  650. {
  651. ScenePresence s = Scene.GetScenePresence(prey);
  652. if (s != null)
  653. {
  654. Scene.TeleportClientHome(prey, s.ControllingClient);
  655. }
  656. }
  657. }
  658. private void handleEstateTeleportAllUsersHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID)
  659. {
  660. if (!Scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false))
  661. return;
  662. Scene.ForEachRootClient(delegate(IClientAPI client)
  663. {
  664. if (client.AgentId != senderID)
  665. {
  666. // make sure they are still there, we could be working down a long list
  667. // Also make sure they are actually in the region
  668. ScenePresence p;
  669. if(Scene.TryGetScenePresence(client.AgentId, out p))
  670. Scene.TeleportClientHome(p.UUID, p.ControllingClient);
  671. }
  672. });
  673. }
  674. private void AbortTerrainXferHandler(IClientAPI remoteClient, ulong XferID)
  675. {
  676. if (TerrainUploader != null)
  677. {
  678. lock (TerrainUploader)
  679. {
  680. if (XferID == TerrainUploader.XferID)
  681. {
  682. remoteClient.OnXferReceive -= TerrainUploader.XferReceive;
  683. remoteClient.OnAbortXfer -= AbortTerrainXferHandler;
  684. TerrainUploader.TerrainUploadDone -= HandleTerrainApplication;
  685. TerrainUploader = null;
  686. remoteClient.SendAlertMessage("Terrain Upload aborted by the client");
  687. }
  688. }
  689. }
  690. }
  691. private void HandleTerrainApplication(string filename, byte[] terrainData, IClientAPI remoteClient)
  692. {
  693. lock (TerrainUploader)
  694. {
  695. remoteClient.OnXferReceive -= TerrainUploader.XferReceive;
  696. remoteClient.OnAbortXfer -= AbortTerrainXferHandler;
  697. TerrainUploader.TerrainUploadDone -= HandleTerrainApplication;
  698. TerrainUploader = null;
  699. }
  700. remoteClient.SendAlertMessage("Terrain Upload Complete. Loading....");
  701. ITerrainModule terr = Scene.RequestModuleInterface<ITerrainModule>();
  702. if (terr != null)
  703. {
  704. m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + Scene.RegionInfo.RegionName);
  705. try
  706. {
  707. MemoryStream terrainStream = new MemoryStream(terrainData);
  708. terr.LoadFromStream(filename, terrainStream);
  709. terrainStream.Close();
  710. FileInfo x = new FileInfo(filename);
  711. remoteClient.SendAlertMessage("Your terrain was loaded as a " + x.Extension + " file. It may take a few moments to appear.");
  712. }
  713. catch (IOException e)
  714. {
  715. m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
  716. remoteClient.SendAlertMessage("There was an IO Exception loading your terrain. Please check free space.");
  717. return;
  718. }
  719. catch (SecurityException e)
  720. {
  721. m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
  722. remoteClient.SendAlertMessage("There was a security Exception loading your terrain. Please check the security on the simulator drive");
  723. return;
  724. }
  725. catch (UnauthorizedAccessException e)
  726. {
  727. m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
  728. remoteClient.SendAlertMessage("There was a security Exception loading your terrain. Please check the security on the simulator drive");
  729. return;
  730. }
  731. catch (Exception e)
  732. {
  733. m_log.ErrorFormat("[TERRAIN]: Error loading a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
  734. remoteClient.SendAlertMessage("There was a general error loading your terrain. Please fix the terrain file and try again");
  735. }
  736. }
  737. else
  738. {
  739. remoteClient.SendAlertMessage("Unable to apply terrain. Cannot get an instance of the terrain module");
  740. }
  741. }
  742. private void handleUploadTerrain(IClientAPI remote_client, string clientFileName)
  743. {
  744. if (TerrainUploader == null)
  745. {
  746. TerrainUploader = new EstateTerrainXferHandler(remote_client, clientFileName);
  747. lock (TerrainUploader)
  748. {
  749. remote_client.OnXferReceive += TerrainUploader.XferReceive;
  750. remote_client.OnAbortXfer += AbortTerrainXferHandler;
  751. TerrainUploader.TerrainUploadDone += HandleTerrainApplication;
  752. }
  753. TerrainUploader.RequestStartXfer(remote_client);
  754. }
  755. else
  756. {
  757. remote_client.SendAlertMessage("Another Terrain Upload is in progress. Please wait your turn!");
  758. }
  759. }
  760. private void handleTerrainRequest(IClientAPI remote_client, string clientFileName)
  761. {
  762. // Save terrain here
  763. ITerrainModule terr = Scene.RequestModuleInterface<ITerrainModule>();
  764. if (terr != null)
  765. {
  766. m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + Scene.RegionInfo.RegionName);
  767. if (File.Exists(Util.dataDir() + "/terrain.raw"))
  768. {
  769. File.Delete(Util.dataDir() + "/terrain.raw");
  770. }
  771. terr.SaveToFile(Util.dataDir() + "/terrain.raw");
  772. FileStream input = new FileStream(Util.dataDir() + "/terrain.raw", FileMode.Open);
  773. byte[] bdata = new byte[input.Length];
  774. input.Read(bdata, 0, (int)input.Length);
  775. remote_client.SendAlertMessage("Terrain file written, starting download...");
  776. Scene.XferManager.AddNewFile("terrain.raw", bdata);
  777. // Tell client about it
  778. m_log.Warn("[CLIENT]: Sending Terrain to " + remote_client.Name);
  779. remote_client.SendInitiateDownload("terrain.raw", clientFileName);
  780. }
  781. }
  782. private void HandleRegionInfoRequest(IClientAPI remote_client)
  783. {
  784. RegionInfoForEstateMenuArgs args = new RegionInfoForEstateMenuArgs();
  785. args.billableFactor = Scene.RegionInfo.EstateSettings.BillableFactor;
  786. args.estateID = Scene.RegionInfo.EstateSettings.EstateID;
  787. args.maxAgents = (byte)Scene.RegionInfo.RegionSettings.AgentLimit;
  788. args.objectBonusFactor = (float)Scene.RegionInfo.RegionSettings.ObjectBonus;
  789. args.parentEstateID = Scene.RegionInfo.EstateSettings.ParentEstateID;
  790. args.pricePerMeter = Scene.RegionInfo.EstateSettings.PricePerMeter;
  791. args.redirectGridX = Scene.RegionInfo.EstateSettings.RedirectGridX;
  792. args.redirectGridY = Scene.RegionInfo.EstateSettings.RedirectGridY;
  793. args.regionFlags = GetRegionFlags();
  794. args.simAccess = Scene.RegionInfo.AccessLevel;
  795. args.sunHour = (float)Scene.RegionInfo.RegionSettings.SunPosition;
  796. args.terrainLowerLimit = (float)Scene.RegionInfo.RegionSettings.TerrainLowerLimit;
  797. args.terrainRaiseLimit = (float)Scene.RegionInfo.RegionSettings.TerrainRaiseLimit;
  798. args.useEstateSun = Scene.RegionInfo.RegionSettings.UseEstateSun;
  799. args.waterHeight = (float)Scene.RegionInfo.RegionSettings.WaterHeight;
  800. args.simName = Scene.RegionInfo.RegionName;
  801. args.regionType = Scene.RegionInfo.RegionType;
  802. remote_client.SendRegionInfoToEstateMenu(args);
  803. }
  804. private void HandleEstateCovenantRequest(IClientAPI remote_client)
  805. {
  806. remote_client.SendEstateCovenantInformation(Scene.RegionInfo.RegionSettings.Covenant);
  807. }
  808. private void HandleLandStatRequest(int parcelID, uint reportType, uint requestFlags, string filter, IClientAPI remoteClient)
  809. {
  810. if (!Scene.Permissions.CanIssueEstateCommand(remoteClient.AgentId, false))
  811. return;
  812. Dictionary<uint, float> sceneData = null;
  813. if (reportType == 1)
  814. {
  815. sceneData = Scene.PhysicsScene.GetTopColliders();
  816. }
  817. else if (reportType == 0)
  818. {
  819. IScriptModule scriptModule = Scene.RequestModuleInterface<IScriptModule>();
  820. if (scriptModule != null)
  821. sceneData = scriptModule.GetObjectScriptsExecutionTimes();
  822. }
  823. List<LandStatReportItem> SceneReport = new List<LandStatReportItem>();
  824. if (sceneData != null)
  825. {
  826. var sortedSceneData
  827. = sceneData.Select(
  828. item => new { Measurement = item.Value, Part = Scene.GetSceneObjectPart(item.Key) });
  829. sortedSceneData.OrderBy(item => item.Measurement);
  830. int items = 0;
  831. foreach (var entry in sortedSceneData)
  832. {
  833. // The object may have been deleted since we received the data.
  834. if (entry.Part == null)
  835. continue;
  836. // Don't show scripts that haven't executed or where execution time is below one microsecond in
  837. // order to produce a more readable report.
  838. if (entry.Measurement < 0.001)
  839. continue;
  840. items++;
  841. SceneObjectGroup so = entry.Part.ParentGroup;
  842. LandStatReportItem lsri = new LandStatReportItem();
  843. lsri.LocationX = so.AbsolutePosition.X;
  844. lsri.LocationY = so.AbsolutePosition.Y;
  845. lsri.LocationZ = so.AbsolutePosition.Z;
  846. lsri.Score = entry.Measurement;
  847. lsri.TaskID = so.UUID;
  848. lsri.TaskLocalID = so.LocalId;
  849. lsri.TaskName = entry.Part.Name;
  850. lsri.OwnerName = UserManager.GetUserName(so.OwnerID);
  851. if (filter.Length != 0)
  852. {
  853. if ((lsri.OwnerName.Contains(filter) || lsri.TaskName.Contains(filter)))
  854. {
  855. }
  856. else
  857. {
  858. continue;
  859. }
  860. }
  861. SceneReport.Add(lsri);
  862. if (items >= 100)
  863. break;
  864. }
  865. }
  866. remoteClient.SendLandStatReply(reportType, requestFlags, (uint)SceneReport.Count,SceneReport.ToArray());
  867. }
  868. #endregion
  869. #region Outgoing Packets
  870. public void sendRegionInfoPacketToAll()
  871. {
  872. Scene.ForEachRootClient(delegate(IClientAPI client)
  873. {
  874. HandleRegionInfoRequest(client);
  875. });
  876. }
  877. public void sendRegionHandshake(IClientAPI remoteClient)
  878. {
  879. RegionHandshakeArgs args = new RegionHandshakeArgs();
  880. args.isEstateManager = Scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(remoteClient.AgentId);
  881. if (Scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero && Scene.RegionInfo.EstateSettings.EstateOwner == remoteClient.AgentId)
  882. args.isEstateManager = true;
  883. args.billableFactor = Scene.RegionInfo.EstateSettings.BillableFactor;
  884. args.terrainStartHeight0 = (float)Scene.RegionInfo.RegionSettings.Elevation1SW;
  885. args.terrainHeightRange0 = (float)Scene.RegionInfo.RegionSettings.Elevation2SW;
  886. args.terrainStartHeight1 = (float)Scene.RegionInfo.RegionSettings.Elevation1NW;
  887. args.terrainHeightRange1 = (float)Scene.RegionInfo.RegionSettings.Elevation2NW;
  888. args.terrainStartHeight2 = (float)Scene.RegionInfo.RegionSettings.Elevation1SE;
  889. args.terrainHeightRange2 = (float)Scene.RegionInfo.RegionSettings.Elevation2SE;
  890. args.terrainStartHeight3 = (float)Scene.RegionInfo.RegionSettings.Elevation1NE;
  891. args.terrainHeightRange3 = (float)Scene.RegionInfo.RegionSettings.Elevation2NE;
  892. args.simAccess = Scene.RegionInfo.AccessLevel;
  893. args.waterHeight = (float)Scene.RegionInfo.RegionSettings.WaterHeight;
  894. args.regionFlags = GetRegionFlags();
  895. args.regionName = Scene.RegionInfo.RegionName;
  896. args.SimOwner = Scene.RegionInfo.EstateSettings.EstateOwner;
  897. args.terrainBase0 = UUID.Zero;
  898. args.terrainBase1 = UUID.Zero;
  899. args.terrainBase2 = UUID.Zero;
  900. args.terrainBase3 = UUID.Zero;
  901. args.terrainDetail0 = Scene.RegionInfo.RegionSettings.TerrainTexture1;
  902. args.terrainDetail1 = Scene.RegionInfo.RegionSettings.TerrainTexture2;
  903. args.terrainDetail2 = Scene.RegionInfo.RegionSettings.TerrainTexture3;
  904. args.terrainDetail3 = Scene.RegionInfo.RegionSettings.TerrainTexture4;
  905. // m_log.DebugFormat("[ESTATE MANAGEMENT MODULE]: Sending terrain texture 1 {0} for region {1}", args.terrainDetail0, Scene.RegionInfo.RegionName);
  906. // m_log.DebugFormat("[ESTATE MANAGEMENT MODULE]: Sending terrain texture 2 {0} for region {1}", args.terrainDetail1, Scene.RegionInfo.RegionName);
  907. // m_log.DebugFormat("[ESTATE MANAGEMENT MODULE]: Sending terrain texture 3 {0} for region {1}", args.terrainDetail2, Scene.RegionInfo.RegionName);
  908. // m_log.DebugFormat("[ESTATE MANAGEMENT MODULE]: Sending terrain texture 4 {0} for region {1}", args.terrainDetail3, Scene.RegionInfo.RegionName);
  909. remoteClient.SendRegionHandshake(Scene.RegionInfo,args);
  910. }
  911. public void sendRegionHandshakeToAll()
  912. {
  913. Scene.ForEachClient(sendRegionHandshake);
  914. }
  915. public void handleEstateChangeInfo(IClientAPI remoteClient, UUID invoice, UUID senderID, UInt32 parms1, UInt32 parms2)
  916. {
  917. if (parms2 == 0)
  918. {
  919. Scene.RegionInfo.EstateSettings.UseGlobalTime = true;
  920. Scene.RegionInfo.EstateSettings.SunPosition = 0.0;
  921. }
  922. else
  923. {
  924. Scene.RegionInfo.EstateSettings.UseGlobalTime = false;
  925. Scene.RegionInfo.EstateSettings.SunPosition = (parms2 - 0x1800)/1024.0;
  926. }
  927. if ((parms1 & 0x00000010) != 0)
  928. Scene.RegionInfo.EstateSettings.FixedSun = true;
  929. else
  930. Scene.RegionInfo.EstateSettings.FixedSun = false;
  931. if ((parms1 & 0x00008000) != 0)
  932. Scene.RegionInfo.EstateSettings.PublicAccess = true;
  933. else
  934. Scene.RegionInfo.EstateSettings.PublicAccess = false;
  935. if ((parms1 & 0x10000000) != 0)
  936. Scene.RegionInfo.EstateSettings.AllowVoice = true;
  937. else
  938. Scene.RegionInfo.EstateSettings.AllowVoice = false;
  939. if ((parms1 & 0x00100000) != 0)
  940. Scene.RegionInfo.EstateSettings.AllowDirectTeleport = true;
  941. else
  942. Scene.RegionInfo.EstateSettings.AllowDirectTeleport = false;
  943. if ((parms1 & 0x00800000) != 0)
  944. Scene.RegionInfo.EstateSettings.DenyAnonymous = true;
  945. else
  946. Scene.RegionInfo.EstateSettings.DenyAnonymous = false;
  947. if ((parms1 & 0x01000000) != 0)
  948. Scene.RegionInfo.EstateSettings.DenyIdentified = true;
  949. else
  950. Scene.RegionInfo.EstateSettings.DenyIdentified = false;
  951. if ((parms1 & 0x02000000) != 0)
  952. Scene.RegionInfo.EstateSettings.DenyTransacted = true;
  953. else
  954. Scene.RegionInfo.EstateSettings.DenyTransacted = false;
  955. if ((parms1 & 0x40000000) != 0)
  956. Scene.RegionInfo.EstateSettings.DenyMinors = true;
  957. else
  958. Scene.RegionInfo.EstateSettings.DenyMinors = false;
  959. Scene.RegionInfo.EstateSettings.Save();
  960. TriggerEstateInfoChange();
  961. Scene.TriggerEstateSunUpdate();
  962. sendDetailedEstateData(remoteClient, invoice);
  963. }
  964. #endregion
  965. #region Other Functions
  966. public void changeWaterHeight(float height)
  967. {
  968. setRegionTerrainSettings(height,
  969. (float)Scene.RegionInfo.RegionSettings.TerrainRaiseLimit,
  970. (float)Scene.RegionInfo.RegionSettings.TerrainLowerLimit,
  971. Scene.RegionInfo.RegionSettings.UseEstateSun,
  972. Scene.RegionInfo.RegionSettings.FixedSun,
  973. (float)Scene.RegionInfo.RegionSettings.SunPosition,
  974. Scene.RegionInfo.EstateSettings.UseGlobalTime,
  975. Scene.RegionInfo.EstateSettings.FixedSun,
  976. (float)Scene.RegionInfo.EstateSettings.SunPosition);
  977. sendRegionInfoPacketToAll();
  978. }
  979. #endregion
  980. private void EventManager_OnNewClient(IClientAPI client)
  981. {
  982. client.OnDetailedEstateDataRequest += sendDetailedEstateData;
  983. client.OnSetEstateFlagsRequest += estateSetRegionInfoHandler;
  984. // client.OnSetEstateTerrainBaseTexture += setEstateTerrainBaseTexture;
  985. client.OnSetEstateTerrainDetailTexture += setEstateTerrainBaseTexture;
  986. client.OnSetEstateTerrainTextureHeights += setEstateTerrainTextureHeights;
  987. client.OnCommitEstateTerrainTextureRequest += handleCommitEstateTerrainTextureRequest;
  988. client.OnSetRegionTerrainSettings += setRegionTerrainSettings;
  989. client.OnEstateRestartSimRequest += handleEstateRestartSimRequest;
  990. client.OnEstateChangeCovenantRequest += handleChangeEstateCovenantRequest;
  991. client.OnEstateChangeInfo += handleEstateChangeInfo;
  992. client.OnEstateManageTelehub += handleOnEstateManageTelehub;
  993. client.OnUpdateEstateAccessDeltaRequest += handleEstateAccessDeltaRequest;
  994. client.OnSimulatorBlueBoxMessageRequest += SendSimulatorBlueBoxMessage;
  995. client.OnEstateBlueBoxMessageRequest += SendEstateBlueBoxMessage;
  996. client.OnEstateDebugRegionRequest += handleEstateDebugRegionRequest;
  997. client.OnEstateTeleportOneUserHomeRequest += handleEstateTeleportOneUserHomeRequest;
  998. client.OnEstateTeleportAllUsersHomeRequest += handleEstateTeleportAllUsersHomeRequest;
  999. client.OnRequestTerrain += handleTerrainRequest;
  1000. client.OnUploadTerrain += handleUploadTerrain;
  1001. client.OnRegionInfoRequest += HandleRegionInfoRequest;
  1002. client.OnEstateCovenantRequest += HandleEstateCovenantRequest;
  1003. client.OnLandStatRequest += HandleLandStatRequest;
  1004. sendRegionHandshake(client);
  1005. }
  1006. public uint GetRegionFlags()
  1007. {
  1008. RegionFlags flags = RegionFlags.None;
  1009. // Fully implemented
  1010. //
  1011. if (Scene.RegionInfo.RegionSettings.AllowDamage)
  1012. flags |= RegionFlags.AllowDamage;
  1013. if (Scene.RegionInfo.RegionSettings.BlockTerraform)
  1014. flags |= RegionFlags.BlockTerraform;
  1015. if (!Scene.RegionInfo.RegionSettings.AllowLandResell)
  1016. flags |= RegionFlags.BlockLandResell;
  1017. if (Scene.RegionInfo.RegionSettings.DisableCollisions)
  1018. flags |= RegionFlags.SkipCollisions;
  1019. if (Scene.RegionInfo.RegionSettings.DisableScripts)
  1020. flags |= RegionFlags.SkipScripts;
  1021. if (Scene.RegionInfo.RegionSettings.DisablePhysics)
  1022. flags |= RegionFlags.SkipPhysics;
  1023. if (Scene.RegionInfo.RegionSettings.BlockFly)
  1024. flags |= RegionFlags.NoFly;
  1025. if (Scene.RegionInfo.RegionSettings.RestrictPushing)
  1026. flags |= RegionFlags.RestrictPushObject;
  1027. if (Scene.RegionInfo.RegionSettings.AllowLandJoinDivide)
  1028. flags |= RegionFlags.AllowParcelChanges;
  1029. if (Scene.RegionInfo.RegionSettings.BlockShowInSearch)
  1030. flags |= RegionFlags.BlockParcelSearch;
  1031. if (Scene.RegionInfo.RegionSettings.FixedSun)
  1032. flags |= RegionFlags.SunFixed;
  1033. if (Scene.RegionInfo.RegionSettings.Sandbox)
  1034. flags |= RegionFlags.Sandbox;
  1035. if (Scene.RegionInfo.EstateSettings.AllowVoice)
  1036. flags |= RegionFlags.AllowVoice;
  1037. // Fudge these to always on, so the menu options activate
  1038. //
  1039. flags |= RegionFlags.AllowLandmark;
  1040. flags |= RegionFlags.AllowSetHome;
  1041. // TODO: SkipUpdateInterestList
  1042. // Omitted
  1043. //
  1044. // Omitted: NullLayer (what is that?)
  1045. // Omitted: SkipAgentAction (what does it do?)
  1046. return (uint)flags;
  1047. }
  1048. public uint GetEstateFlags()
  1049. {
  1050. RegionFlags flags = RegionFlags.None;
  1051. if (Scene.RegionInfo.EstateSettings.FixedSun)
  1052. flags |= RegionFlags.SunFixed;
  1053. if (Scene.RegionInfo.EstateSettings.PublicAccess)
  1054. flags |= (RegionFlags.PublicAllowed |
  1055. RegionFlags.ExternallyVisible);
  1056. if (Scene.RegionInfo.EstateSettings.AllowVoice)
  1057. flags |= RegionFlags.AllowVoice;
  1058. if (Scene.RegionInfo.EstateSettings.AllowDirectTeleport)
  1059. flags |= RegionFlags.AllowDirectTeleport;
  1060. if (Scene.RegionInfo.EstateSettings.DenyAnonymous)
  1061. flags |= RegionFlags.DenyAnonymous;
  1062. if (Scene.RegionInfo.EstateSettings.DenyIdentified)
  1063. flags |= RegionFlags.DenyIdentified;
  1064. if (Scene.RegionInfo.EstateSettings.DenyTransacted)
  1065. flags |= RegionFlags.DenyTransacted;
  1066. if (Scene.RegionInfo.EstateSettings.AbuseEmailToEstateOwner)
  1067. flags |= RegionFlags.AbuseEmailToEstateOwner;
  1068. if (Scene.RegionInfo.EstateSettings.BlockDwell)
  1069. flags |= RegionFlags.BlockDwell;
  1070. if (Scene.RegionInfo.EstateSettings.EstateSkipScripts)
  1071. flags |= RegionFlags.EstateSkipScripts;
  1072. if (Scene.RegionInfo.EstateSettings.ResetHomeOnTeleport)
  1073. flags |= RegionFlags.ResetHomeOnTeleport;
  1074. if (Scene.RegionInfo.EstateSettings.TaxFree)
  1075. flags |= RegionFlags.TaxFree;
  1076. if (Scene.RegionInfo.EstateSettings.DenyMinors)
  1077. flags |= (RegionFlags)(1 << 30);
  1078. return (uint)flags;
  1079. }
  1080. public bool IsManager(UUID avatarID)
  1081. {
  1082. if (avatarID == Scene.RegionInfo.EstateSettings.EstateOwner)
  1083. return true;
  1084. List<UUID> ems = new List<UUID>(Scene.RegionInfo.EstateSettings.EstateManagers);
  1085. if (ems.Contains(avatarID))
  1086. return true;
  1087. return false;
  1088. }
  1089. public void TriggerRegionInfoChange()
  1090. {
  1091. ChangeDelegate change = OnRegionInfoChange;
  1092. if (change != null)
  1093. change(Scene.RegionInfo.RegionID);
  1094. }
  1095. public void TriggerEstateInfoChange()
  1096. {
  1097. ChangeDelegate change = OnEstateInfoChange;
  1098. if (change != null)
  1099. change(Scene.RegionInfo.RegionID);
  1100. }
  1101. public void TriggerEstateMessage(UUID fromID, string fromName, string message)
  1102. {
  1103. MessageDelegate onmessage = OnEstateMessage;
  1104. if (onmessage != null)
  1105. onmessage(Scene.RegionInfo.RegionID, fromID, fromName, message);
  1106. }
  1107. private void SendTelehubInfo(IClientAPI client)
  1108. {
  1109. RegionSettings settings =
  1110. this.Scene.RegionInfo.RegionSettings;
  1111. SceneObjectGroup telehub = null;
  1112. if (settings.TelehubObject != UUID.Zero &&
  1113. (telehub = Scene.GetSceneObjectGroup(settings.TelehubObject)) != null)
  1114. {
  1115. List<Vector3> spawnPoints = new List<Vector3>();
  1116. foreach (SpawnPoint sp in settings.SpawnPoints())
  1117. {
  1118. spawnPoints.Add(sp.GetLocation(Vector3.Zero, Quaternion.Identity));
  1119. }
  1120. client.SendTelehubInfo(settings.TelehubObject,
  1121. telehub.Name,
  1122. telehub.AbsolutePosition,
  1123. telehub.GroupRotation,
  1124. spawnPoints);
  1125. }
  1126. else
  1127. {
  1128. client.SendTelehubInfo(UUID.Zero,
  1129. String.Empty,
  1130. Vector3.Zero,
  1131. Quaternion.Identity,
  1132. new List<Vector3>());
  1133. }
  1134. }
  1135. }
  1136. }