EstateManagementModule.cs 53 KB

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