RegionSettings.cs 16 KB

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