RegionInfo.cs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Net;
  5. using System.Web;
  6. using System.IO;
  7. using OpenSim.Framework.Interfaces;
  8. using OpenSim.Framework.Utilities;
  9. using libsecondlife;
  10. using OpenSim.Framework.Types;
  11. namespace OpenSim
  12. {
  13. public class RegionInfo : RegionInfoBase
  14. {
  15. private bool isSandbox;
  16. public string DataStore;
  17. public RegionInfo()
  18. {
  19. }
  20. public void InitConfig(bool sandboxMode, IGenericConfig configData)
  21. {
  22. this.isSandbox = sandboxMode;
  23. try
  24. {
  25. // Sim UUID
  26. string attri = "";
  27. attri = configData.GetAttribute("SimUUID");
  28. if (attri == "")
  29. {
  30. this.SimUUID = LLUUID.Random();
  31. configData.SetAttribute("SimUUID", this.SimUUID.ToString());
  32. }
  33. else
  34. {
  35. this.SimUUID = new LLUUID(attri);
  36. }
  37. // Sim name
  38. attri = "";
  39. attri = configData.GetAttribute("SimName");
  40. if (attri == "")
  41. {
  42. this.RegionName = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Name", "OpenSim test");
  43. configData.SetAttribute("SimName", this.RegionName);
  44. }
  45. else
  46. {
  47. this.RegionName = attri;
  48. }
  49. // Sim/Grid location X
  50. attri = "";
  51. attri = configData.GetAttribute("SimLocationX");
  52. if (attri == "")
  53. {
  54. string location = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid Location X", "997");
  55. configData.SetAttribute("SimLocationX", location);
  56. this.RegionLocX = (uint)Convert.ToUInt32(location);
  57. }
  58. else
  59. {
  60. this.RegionLocX = (uint)Convert.ToUInt32(attri);
  61. }
  62. // Sim/Grid location Y
  63. attri = "";
  64. attri = configData.GetAttribute("SimLocationY");
  65. if (attri == "")
  66. {
  67. string location = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid Location Y", "996");
  68. configData.SetAttribute("SimLocationY", location);
  69. this.RegionLocY = (uint)Convert.ToUInt32(location);
  70. }
  71. else
  72. {
  73. this.RegionLocY = (uint)Convert.ToUInt32(attri);
  74. }
  75. // Local storage datastore
  76. attri = "";
  77. attri = configData.GetAttribute("Datastore");
  78. if (attri == "")
  79. {
  80. string datastore = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Filename for local storage", "localworld.yap");
  81. configData.SetAttribute("Datastore", datastore);
  82. this.DataStore = datastore;
  83. }
  84. else
  85. {
  86. this.DataStore = attri;
  87. }
  88. //Sim Listen Port
  89. attri = "";
  90. attri = configData.GetAttribute("SimListenPort");
  91. if (attri == "")
  92. {
  93. string port = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("UDP port for client connections", "9000");
  94. configData.SetAttribute("SimListenPort", port);
  95. this.IPListenPort = Convert.ToInt32(port);
  96. }
  97. else
  98. {
  99. this.IPListenPort = Convert.ToInt32(attri);
  100. }
  101. //Sim Listen Address
  102. attri = "";
  103. attri = configData.GetAttribute("SimListenAddress");
  104. if (attri == "")
  105. {
  106. this.IPListenAddr = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("IP Address to listen on for client connections", "127.0.0.1");
  107. configData.SetAttribute("SimListenAddress", this.IPListenAddr);
  108. }
  109. else
  110. {
  111. this.IPListenAddr = attri;
  112. }
  113. this.RegionHandle = Util.UIntsToLong((RegionLocX * 256), (RegionLocY * 256));
  114. configData.Commit();
  115. }
  116. catch (Exception e)
  117. {
  118. OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM,"Config.cs:InitConfig() - Exception occured");
  119. OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM,e.ToString());
  120. }
  121. OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Sim settings loaded:");
  122. OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "UUID: " + this.SimUUID.ToStringHyphenated());
  123. OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Name: " + this.RegionName);
  124. OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]");
  125. OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Region Handle: " + this.RegionHandle.ToString());
  126. OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Listening on IP: " + this.IPListenAddr + ":" + this.IPListenPort);
  127. OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Sandbox Mode? " + isSandbox.ToString());
  128. OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Asset URL: " + this.AssetURL);
  129. OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Asset key: " + this.AssetSendKey);
  130. OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Grid URL: " + this.GridURL);
  131. OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Grid key: " + this.GridSendKey);
  132. }
  133. }
  134. }