EstateManager.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  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 OpenSim 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. */
  28. using System;
  29. using System.Collections.Generic;
  30. using System.Text;
  31. using libsecondlife;
  32. using libsecondlife.Packets;
  33. using OpenSim.Framework;
  34. using OpenSim.Framework.Console;
  35. using OpenSim.Region.Environment.Scenes;
  36. namespace OpenSim.Region.Environment
  37. {
  38. /// <summary>
  39. /// Processes requests regarding estates. Refer to EstateSettings.cs in OpenSim.Framework. Types for all of the core settings
  40. /// </summary>
  41. public class EstateManager
  42. {
  43. private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  44. private Scene m_scene;
  45. private RegionInfo m_regInfo;
  46. public enum EstateAccessCodex : uint
  47. {
  48. AccessOptions = 17,
  49. AllowedGroups = 18,
  50. EstateBans = 20,
  51. EstateManagers = 24
  52. }
  53. public EstateManager(Scene scene, RegionInfo reginfo)
  54. {
  55. m_scene = scene;
  56. m_regInfo = reginfo;
  57. }
  58. private bool convertParamStringToBool(byte[] field)
  59. {
  60. string s = Helpers.FieldToUTF8String(field);
  61. if (s == "1" || s.ToLower() == "y" || s.ToLower() == "yes" || s.ToLower() == "t" || s.ToLower() == "true")
  62. {
  63. return true;
  64. }
  65. return false;
  66. }
  67. /// <summary>
  68. /// Sets terrain texture heights for each of the four corners of the region - textures are distributed as a linear range between the two heights.
  69. /// </summary>
  70. /// <param name="corner">Which corner</param>
  71. /// <param name="lowValue">Minimum height that texture range should cover</param>
  72. /// <param name="highValue">Maximum height that texture range should cover</param>
  73. public void setEstateTextureRange(Int16 corner, float lowValue, float highValue)
  74. {
  75. switch (corner)
  76. {
  77. case 0:
  78. m_regInfo.EstateSettings.terrainStartHeight0 = lowValue;
  79. m_regInfo.EstateSettings.terrainHeightRange0 = highValue;
  80. break;
  81. case 1:
  82. m_regInfo.EstateSettings.terrainStartHeight1 = lowValue;
  83. m_regInfo.EstateSettings.terrainHeightRange1 = highValue;
  84. break;
  85. case 2:
  86. m_regInfo.EstateSettings.terrainStartHeight2 = lowValue;
  87. m_regInfo.EstateSettings.terrainHeightRange2 = highValue;
  88. break;
  89. case 3:
  90. m_regInfo.EstateSettings.terrainStartHeight3 = lowValue;
  91. m_regInfo.EstateSettings.terrainHeightRange3 = highValue;
  92. break;
  93. }
  94. }
  95. /// <summary>
  96. /// Sets the 'detail' terrain texture on each of the bands.
  97. /// </summary>
  98. /// <param name="band">Which texture band</param>
  99. /// <param name="textureUUID">The UUID of the texture</param>
  100. public void setTerrainTexture(Int16 band, LLUUID textureUUID)
  101. {
  102. switch (band)
  103. {
  104. case 0:
  105. m_regInfo.EstateSettings.terrainDetail0 = textureUUID;
  106. break;
  107. case 1:
  108. m_regInfo.EstateSettings.terrainDetail1 = textureUUID;
  109. break;
  110. case 2:
  111. m_regInfo.EstateSettings.terrainDetail2 = textureUUID;
  112. break;
  113. case 3:
  114. m_regInfo.EstateSettings.terrainDetail3 = textureUUID;
  115. break;
  116. }
  117. }
  118. /// <summary>
  119. /// Sets common region settings
  120. /// </summary>
  121. /// <param name="WaterHeight">Water height of the waterplane (may not nessecarily be one value)</param>
  122. /// <param name="TerrainRaiseLimit">Maximum amount terrain can be raised from previous baking</param>
  123. /// <param name="TerrainLowerLimit">Minimum amount terrain can be lowered from previous baking</param>
  124. /// <param name="UseFixedSun">Use a fixed time of day on the sun?</param>
  125. /// <param name="SunHour">The offset hour of the day</param>
  126. public void setRegionSettings(float WaterHeight, float TerrainRaiseLimit, float TerrainLowerLimit,
  127. bool UseFixedSun, float SunHour)
  128. {
  129. // Water Height
  130. m_regInfo.EstateSettings.waterHeight = WaterHeight;
  131. m_scene.Terrain.watermap.Fill(WaterHeight);
  132. // Terraforming limits
  133. m_regInfo.EstateSettings.terrainRaiseLimit = TerrainRaiseLimit;
  134. m_regInfo.EstateSettings.terrainLowerLimit = TerrainLowerLimit;
  135. m_scene.Terrain.maxRaise = TerrainRaiseLimit;
  136. m_scene.Terrain.minLower = TerrainLowerLimit;
  137. // Time of day / fixed sun
  138. m_regInfo.EstateSettings.useFixedSun = UseFixedSun;
  139. m_regInfo.EstateSettings.sunHour = SunHour;
  140. }
  141. #region Packet Handlers
  142. public void handleEstateOwnerMessage(EstateOwnerMessagePacket packet, IClientAPI remote_client)
  143. {
  144. switch (Helpers.FieldToUTF8String(packet.MethodData.Method))
  145. {
  146. case "getinfo":
  147. //m_log.Info("[ESTATE]: CLIENT--->" + packet.ToString());
  148. sendRegionInfoPacketToAll();
  149. if (m_scene.PermissionsMngr.GenericEstatePermission(remote_client.AgentId))
  150. {
  151. sendDetailedEstateData(remote_client, packet);
  152. }
  153. break;
  154. case "setregioninfo":
  155. if (m_scene.PermissionsMngr.CanEditEstateTerrain(remote_client.AgentId))
  156. estateSetRegionInfoHandler(packet);
  157. break;
  158. case "texturebase":
  159. if (m_scene.PermissionsMngr.CanEditEstateTerrain(remote_client.AgentId))
  160. estateTextureBaseHandler(packet);
  161. break;
  162. case "texturedetail":
  163. if (m_scene.PermissionsMngr.CanEditEstateTerrain(remote_client.AgentId))
  164. estateTextureDetailHandler(packet);
  165. break;
  166. case "textureheights":
  167. if (m_scene.PermissionsMngr.CanEditEstateTerrain(remote_client.AgentId))
  168. estateTextureHeightsHandler(packet);
  169. break;
  170. case "texturecommit":
  171. sendRegionHandshakeToAll();
  172. break;
  173. case "setregionterrain":
  174. if (m_scene.PermissionsMngr.CanEditEstateTerrain(remote_client.AgentId))
  175. estateSetRegionTerrainHandler(packet);
  176. break;
  177. case "restart":
  178. if (m_scene.PermissionsMngr.CanRestartSim(remote_client.AgentId))
  179. {
  180. estateRestartSim(packet);
  181. }
  182. break;
  183. case "estatechangecovenantid":
  184. if (m_scene.PermissionsMngr.CanEditEstateTerrain(remote_client.AgentId))
  185. {
  186. EstateChangeCovenant(packet);
  187. }
  188. break;
  189. case "estateaccessdelta": // Estate access delta manages the banlist and allow list too.
  190. if (m_scene.PermissionsMngr.GenericEstatePermission(remote_client.AgentId))
  191. {
  192. estateAccessDelta(remote_client, packet);
  193. }
  194. break;
  195. case "simulatormessage":
  196. if (m_scene.PermissionsMngr.GenericEstatePermission(remote_client.AgentId))
  197. {
  198. SendSimulatorBlueBoxMessage(remote_client, packet);
  199. }
  200. break;
  201. case "instantmessage":
  202. if (m_scene.PermissionsMngr.GenericEstatePermission(remote_client.AgentId))
  203. {
  204. SendEstateBlueBoxMessage(remote_client, packet);
  205. }
  206. break;
  207. case "setregiondebug":
  208. if (m_scene.PermissionsMngr.GenericEstatePermission(remote_client.AgentId))
  209. {
  210. SetRegionDebug(remote_client, packet);
  211. }
  212. break;
  213. default:
  214. m_log.Error("EstateOwnerMessage: Unknown method requested\n" + packet.ToString());
  215. break;
  216. }
  217. }
  218. private void SetRegionDebug(IClientAPI remote_client, EstateOwnerMessagePacket packet)
  219. {
  220. LLUUID invoice = packet.MethodData.Invoice;
  221. LLUUID SenderID = packet.AgentData.AgentID;
  222. bool scripted = convertParamStringToBool(packet.ParamList[0].Parameter);
  223. bool collisionEvents = convertParamStringToBool(packet.ParamList[1].Parameter);
  224. bool physics = convertParamStringToBool(packet.ParamList[2].Parameter);
  225. if (physics)
  226. {
  227. m_scene.RegionInfo.EstateSettings.regionFlags |= Simulator.RegionFlags.SkipPhysics;
  228. }
  229. else
  230. {
  231. m_scene.RegionInfo.EstateSettings.regionFlags &= ~Simulator.RegionFlags.SkipPhysics;
  232. }
  233. if (scripted)
  234. {
  235. m_scene.RegionInfo.EstateSettings.regionFlags |= Simulator.RegionFlags.SkipScripts;
  236. }
  237. else
  238. {
  239. m_scene.RegionInfo.EstateSettings.regionFlags &= ~Simulator.RegionFlags.SkipScripts;
  240. }
  241. m_scene.SetSceneCoreDebug(scripted, collisionEvents, physics);
  242. }
  243. private void SendSimulatorBlueBoxMessage(IClientAPI remote_client, EstateOwnerMessagePacket packet)
  244. {
  245. LLUUID invoice = packet.MethodData.Invoice;
  246. LLUUID SenderID = new LLUUID(Helpers.FieldToUTF8String(packet.ParamList[2].Parameter));
  247. string SenderName = Helpers.FieldToUTF8String(packet.ParamList[3].Parameter);
  248. string Message = Helpers.FieldToUTF8String(packet.ParamList[4].Parameter);
  249. m_scene.SendRegionMessageFromEstateTools(SenderID, packet.AgentData.SessionID, SenderName, Message);
  250. }
  251. private void SendEstateBlueBoxMessage(IClientAPI remote_client, EstateOwnerMessagePacket packet)
  252. {
  253. LLUUID invoice = packet.MethodData.Invoice;
  254. LLUUID SenderID = packet.AgentData.AgentID;
  255. string SenderName = Helpers.FieldToUTF8String(packet.ParamList[0].Parameter);
  256. string Message = Helpers.FieldToUTF8String(packet.ParamList[1].Parameter);
  257. m_scene.SendEstateMessageFromEstateTools(SenderID, packet.AgentData.SessionID, SenderName, Message);
  258. }
  259. private void sendDetailedEstateData(IClientAPI remote_client, EstateOwnerMessagePacket packet)
  260. {
  261. LLUUID invoice = packet.MethodData.Invoice;
  262. packet.AgentData.TransactionID = LLUUID.Random();
  263. packet.MethodData.Method = Helpers.StringToField("estateupdateinfo");
  264. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[9];
  265. for (int i = 0; i < 9; i++)
  266. {
  267. returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
  268. }
  269. //Sending Estate Settings
  270. returnblock[0].Parameter = Helpers.StringToField(m_scene.RegionInfo.MasterAvatarFirstName + m_scene.RegionInfo.MasterAvatarLastName);
  271. returnblock[1].Parameter = Helpers.StringToField(m_scene.RegionInfo.MasterAvatarAssignedUUID.ToString());
  272. returnblock[2].Parameter = Helpers.StringToField(m_scene.RegionInfo.EstateSettings.estateID.ToString());
  273. // TODO: Resolve Magic numbers here
  274. returnblock[3].Parameter = Helpers.StringToField("269516800");
  275. returnblock[4].Parameter = Helpers.StringToField("0");
  276. returnblock[5].Parameter = Helpers.StringToField("1");
  277. returnblock[6].Parameter = Helpers.StringToField(m_scene.RegionInfo.RegionID.ToString());
  278. returnblock[7].Parameter = Helpers.StringToField("1160895077");
  279. returnblock[8].Parameter = Helpers.StringToField("1");
  280. packet.ParamList = returnblock;
  281. //m_log.Info("[ESTATE]: SIM--->" + packet.ToString());
  282. remote_client.OutPacket(packet, ThrottleOutPacketType.Task);
  283. sendEstateManagerList(remote_client, packet);
  284. }
  285. private void sendEstateManagerList(IClientAPI remote_client, EstateOwnerMessagePacket packet)
  286. {
  287. LLUUID invoice = packet.MethodData.Invoice;
  288. //Sending Estate Managers
  289. packet = new EstateOwnerMessagePacket();
  290. packet.AgentData.TransactionID = LLUUID.Random();
  291. packet.AgentData.AgentID = remote_client.AgentId;
  292. packet.AgentData.SessionID = remote_client.SessionId;
  293. packet.MethodData.Invoice = invoice;
  294. packet.MethodData.Method = Helpers.StringToField("setaccess");
  295. LLUUID[] EstateManagers = m_scene.RegionInfo.EstateSettings.estateManagers;
  296. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + EstateManagers.Length];
  297. for (int i = 0; i < (6 + EstateManagers.Length); i++)
  298. {
  299. returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
  300. }
  301. int j = 0;
  302. returnblock[j].Parameter = Helpers.StringToField(m_scene.RegionInfo.EstateSettings.estateID.ToString()); j++;
  303. returnblock[j].Parameter = Helpers.StringToField(((int)EstateAccessCodex.EstateManagers).ToString()); j++;
  304. returnblock[j].Parameter = Helpers.StringToField("0"); j++;
  305. returnblock[j].Parameter = Helpers.StringToField("0"); j++;
  306. returnblock[j].Parameter = Helpers.StringToField("0"); j++;
  307. returnblock[j].Parameter = Helpers.StringToField(EstateManagers.Length.ToString()); j++;
  308. for (int i = 0; i < EstateManagers.Length; i++)
  309. {
  310. returnblock[j].Parameter = EstateManagers[i].GetBytes(); j++;
  311. }
  312. packet.ParamList = returnblock;
  313. //m_log.Info("[ESTATE]: SIM--->" + packet.ToString());
  314. remote_client.OutPacket(packet, ThrottleOutPacketType.Task);
  315. }
  316. private void estateAccessDelta(IClientAPI remote_client, EstateOwnerMessagePacket packet)
  317. {
  318. // EstateAccessDelta handles Estate Managers, Sim Access, Sim Banlist, allowed Groups.. etc.
  319. int estateAccessType = Convert.ToInt16(Helpers.FieldToUTF8String(packet.ParamList[1].Parameter));
  320. switch (estateAccessType)
  321. {
  322. case 256:
  323. // This needs to be updated for SuperEstateOwnerUser.. a non existing user in the estatesettings.xml
  324. // So make sure you really trust your region owners. because they can add other estate manaagers to your other estates
  325. if (packet.AgentData.AgentID == m_scene.RegionInfo.MasterAvatarAssignedUUID || m_scene.PermissionsMngr.BypassPermissions)
  326. {
  327. m_scene.RegionInfo.EstateSettings.AddEstateManager(new LLUUID(Helpers.FieldToUTF8String(packet.ParamList[2].Parameter)));
  328. sendEstateManagerList(remote_client, packet);
  329. }
  330. else
  331. {
  332. remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
  333. }
  334. break;
  335. case 512:
  336. // This needs to be updated for SuperEstateOwnerUser.. a non existing user in the estatesettings.xml
  337. // So make sure you really trust your region owners. because they can add other estate manaagers to your other estates
  338. if (packet.AgentData.AgentID == m_scene.RegionInfo.MasterAvatarAssignedUUID || m_scene.PermissionsMngr.BypassPermissions)
  339. {
  340. m_scene.RegionInfo.EstateSettings.RemoveEstateManager(new LLUUID(Helpers.FieldToUTF8String(packet.ParamList[2].Parameter)));
  341. sendEstateManagerList(remote_client, packet);
  342. }
  343. else
  344. {
  345. remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
  346. }
  347. break;
  348. default:
  349. m_log.Error("EstateOwnerMessage: Unknown EstateAccessType requested in estateAccessDelta\n" + packet.ToString());
  350. break;
  351. }
  352. //m_log.Error("EstateOwnerMessage: estateAccessDelta\n" + packet.ToString());
  353. }
  354. private void estateSetRegionInfoHandler(EstateOwnerMessagePacket packet)
  355. {
  356. if (packet.ParamList.Length != 9)
  357. {
  358. m_log.Error("EstateOwnerMessage: SetRegionInfo method has a ParamList of invalid length");
  359. }
  360. else
  361. {
  362. m_regInfo.EstateSettings.regionFlags = Simulator.RegionFlags.None;
  363. if (convertParamStringToBool(packet.ParamList[0].Parameter))
  364. {
  365. m_regInfo.EstateSettings.regionFlags = m_regInfo.EstateSettings.regionFlags |
  366. Simulator.RegionFlags.BlockTerraform;
  367. }
  368. if (convertParamStringToBool(packet.ParamList[1].Parameter))
  369. {
  370. m_regInfo.EstateSettings.regionFlags = m_regInfo.EstateSettings.regionFlags |
  371. Simulator.RegionFlags.NoFly;
  372. }
  373. if (convertParamStringToBool(packet.ParamList[2].Parameter))
  374. {
  375. m_regInfo.EstateSettings.regionFlags = m_regInfo.EstateSettings.regionFlags |
  376. Simulator.RegionFlags.AllowDamage;
  377. }
  378. if (convertParamStringToBool(packet.ParamList[3].Parameter) == false)
  379. {
  380. m_regInfo.EstateSettings.regionFlags = m_regInfo.EstateSettings.regionFlags |
  381. Simulator.RegionFlags.BlockLandResell;
  382. }
  383. int tempMaxAgents =
  384. Convert.ToInt16(Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[4].Parameter)));
  385. m_regInfo.EstateSettings.maxAgents = (byte) tempMaxAgents;
  386. float tempObjectBonusFactor =
  387. (float) Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter));
  388. m_regInfo.EstateSettings.objectBonusFactor = tempObjectBonusFactor;
  389. int tempMatureLevel = Convert.ToInt16(Helpers.FieldToUTF8String(packet.ParamList[6].Parameter));
  390. m_regInfo.EstateSettings.simAccess = (Simulator.SimAccess) tempMatureLevel;
  391. if (convertParamStringToBool(packet.ParamList[7].Parameter))
  392. {
  393. m_regInfo.EstateSettings.regionFlags = m_regInfo.EstateSettings.regionFlags |
  394. Simulator.RegionFlags.RestrictPushObject;
  395. }
  396. if (convertParamStringToBool(packet.ParamList[8].Parameter))
  397. {
  398. m_regInfo.EstateSettings.regionFlags = m_regInfo.EstateSettings.regionFlags |
  399. Simulator.RegionFlags.AllowParcelChanges;
  400. }
  401. sendRegionInfoPacketToAll();
  402. }
  403. }
  404. private void estateSetRegionTerrainHandler(EstateOwnerMessagePacket packet)
  405. {
  406. if (packet.ParamList.Length != 9)
  407. {
  408. m_log.Error("EstateOwnerMessage: SetRegionTerrain method has a ParamList of invalid length");
  409. }
  410. else
  411. {
  412. try
  413. {
  414. string tmp;
  415. tmp = Helpers.FieldToUTF8String(packet.ParamList[0].Parameter);
  416. if (!tmp.Contains(".")) tmp += ".00";
  417. float WaterHeight = (float)Convert.ToDecimal(tmp);
  418. tmp = Helpers.FieldToUTF8String(packet.ParamList[1].Parameter);
  419. if (!tmp.Contains(".")) tmp += ".00";
  420. float TerrainRaiseLimit = (float)Convert.ToDecimal(tmp);
  421. tmp = Helpers.FieldToUTF8String(packet.ParamList[2].Parameter);
  422. if (!tmp.Contains(".")) tmp += ".00";
  423. float TerrainLowerLimit = (float)Convert.ToDecimal(tmp);
  424. bool UseFixedSun = convertParamStringToBool(packet.ParamList[4].Parameter);
  425. float SunHour = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter));
  426. setRegionSettings(WaterHeight, TerrainRaiseLimit, TerrainLowerLimit, UseFixedSun, SunHour);
  427. sendRegionInfoPacketToAll();
  428. }
  429. catch (Exception ex)
  430. {
  431. m_log.Error("EstateManager: Exception while setting terrain settings: \n" + packet.ToString() + "\n" + ex.ToString());
  432. }
  433. }
  434. }
  435. private void estateTextureHeightsHandler(EstateOwnerMessagePacket packet)
  436. {
  437. foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
  438. {
  439. string s = Helpers.FieldToUTF8String(block.Parameter);
  440. string[] splitField = s.Split(' ');
  441. if (splitField.Length == 3)
  442. {
  443. Int16 corner = Convert.ToInt16(splitField[0]);
  444. float lowValue = (float) Convert.ToDecimal(splitField[1]);
  445. float highValue = (float) Convert.ToDecimal(splitField[2]);
  446. setEstateTextureRange(corner, lowValue, highValue);
  447. }
  448. }
  449. }
  450. private void estateTextureDetailHandler(EstateOwnerMessagePacket packet)
  451. {
  452. foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
  453. {
  454. string s = Helpers.FieldToUTF8String(block.Parameter);
  455. string[] splitField = s.Split(' ');
  456. if (splitField.Length == 2)
  457. {
  458. Int16 corner = Convert.ToInt16(splitField[0]);
  459. LLUUID textureUUID = new LLUUID(splitField[1]);
  460. setTerrainTexture(corner, textureUUID);
  461. }
  462. }
  463. }
  464. private void estateTextureBaseHandler(EstateOwnerMessagePacket packet)
  465. {
  466. foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
  467. {
  468. string s = Helpers.FieldToUTF8String(block.Parameter);
  469. string[] splitField = s.Split(' ');
  470. if (splitField.Length == 2)
  471. {
  472. LLUUID tempUUID = new LLUUID(splitField[1]);
  473. switch (Convert.ToInt16(splitField[0]))
  474. {
  475. case 0:
  476. m_regInfo.EstateSettings.terrainBase0 = tempUUID;
  477. break;
  478. case 1:
  479. m_regInfo.EstateSettings.terrainBase1 = tempUUID;
  480. break;
  481. case 2:
  482. m_regInfo.EstateSettings.terrainBase2 = tempUUID;
  483. break;
  484. case 3:
  485. m_regInfo.EstateSettings.terrainBase3 = tempUUID;
  486. break;
  487. }
  488. }
  489. }
  490. }
  491. private void estateRestartSim(EstateOwnerMessagePacket packet)
  492. {
  493. // There's only 1 block in the estateResetSim.. and that's the number of seconds till restart.
  494. foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
  495. {
  496. float timeSeconds = 0;
  497. Helpers.TryParse(Helpers.FieldToUTF8String(block.Parameter), out timeSeconds);
  498. timeSeconds = (int)timeSeconds;
  499. m_scene.Restart(timeSeconds);
  500. }
  501. }
  502. private void EstateChangeCovenant(EstateOwnerMessagePacket packet)
  503. {
  504. foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList)
  505. {
  506. LLUUID newCovenantID = new LLUUID(Helpers.FieldToUTF8String(block.Parameter));
  507. m_regInfo.CovenantID = newCovenantID;
  508. m_scene.RegionInfo.SaveEstatecovenantUUID(newCovenantID);
  509. }
  510. }
  511. public void HandleRegionInfoRequest(IClientAPI client, LLUUID sessionID)
  512. {
  513. RegionInfoPacket rinfopack = new RegionInfoPacket();
  514. RegionInfoPacket.RegionInfoBlock rinfoblk = new RegionInfoPacket.RegionInfoBlock();
  515. rinfoblk.BillableFactor = 0;
  516. rinfoblk.EstateID = 02;
  517. rinfoblk.MaxAgents = 100;
  518. rinfoblk.ObjectBonusFactor = 1.0f;
  519. rinfoblk.ParentEstateID = 0;
  520. rinfoblk.PricePerMeter = 0;
  521. rinfoblk.RedirectGridX = 0;
  522. rinfoblk.RedirectGridY = 0;
  523. rinfoblk.RegionFlags = (uint) m_regInfo.EstateSettings.regionFlags;
  524. rinfoblk.SimAccess = (byte) m_regInfo.EstateSettings.simAccess;
  525. rinfoblk.SunHour = m_regInfo.EstateSettings.sunHour;
  526. rinfoblk.TerrainLowerLimit = 20;
  527. rinfoblk.TerrainRaiseLimit = 20;
  528. rinfoblk.UseEstateSun = true;
  529. rinfoblk.WaterHeight = m_regInfo.EstateSettings.waterHeight;
  530. rinfoblk.SimName = Helpers.StringToField(m_regInfo.RegionName);
  531. rinfopack.RegionInfo = rinfoblk;
  532. client.OutPacket(rinfopack, ThrottleOutPacketType.Task);
  533. }
  534. public void HandleEstateCovenantRequest(IClientAPI client, LLUUID sessionID)
  535. {
  536. EstateCovenantReplyPacket einfopack = new EstateCovenantReplyPacket();
  537. EstateCovenantReplyPacket.DataBlock edata = new EstateCovenantReplyPacket.DataBlock();
  538. edata.CovenantID = m_regInfo.CovenantID;
  539. edata.CovenantTimestamp = 0;
  540. edata.EstateOwnerID = m_regInfo.MasterAvatarAssignedUUID;
  541. edata.EstateName =
  542. Helpers.StringToField(m_regInfo.MasterAvatarFirstName + " " + m_regInfo.MasterAvatarLastName);
  543. einfopack.Data = edata;
  544. client.OutPacket(einfopack, ThrottleOutPacketType.Task);
  545. }
  546. #endregion
  547. #region Outgoing Packets
  548. public void sendRegionInfoPacketToAll()
  549. {
  550. List<ScenePresence> avatars = m_scene.GetAvatars();
  551. for (int i = 0; i < avatars.Count; i++)
  552. {
  553. sendRegionInfoPacket(avatars[i].ControllingClient);
  554. }
  555. }
  556. public void sendRegionHandshakeToAll()
  557. {
  558. m_scene.Broadcast(
  559. sendRegionHandshake
  560. );
  561. }
  562. public void sendRegionInfoPacket(IClientAPI remote_client)
  563. {
  564. Encoding _enc = Encoding.ASCII;
  565. AgentCircuitData circuitData = remote_client.RequestClientInfo();
  566. RegionInfoPacket regionInfoPacket = new RegionInfoPacket();
  567. regionInfoPacket.AgentData.AgentID = circuitData.AgentID;
  568. regionInfoPacket.AgentData.SessionID = circuitData.SessionID;
  569. regionInfoPacket.RegionInfo.BillableFactor = m_regInfo.EstateSettings.billableFactor;
  570. regionInfoPacket.RegionInfo.EstateID = m_regInfo.EstateSettings.estateID;
  571. regionInfoPacket.RegionInfo.MaxAgents = m_regInfo.EstateSettings.maxAgents;
  572. regionInfoPacket.RegionInfo.ObjectBonusFactor = m_regInfo.EstateSettings.objectBonusFactor;
  573. regionInfoPacket.RegionInfo.ParentEstateID = m_regInfo.EstateSettings.parentEstateID;
  574. regionInfoPacket.RegionInfo.PricePerMeter = m_regInfo.EstateSettings.pricePerMeter;
  575. regionInfoPacket.RegionInfo.RedirectGridX = m_regInfo.EstateSettings.redirectGridX;
  576. regionInfoPacket.RegionInfo.RedirectGridY = m_regInfo.EstateSettings.redirectGridY;
  577. regionInfoPacket.RegionInfo.RegionFlags = (uint) m_regInfo.EstateSettings.regionFlags;
  578. regionInfoPacket.RegionInfo.SimAccess = (byte) m_regInfo.EstateSettings.simAccess;
  579. regionInfoPacket.RegionInfo.SimName = _enc.GetBytes(m_regInfo.RegionName);
  580. regionInfoPacket.RegionInfo.SunHour = m_regInfo.EstateSettings.sunHour;
  581. regionInfoPacket.RegionInfo.TerrainLowerLimit = m_regInfo.EstateSettings.terrainLowerLimit;
  582. regionInfoPacket.RegionInfo.TerrainRaiseLimit = m_regInfo.EstateSettings.terrainRaiseLimit;
  583. regionInfoPacket.RegionInfo.UseEstateSun = !m_regInfo.EstateSettings.useFixedSun;
  584. regionInfoPacket.RegionInfo.WaterHeight = m_regInfo.EstateSettings.waterHeight;
  585. remote_client.OutPacket(regionInfoPacket, ThrottleOutPacketType.Task);
  586. }
  587. public void sendRegionHandshake(IClientAPI remoteClient)
  588. {
  589. remoteClient.SendRegionHandshake(m_regInfo);
  590. }
  591. #endregion
  592. }
  593. }