RegionSettings.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  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_base_0",
  62. ConfigurationOption.ConfigurationTypes.TYPE_LLUUID,
  63. String.Empty, "00000000-0000-0000-0000-000000000000",true);
  64. configMember.addConfigurationOption("terrain_base_1",
  65. ConfigurationOption.ConfigurationTypes.TYPE_LLUUID,
  66. String.Empty, "00000000-0000-0000-0000-000000000000",true);
  67. configMember.addConfigurationOption("terrain_base_2",
  68. ConfigurationOption.ConfigurationTypes.TYPE_LLUUID,
  69. String.Empty, "00000000-0000-0000-0000-000000000000",true);
  70. configMember.addConfigurationOption("terrain_base_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. m_Sandbox =
  139. (flags & Simulator.RegionFlags.Sandbox) != 0;
  140. break;
  141. case "max_agents":
  142. m_AgentLimit = (int)value;
  143. break;
  144. case "object_bonus_factor":
  145. m_ObjectBonus = (double)value;
  146. break;
  147. case "sim_access":
  148. int access = (int)value;
  149. if (access <= 13)
  150. m_Maturity = 0;
  151. else
  152. m_Maturity = 1;
  153. break;
  154. case "terrain_base_0":
  155. m_TerrainTexture1 = (LLUUID)value;
  156. break;
  157. case "terrain_base_1":
  158. m_TerrainTexture2 = (LLUUID)value;
  159. break;
  160. case "terrain_base_2":
  161. m_TerrainTexture3 = (LLUUID)value;
  162. break;
  163. case "terrain_base_3":
  164. m_TerrainTexture4 = (LLUUID)value;
  165. break;
  166. case "terrain_start_height_0":
  167. m_Elevation1SW = (double)value;
  168. break;
  169. case "terrain_start_height_1":
  170. m_Elevation1NW = (double)value;
  171. break;
  172. case "terrain_start_height_2":
  173. m_Elevation1SE = (double)value;
  174. break;
  175. case "terrain_start_height_3":
  176. m_Elevation1NE = (double)value;
  177. break;
  178. case "terrain_height_range_0":
  179. m_Elevation2SW = (double)value;
  180. break;
  181. case "terrain_height_range_1":
  182. m_Elevation2NW = (double)value;
  183. break;
  184. case "terrain_height_range_2":
  185. m_Elevation2SE = (double)value;
  186. break;
  187. case "terrain_height_range_3":
  188. m_Elevation2NE = (double)value;
  189. break;
  190. case "region_water_height":
  191. m_WaterHeight = (double)value;
  192. break;
  193. case "terrain_raise_limit":
  194. m_TerrainRaiseLimit = (double)value;
  195. break;
  196. case "terrain_lower_limit":
  197. m_TerrainLowerLimit = (double)value;
  198. break;
  199. case "sun_hour":
  200. m_SunPosition = (double)value;
  201. break;
  202. }
  203. return true;
  204. }
  205. public void Save()
  206. {
  207. if(OnSave != null)
  208. OnSave(this);
  209. }
  210. private LLUUID m_RegionUUID = LLUUID.Zero;
  211. public LLUUID RegionUUID
  212. {
  213. get { return m_RegionUUID; }
  214. set { m_RegionUUID = value; }
  215. }
  216. private bool m_BlockTerraform = false;
  217. public bool BlockTerraform
  218. {
  219. get { return m_BlockTerraform; }
  220. set { m_BlockTerraform = value; }
  221. }
  222. private bool m_BlockFly = false;
  223. public bool BlockFly
  224. {
  225. get { return m_BlockFly; }
  226. set { m_BlockFly = value; }
  227. }
  228. private bool m_AllowDamage = false;
  229. public bool AllowDamage
  230. {
  231. get { return m_AllowDamage; }
  232. set { m_AllowDamage = value; }
  233. }
  234. private bool m_RestrictPushing = false;
  235. public bool RestrictPushing
  236. {
  237. get { return m_RestrictPushing; }
  238. set { m_RestrictPushing = value; }
  239. }
  240. private bool m_AllowLandResell = true;
  241. public bool AllowLandResell
  242. {
  243. get { return m_AllowLandResell; }
  244. set { m_AllowLandResell = value; }
  245. }
  246. private bool m_AllowLandJoinDivide = true;
  247. public bool AllowLandJoinDivide
  248. {
  249. get { return m_AllowLandJoinDivide; }
  250. set { m_AllowLandJoinDivide = value; }
  251. }
  252. private bool m_BlockShowInSearch = false;
  253. public bool BlockShowInSearch
  254. {
  255. get { return m_BlockShowInSearch; }
  256. set { m_BlockShowInSearch = value; }
  257. }
  258. private int m_AgentLimit = 40;
  259. public int AgentLimit
  260. {
  261. get { return m_AgentLimit; }
  262. set { m_AgentLimit = value; }
  263. }
  264. private double m_ObjectBonus = 1.0;
  265. public double ObjectBonus
  266. {
  267. get { return m_ObjectBonus; }
  268. set { m_ObjectBonus = value; }
  269. }
  270. private int m_Maturity = 1;
  271. public int Maturity
  272. {
  273. get { return m_Maturity; }
  274. set { m_Maturity = value; }
  275. }
  276. private bool m_DisableScripts = false;
  277. public bool DisableScripts
  278. {
  279. get { return m_DisableScripts; }
  280. set { m_DisableScripts = value; }
  281. }
  282. private bool m_DisableCollisions = false;
  283. public bool DisableCollisions
  284. {
  285. get { return m_DisableCollisions; }
  286. set { m_DisableCollisions = value; }
  287. }
  288. private bool m_DisablePhysics = false;
  289. public bool DisablePhysics
  290. {
  291. get { return m_DisablePhysics; }
  292. set { m_DisablePhysics = value; }
  293. }
  294. private LLUUID m_TerrainTexture1 = LLUUID.Zero;
  295. public LLUUID TerrainTexture1
  296. {
  297. get { return m_TerrainTexture1; }
  298. set { m_TerrainTexture1 = value; }
  299. }
  300. private LLUUID m_TerrainTexture2 = LLUUID.Zero;
  301. public LLUUID TerrainTexture2
  302. {
  303. get { return m_TerrainTexture2; }
  304. set { m_TerrainTexture2 = value; }
  305. }
  306. private LLUUID m_TerrainTexture3 = LLUUID.Zero;
  307. public LLUUID TerrainTexture3
  308. {
  309. get { return m_TerrainTexture3; }
  310. set { m_TerrainTexture3 = value; }
  311. }
  312. private LLUUID m_TerrainTexture4 = LLUUID.Zero;
  313. public LLUUID TerrainTexture4
  314. {
  315. get { return m_TerrainTexture4; }
  316. set { m_TerrainTexture4 = value; }
  317. }
  318. private double m_Elevation1NW = 10;
  319. public double Elevation1NW
  320. {
  321. get { return m_Elevation1NW; }
  322. set { m_Elevation1NW = value; }
  323. }
  324. private double m_Elevation2NW = 60;
  325. public double Elevation2NW
  326. {
  327. get { return m_Elevation2NW; }
  328. set { m_Elevation2NW = value; }
  329. }
  330. private double m_Elevation1NE = 10;
  331. public double Elevation1NE
  332. {
  333. get { return m_Elevation1NE; }
  334. set { m_Elevation1NE = value; }
  335. }
  336. private double m_Elevation2NE = 60;
  337. public double Elevation2NE
  338. {
  339. get { return m_Elevation2NE; }
  340. set { m_Elevation2NE = value; }
  341. }
  342. private double m_Elevation1SE = 10;
  343. public double Elevation1SE
  344. {
  345. get { return m_Elevation1SE; }
  346. set { m_Elevation1SE = value; }
  347. }
  348. private double m_Elevation2SE = 60;
  349. public double Elevation2SE
  350. {
  351. get { return m_Elevation2SE; }
  352. set { m_Elevation2SE = value; }
  353. }
  354. private double m_Elevation1SW = 10;
  355. public double Elevation1SW
  356. {
  357. get { return m_Elevation1SW; }
  358. set { m_Elevation1SW = value; }
  359. }
  360. private double m_Elevation2SW = 60;
  361. public double Elevation2SW
  362. {
  363. get { return m_Elevation2SW; }
  364. set { m_Elevation2SW = value; }
  365. }
  366. private double m_WaterHeight = 20;
  367. public double WaterHeight
  368. {
  369. get { return m_WaterHeight; }
  370. set { m_WaterHeight = value; }
  371. }
  372. private double m_TerrainRaiseLimit = 100;
  373. public double TerrainRaiseLimit
  374. {
  375. get { return m_TerrainRaiseLimit; }
  376. set { m_TerrainRaiseLimit = value; }
  377. }
  378. private double m_TerrainLowerLimit = -100;
  379. public double TerrainLowerLimit
  380. {
  381. get { return m_TerrainLowerLimit; }
  382. set { m_TerrainLowerLimit = value; }
  383. }
  384. private bool m_UseEstateSun = true;
  385. public bool UseEstateSun
  386. {
  387. get { return m_UseEstateSun; }
  388. set { m_UseEstateSun = value; }
  389. }
  390. private bool m_Sandbox = false;
  391. public bool Sandbox
  392. {
  393. get { return m_Sandbox; }
  394. set { m_Sandbox = value; }
  395. }
  396. private LLVector3 m_SunVector;
  397. public LLVector3 SunVector
  398. {
  399. get { return m_SunVector; }
  400. set { m_SunVector = value; }
  401. }
  402. private LLUUID m_TerrainImageID;
  403. public LLUUID TerrainImageID
  404. {
  405. get { return m_TerrainImageID; }
  406. set { m_TerrainImageID = value; }
  407. }
  408. private bool m_FixedSun = false;
  409. public bool FixedSun
  410. {
  411. get { return m_FixedSun; }
  412. set { m_FixedSun = value; }
  413. }
  414. private double m_SunPosition = 0.0;
  415. public double SunPosition
  416. {
  417. get { return m_SunPosition; }
  418. set { m_SunPosition = value; }
  419. }
  420. private LLUUID m_Covenant = LLUUID.Zero;
  421. public LLUUID Covenant
  422. {
  423. get { return m_Covenant; }
  424. set { m_Covenant = value; }
  425. }
  426. }
  427. }