EstateManagementModule.cs 52 KB

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