RegionSettings.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  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. using System;
  28. using System.IO;
  29. using OpenMetaverse;
  30. namespace OpenSim.Framework
  31. {
  32. public class RegionSettings
  33. {
  34. private ConfigurationMember configMember;
  35. public delegate void SaveDelegate(RegionSettings rs);
  36. public event SaveDelegate OnSave;
  37. /// <value>
  38. /// These appear to be terrain textures that are shipped with the client.
  39. /// </value>
  40. public static readonly UUID DEFAULT_TERRAIN_TEXTURE_1 = new UUID("b8d3965a-ad78-bf43-699b-bff8eca6c975");
  41. public static readonly UUID DEFAULT_TERRAIN_TEXTURE_2 = new UUID("abb783e6-3e93-26c0-248a-247666855da3");
  42. public static readonly UUID DEFAULT_TERRAIN_TEXTURE_3 = new UUID("179cdabd-398a-9b6b-1391-4dc333ba321f");
  43. public static readonly UUID DEFAULT_TERRAIN_TEXTURE_4 = new UUID("beb169c7-11ea-fff2-efe5-0f24dc881df2");
  44. public RegionSettings()
  45. {
  46. if (configMember == null)
  47. {
  48. try
  49. {
  50. configMember = new ConfigurationMember(Path.Combine(Util.configDir(), "estate_settings.xml"), "ESTATE SETTINGS", LoadConfigurationOptions, HandleIncomingConfiguration, true);
  51. configMember.performConfigurationRetrieve();
  52. }
  53. catch (Exception)
  54. {
  55. }
  56. }
  57. }
  58. public void LoadConfigurationOptions()
  59. {
  60. configMember.addConfigurationOption("region_flags",
  61. ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
  62. String.Empty, "336723974", true);
  63. configMember.addConfigurationOption("max_agents",
  64. ConfigurationOption.ConfigurationTypes.TYPE_INT32,
  65. String.Empty, "40", true);
  66. configMember.addConfigurationOption("object_bonus_factor",
  67. ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE,
  68. String.Empty, "1.0", true);
  69. configMember.addConfigurationOption("sim_access",
  70. ConfigurationOption.ConfigurationTypes.TYPE_INT32,
  71. String.Empty, "21", true);
  72. configMember.addConfigurationOption("terrain_base_0",
  73. ConfigurationOption.ConfigurationTypes.TYPE_UUID,
  74. String.Empty, DEFAULT_TERRAIN_TEXTURE_1.ToString(), true);
  75. configMember.addConfigurationOption("terrain_base_1",
  76. ConfigurationOption.ConfigurationTypes.TYPE_UUID,
  77. String.Empty, DEFAULT_TERRAIN_TEXTURE_2.ToString(), true);
  78. configMember.addConfigurationOption("terrain_base_2",
  79. ConfigurationOption.ConfigurationTypes.TYPE_UUID,
  80. String.Empty, DEFAULT_TERRAIN_TEXTURE_3.ToString(), true);
  81. configMember.addConfigurationOption("terrain_base_3",
  82. ConfigurationOption.ConfigurationTypes.TYPE_UUID,
  83. String.Empty, DEFAULT_TERRAIN_TEXTURE_4.ToString(), true);
  84. configMember.addConfigurationOption("terrain_start_height_0",
  85. ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE,
  86. String.Empty, "10.0", true);
  87. configMember.addConfigurationOption("terrain_start_height_1",
  88. ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE,
  89. String.Empty, "10.0", true);
  90. configMember.addConfigurationOption("terrain_start_height_2",
  91. ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE,
  92. String.Empty, "10.0", true);
  93. configMember.addConfigurationOption("terrain_start_height_3",
  94. ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE,
  95. String.Empty, "10.0", true);
  96. configMember.addConfigurationOption("terrain_height_range_0",
  97. ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE,
  98. String.Empty, "60.0", true);
  99. configMember.addConfigurationOption("terrain_height_range_1",
  100. ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE,
  101. String.Empty, "60.0", true);
  102. configMember.addConfigurationOption("terrain_height_range_2",
  103. ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE,
  104. String.Empty, "60.0", true);
  105. configMember.addConfigurationOption("terrain_height_range_3",
  106. ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE,
  107. String.Empty, "60.0", true);
  108. configMember.addConfigurationOption("region_water_height",
  109. ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE,
  110. String.Empty, "20.0", true);
  111. configMember.addConfigurationOption("terrain_raise_limit",
  112. ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE,
  113. String.Empty, "100.0", true);
  114. configMember.addConfigurationOption("terrain_lower_limit",
  115. ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE,
  116. String.Empty, "-100.0", true);
  117. configMember.addConfigurationOption("sun_hour",
  118. ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE,
  119. String.Empty, "0.0", true);
  120. }
  121. public bool HandleIncomingConfiguration(string key, object value)
  122. {
  123. switch (key)
  124. {
  125. case "region_flags":
  126. RegionFlags flags = (RegionFlags)(uint)value;
  127. m_BlockTerraform =
  128. (flags & RegionFlags.BlockTerraform) != 0;
  129. m_BlockFly =
  130. (flags & RegionFlags.NoFly) != 0;
  131. m_AllowDamage =
  132. (flags & RegionFlags.AllowDamage) != 0;
  133. m_RestrictPushing =
  134. (flags & RegionFlags.RestrictPushObject) != 0;
  135. m_AllowLandResell =
  136. (flags & RegionFlags.BlockLandResell) == 0;
  137. m_AllowLandJoinDivide =
  138. (flags & RegionFlags.AllowParcelChanges) != 0;
  139. m_BlockShowInSearch =
  140. ((uint)flags & (1 << 29)) != 0;
  141. m_DisableScripts =
  142. (flags & RegionFlags.SkipScripts) != 0;
  143. m_DisableCollisions =
  144. (flags & RegionFlags.SkipCollisions) != 0;
  145. m_DisablePhysics =
  146. (flags & RegionFlags.SkipPhysics) != 0;
  147. m_FixedSun =
  148. (flags & RegionFlags.SunFixed) != 0;
  149. m_Sandbox =
  150. (flags & RegionFlags.Sandbox) != 0;
  151. break;
  152. case "max_agents":
  153. m_AgentLimit = (int)value;
  154. break;
  155. case "object_bonus_factor":
  156. m_ObjectBonus = (double)value;
  157. break;
  158. case "sim_access":
  159. int access = (int)value;
  160. if (access <= 13)
  161. m_Maturity = 0;
  162. else
  163. m_Maturity = 1;
  164. break;
  165. case "terrain_base_0":
  166. m_TerrainTexture1 = (UUID)value;
  167. break;
  168. case "terrain_base_1":
  169. m_TerrainTexture2 = (UUID)value;
  170. break;
  171. case "terrain_base_2":
  172. m_TerrainTexture3 = (UUID)value;
  173. break;
  174. case "terrain_base_3":
  175. m_TerrainTexture4 = (UUID)value;
  176. break;
  177. case "terrain_start_height_0":
  178. m_Elevation1SW = (double)value;
  179. break;
  180. case "terrain_start_height_1":
  181. m_Elevation1NW = (double)value;
  182. break;
  183. case "terrain_start_height_2":
  184. m_Elevation1SE = (double)value;
  185. break;
  186. case "terrain_start_height_3":
  187. m_Elevation1NE = (double)value;
  188. break;
  189. case "terrain_height_range_0":
  190. m_Elevation2SW = (double)value;
  191. break;
  192. case "terrain_height_range_1":
  193. m_Elevation2NW = (double)value;
  194. break;
  195. case "terrain_height_range_2":
  196. m_Elevation2SE = (double)value;
  197. break;
  198. case "terrain_height_range_3":
  199. m_Elevation2NE = (double)value;
  200. break;
  201. case "region_water_height":
  202. m_WaterHeight = (double)value;
  203. break;
  204. case "terrain_raise_limit":
  205. m_TerrainRaiseLimit = (double)value;
  206. break;
  207. case "terrain_lower_limit":
  208. m_TerrainLowerLimit = (double)value;
  209. break;
  210. case "sun_hour":
  211. m_SunPosition = (double)value;
  212. break;
  213. }
  214. return true;
  215. }
  216. public void Save()
  217. {
  218. if (OnSave != null)
  219. OnSave(this);
  220. }
  221. private UUID m_RegionUUID = UUID.Zero;
  222. public UUID RegionUUID
  223. {
  224. get { return m_RegionUUID; }
  225. set { m_RegionUUID = value; }
  226. }
  227. private bool m_BlockTerraform = false;
  228. public bool BlockTerraform
  229. {
  230. get { return m_BlockTerraform; }
  231. set { m_BlockTerraform = value; }
  232. }
  233. private bool m_BlockFly = false;
  234. public bool BlockFly
  235. {
  236. get { return m_BlockFly; }
  237. set { m_BlockFly = value; }
  238. }
  239. private bool m_AllowDamage = false;
  240. public bool AllowDamage
  241. {
  242. get { return m_AllowDamage; }
  243. set { m_AllowDamage = value; }
  244. }
  245. private bool m_RestrictPushing = false;
  246. public bool RestrictPushing
  247. {
  248. get { return m_RestrictPushing; }
  249. set { m_RestrictPushing = value; }
  250. }
  251. private bool m_AllowLandResell = true;
  252. public bool AllowLandResell
  253. {
  254. get { return m_AllowLandResell; }
  255. set { m_AllowLandResell = value; }
  256. }
  257. private bool m_AllowLandJoinDivide = true;
  258. public bool AllowLandJoinDivide
  259. {
  260. get { return m_AllowLandJoinDivide; }
  261. set { m_AllowLandJoinDivide = value; }
  262. }
  263. private bool m_BlockShowInSearch = false;
  264. public bool BlockShowInSearch
  265. {
  266. get { return m_BlockShowInSearch; }
  267. set { m_BlockShowInSearch = value; }
  268. }
  269. private int m_AgentLimit = 40;
  270. public int AgentLimit
  271. {
  272. get { return m_AgentLimit; }
  273. set { m_AgentLimit = value; }
  274. }
  275. private double m_ObjectBonus = 1.0;
  276. public double ObjectBonus
  277. {
  278. get { return m_ObjectBonus; }
  279. set { m_ObjectBonus = value; }
  280. }
  281. private int m_Maturity = 1;
  282. public int Maturity
  283. {
  284. get { return m_Maturity; }
  285. set { m_Maturity = value; }
  286. }
  287. private bool m_DisableScripts = false;
  288. public bool DisableScripts
  289. {
  290. get { return m_DisableScripts; }
  291. set { m_DisableScripts = value; }
  292. }
  293. private bool m_DisableCollisions = false;
  294. public bool DisableCollisions
  295. {
  296. get { return m_DisableCollisions; }
  297. set { m_DisableCollisions = value; }
  298. }
  299. private bool m_DisablePhysics = false;
  300. public bool DisablePhysics
  301. {
  302. get { return m_DisablePhysics; }
  303. set { m_DisablePhysics = value; }
  304. }
  305. private UUID m_TerrainTexture1 = UUID.Zero;
  306. public UUID TerrainTexture1
  307. {
  308. get { return m_TerrainTexture1; }
  309. set
  310. {
  311. if (value == UUID.Zero)
  312. m_TerrainTexture1 = DEFAULT_TERRAIN_TEXTURE_1;
  313. else
  314. m_TerrainTexture1 = value;
  315. }
  316. }
  317. private UUID m_TerrainTexture2 = UUID.Zero;
  318. public UUID TerrainTexture2
  319. {
  320. get { return m_TerrainTexture2; }
  321. set
  322. {
  323. if (value == UUID.Zero)
  324. m_TerrainTexture2 = DEFAULT_TERRAIN_TEXTURE_2;
  325. else
  326. m_TerrainTexture2 = value;
  327. }
  328. }
  329. private UUID m_TerrainTexture3 = UUID.Zero;
  330. public UUID TerrainTexture3
  331. {
  332. get { return m_TerrainTexture3; }
  333. set
  334. {
  335. if (value == UUID.Zero)
  336. m_TerrainTexture3 = DEFAULT_TERRAIN_TEXTURE_3;
  337. else
  338. m_TerrainTexture3 = value;
  339. }
  340. }
  341. private UUID m_TerrainTexture4 = UUID.Zero;
  342. public UUID TerrainTexture4
  343. {
  344. get { return m_TerrainTexture4; }
  345. set
  346. {
  347. if (value == UUID.Zero)
  348. m_TerrainTexture4 = DEFAULT_TERRAIN_TEXTURE_4;
  349. else
  350. m_TerrainTexture4 = value;
  351. }
  352. }
  353. private double m_Elevation1NW = 10;
  354. public double Elevation1NW
  355. {
  356. get { return m_Elevation1NW; }
  357. set { m_Elevation1NW = value; }
  358. }
  359. private double m_Elevation2NW = 60;
  360. public double Elevation2NW
  361. {
  362. get { return m_Elevation2NW; }
  363. set { m_Elevation2NW = value; }
  364. }
  365. private double m_Elevation1NE = 10;
  366. public double Elevation1NE
  367. {
  368. get { return m_Elevation1NE; }
  369. set { m_Elevation1NE = value; }
  370. }
  371. private double m_Elevation2NE = 60;
  372. public double Elevation2NE
  373. {
  374. get { return m_Elevation2NE; }
  375. set { m_Elevation2NE = value; }
  376. }
  377. private double m_Elevation1SE = 10;
  378. public double Elevation1SE
  379. {
  380. get { return m_Elevation1SE; }
  381. set { m_Elevation1SE = value; }
  382. }
  383. private double m_Elevation2SE = 60;
  384. public double Elevation2SE
  385. {
  386. get { return m_Elevation2SE; }
  387. set { m_Elevation2SE = value; }
  388. }
  389. private double m_Elevation1SW = 10;
  390. public double Elevation1SW
  391. {
  392. get { return m_Elevation1SW; }
  393. set { m_Elevation1SW = value; }
  394. }
  395. private double m_Elevation2SW = 60;
  396. public double Elevation2SW
  397. {
  398. get { return m_Elevation2SW; }
  399. set { m_Elevation2SW = value; }
  400. }
  401. private double m_WaterHeight = 20;
  402. public double WaterHeight
  403. {
  404. get { return m_WaterHeight; }
  405. set { m_WaterHeight = value; }
  406. }
  407. private double m_TerrainRaiseLimit = 100;
  408. public double TerrainRaiseLimit
  409. {
  410. get { return m_TerrainRaiseLimit; }
  411. set { m_TerrainRaiseLimit = value; }
  412. }
  413. private double m_TerrainLowerLimit = -100;
  414. public double TerrainLowerLimit
  415. {
  416. get { return m_TerrainLowerLimit; }
  417. set { m_TerrainLowerLimit = value; }
  418. }
  419. private bool m_UseEstateSun = true;
  420. public bool UseEstateSun
  421. {
  422. get { return m_UseEstateSun; }
  423. set { m_UseEstateSun = value; }
  424. }
  425. private bool m_Sandbox = false;
  426. public bool Sandbox
  427. {
  428. get { return m_Sandbox; }
  429. set { m_Sandbox = value; }
  430. }
  431. private Vector3 m_SunVector;
  432. public Vector3 SunVector
  433. {
  434. get { return m_SunVector; }
  435. set { m_SunVector = value; }
  436. }
  437. private UUID m_TerrainImageID;
  438. public UUID TerrainImageID
  439. {
  440. get { return m_TerrainImageID; }
  441. set { m_TerrainImageID = value; }
  442. }
  443. private bool m_FixedSun = false;
  444. public bool FixedSun
  445. {
  446. get { return m_FixedSun; }
  447. set { m_FixedSun = value; }
  448. }
  449. private double m_SunPosition = 0.0;
  450. public double SunPosition
  451. {
  452. get { return m_SunPosition; }
  453. set { m_SunPosition = value; }
  454. }
  455. private UUID m_Covenant = UUID.Zero;
  456. public UUID Covenant
  457. {
  458. get { return m_Covenant; }
  459. set { m_Covenant = value; }
  460. }
  461. }
  462. }