RegionProfileData.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  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 OpenSimulator 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.Collections;
  29. using Nwc.XmlRpc;
  30. using OpenMetaverse;
  31. using OpenSim.Framework;
  32. namespace OpenSim.Data
  33. {
  34. /// <summary>
  35. /// A class which contains information known to the grid server about a region
  36. /// </summary>
  37. [Serializable]
  38. public class RegionProfileData
  39. {
  40. /// <summary>
  41. /// The name of the region
  42. /// </summary>
  43. public string regionName = String.Empty;
  44. /// <summary>
  45. /// A 64-bit number combining map position into a (mostly) unique ID
  46. /// </summary>
  47. public ulong regionHandle;
  48. /// <summary>
  49. /// OGS/OpenSim Specific ID for a region
  50. /// </summary>
  51. public UUID UUID;
  52. /// <summary>
  53. /// Coordinates of the region
  54. /// </summary>
  55. public uint regionLocX;
  56. public uint regionLocY;
  57. public uint regionLocZ; // Reserved (round-robin, layers, etc)
  58. /// <summary>
  59. /// Authentication secrets
  60. /// </summary>
  61. /// <remarks>Not very secure, needs improvement.</remarks>
  62. public string regionSendKey = String.Empty;
  63. public string regionRecvKey = String.Empty;
  64. public string regionSecret = String.Empty;
  65. /// <summary>
  66. /// Whether the region is online
  67. /// </summary>
  68. public bool regionOnline;
  69. /// <summary>
  70. /// Information about the server that the region is currently hosted on
  71. /// </summary>
  72. public string serverIP = String.Empty;
  73. public uint serverPort;
  74. public string serverURI = String.Empty;
  75. public uint httpPort;
  76. public uint remotingPort;
  77. public string httpServerURI = String.Empty;
  78. /// <summary>
  79. /// Set of optional overrides. Can be used to create non-eulicidean spaces.
  80. /// </summary>
  81. public ulong regionNorthOverrideHandle;
  82. public ulong regionSouthOverrideHandle;
  83. public ulong regionEastOverrideHandle;
  84. public ulong regionWestOverrideHandle;
  85. /// <summary>
  86. /// Optional: URI Location of the region database
  87. /// </summary>
  88. /// <remarks>Used for floating sim pools where the region data is not nessecarily coupled to a specific server</remarks>
  89. public string regionDataURI = String.Empty;
  90. /// <summary>
  91. /// Region Asset Details
  92. /// </summary>
  93. public string regionAssetURI = String.Empty;
  94. public string regionAssetSendKey = String.Empty;
  95. public string regionAssetRecvKey = String.Empty;
  96. /// <summary>
  97. /// Region Userserver Details
  98. /// </summary>
  99. public string regionUserURI = String.Empty;
  100. public string regionUserSendKey = String.Empty;
  101. public string regionUserRecvKey = String.Empty;
  102. /// <summary>
  103. /// Region Map Texture Asset
  104. /// </summary>
  105. public UUID regionMapTextureID = new UUID("00000000-0000-1111-9999-000000000006");
  106. /// <summary>
  107. /// this particular mod to the file provides support within the spec for RegionProfileData for the
  108. /// owner_uuid for the region
  109. /// </summary>
  110. public UUID owner_uuid = UUID.Zero;
  111. /// <summary>
  112. /// OGS/OpenSim Specific original ID for a region after move/split
  113. /// </summary>
  114. public UUID originUUID;
  115. /// <summary>
  116. /// The Maturity rating of the region
  117. /// </summary>
  118. public uint maturity;
  119. //Data Wrappers
  120. public string RegionName
  121. {
  122. get { return regionName; }
  123. set { regionName = value; }
  124. }
  125. public ulong RegionHandle
  126. {
  127. get { return regionHandle; }
  128. set { regionHandle = value; }
  129. }
  130. public UUID Uuid
  131. {
  132. get { return UUID; }
  133. set { UUID = value; }
  134. }
  135. public uint RegionLocX
  136. {
  137. get { return regionLocX; }
  138. set { regionLocX = value; }
  139. }
  140. public uint RegionLocY
  141. {
  142. get { return regionLocY; }
  143. set { regionLocY = value; }
  144. }
  145. public uint RegionLocZ
  146. {
  147. get { return regionLocZ; }
  148. set { regionLocZ = value; }
  149. }
  150. public string RegionSendKey
  151. {
  152. get { return regionSendKey; }
  153. set { regionSendKey = value; }
  154. }
  155. public string RegionRecvKey
  156. {
  157. get { return regionRecvKey; }
  158. set { regionRecvKey = value; }
  159. }
  160. public string RegionSecret
  161. {
  162. get { return regionSecret; }
  163. set { regionSecret = value; }
  164. }
  165. public bool RegionOnline
  166. {
  167. get { return regionOnline; }
  168. set { regionOnline = value; }
  169. }
  170. public string ServerIP
  171. {
  172. get { return serverIP; }
  173. set { serverIP = value; }
  174. }
  175. public uint ServerPort
  176. {
  177. get { return serverPort; }
  178. set { serverPort = value; }
  179. }
  180. public string ServerURI
  181. {
  182. get { return serverURI; }
  183. set { serverURI = value; }
  184. }
  185. public uint ServerHttpPort
  186. {
  187. get { return httpPort; }
  188. set { httpPort = value; }
  189. }
  190. public uint ServerRemotingPort
  191. {
  192. get { return remotingPort; }
  193. set { remotingPort = value; }
  194. }
  195. public ulong NorthOverrideHandle
  196. {
  197. get { return regionNorthOverrideHandle; }
  198. set { regionNorthOverrideHandle = value; }
  199. }
  200. public ulong SouthOverrideHandle
  201. {
  202. get { return regionSouthOverrideHandle; }
  203. set { regionSouthOverrideHandle = value; }
  204. }
  205. public ulong EastOverrideHandle
  206. {
  207. get { return regionEastOverrideHandle; }
  208. set { regionEastOverrideHandle = value; }
  209. }
  210. public ulong WestOverrideHandle
  211. {
  212. get { return regionWestOverrideHandle; }
  213. set { regionWestOverrideHandle = value; }
  214. }
  215. public string RegionDataURI
  216. {
  217. get { return regionDataURI; }
  218. set { regionDataURI = value; }
  219. }
  220. public string RegionAssetURI
  221. {
  222. get { return regionAssetURI; }
  223. set { regionAssetURI = value; }
  224. }
  225. public string RegionAssetSendKey
  226. {
  227. get { return regionAssetSendKey; }
  228. set { regionAssetSendKey = value; }
  229. }
  230. public string RegionAssetRecvKey
  231. {
  232. get { return regionAssetRecvKey; }
  233. set { regionAssetRecvKey = value; }
  234. }
  235. public string RegionUserURI
  236. {
  237. get { return regionUserURI; }
  238. set { regionUserURI = value; }
  239. }
  240. public string RegionUserSendKey
  241. {
  242. get { return regionUserSendKey; }
  243. set { regionUserSendKey = value; }
  244. }
  245. public string RegionUserRecvKey
  246. {
  247. get { return regionUserRecvKey; }
  248. set { regionUserRecvKey = value; }
  249. }
  250. public UUID RegionMapTextureID
  251. {
  252. get { return regionMapTextureID; }
  253. set { regionMapTextureID = value; }
  254. }
  255. public UUID Owner_uuid
  256. {
  257. get { return owner_uuid; }
  258. set { owner_uuid = value; }
  259. }
  260. public UUID OriginUUID
  261. {
  262. get { return originUUID; }
  263. set { originUUID = value; }
  264. }
  265. public uint Maturity
  266. {
  267. get { return maturity; }
  268. set { maturity = value; }
  269. }
  270. public byte AccessLevel
  271. {
  272. get { return Util.ConvertMaturityToAccessLevel(maturity); }
  273. }
  274. public RegionInfo ToRegionInfo()
  275. {
  276. return RegionInfo.Create(UUID, regionName, regionLocX, regionLocY, serverIP, httpPort, serverPort, remotingPort, serverURI);
  277. }
  278. public static RegionProfileData FromRegionInfo(RegionInfo regionInfo)
  279. {
  280. if (regionInfo == null)
  281. {
  282. return null;
  283. }
  284. return Create(regionInfo.RegionID, regionInfo.RegionName, regionInfo.RegionLocX,
  285. regionInfo.RegionLocY, regionInfo.ExternalHostName,
  286. (uint) regionInfo.ExternalEndPoint.Port, regionInfo.HttpPort, regionInfo.RemotingPort,
  287. regionInfo.ServerURI, regionInfo.AccessLevel);
  288. }
  289. public static RegionProfileData Create(UUID regionID, string regionName, uint locX, uint locY, string externalHostName, uint regionPort, uint httpPort, uint remotingPort, string serverUri, byte access)
  290. {
  291. RegionProfileData regionProfile;
  292. regionProfile = new RegionProfileData();
  293. regionProfile.regionLocX = locX;
  294. regionProfile.regionLocY = locY;
  295. regionProfile.regionHandle =
  296. Utils.UIntsToLong((regionProfile.regionLocX * Constants.RegionSize),
  297. (regionProfile.regionLocY*Constants.RegionSize));
  298. regionProfile.serverIP = externalHostName;
  299. regionProfile.serverPort = regionPort;
  300. regionProfile.httpPort = httpPort;
  301. regionProfile.remotingPort = remotingPort;
  302. regionProfile.serverURI = serverUri;
  303. regionProfile.httpServerURI = "http://" + externalHostName + ":" + httpPort + "/";
  304. regionProfile.UUID = regionID;
  305. regionProfile.regionName = regionName;
  306. regionProfile.maturity = access;
  307. return regionProfile;
  308. }
  309. }
  310. }