EstateManagementModule.cs 54 KB

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