EstateManagementModule.cs 60 KB

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