1
0

RegionSettings.cs 18 KB

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