aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/RegionInfo.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/RegionInfo.cs210
1 files changed, 169 insertions, 41 deletions
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs
index 24b9c89..cf909cd 100644
--- a/OpenSim/Framework/RegionInfo.cs
+++ b/OpenSim/Framework/RegionInfo.cs
@@ -99,6 +99,7 @@ namespace OpenSim.Framework
99 public class RegionInfo 99 public class RegionInfo
100 { 100 {
101 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 101 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
102 private static readonly string LogHeader = "[REGION INFO]";
102 103
103 public bool commFailTF = false; 104 public bool commFailTF = false;
104 public ConfigurationMember configMember; 105 public ConfigurationMember configMember;
@@ -137,16 +138,20 @@ namespace OpenSim.Framework
137 public bool m_allow_alternate_ports; 138 public bool m_allow_alternate_ports;
138 protected string m_externalHostName; 139 protected string m_externalHostName;
139 protected IPEndPoint m_internalEndPoint; 140 protected IPEndPoint m_internalEndPoint;
140 protected uint? m_regionLocX;
141 protected uint? m_regionLocY;
142 protected uint m_remotingPort; 141 protected uint m_remotingPort;
143 public UUID RegionID = UUID.Zero; 142 public UUID RegionID = UUID.Zero;
144 public string RemotingAddress; 143 public string RemotingAddress;
145 public UUID ScopeID = UUID.Zero; 144 public UUID ScopeID = UUID.Zero;
146 private UUID m_maptileStaticUUID = UUID.Zero; 145 private UUID m_maptileStaticUUID = UUID.Zero;
147 146
148 private Dictionary<String, String> m_otherSettings = new Dictionary<string, string>(); 147 public uint RegionWorldLocX = 0;
148 public uint RegionWorldLocY = 0;
149 public uint RegionWorldLocZ = 0;
150 public uint RegionSizeX = Constants.RegionSize;
151 public uint RegionSizeY = Constants.RegionSize;
152 public uint RegionSizeZ = Constants.RegionHeight;
149 153
154 private Dictionary<String, String> m_otherSettings = new Dictionary<string, string>();
150 155
151 // Apparently, we're applying the same estatesettings regardless of whether it's local or remote. 156 // Apparently, we're applying the same estatesettings regardless of whether it's local or remote.
152 157
@@ -229,11 +234,8 @@ namespace OpenSim.Framework
229 m_serverURI = string.Empty; 234 m_serverURI = string.Empty;
230 } 235 }
231 236
232 public RegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri) 237 public RegionInfo(uint legacyRegionLocX, uint legacyRegionLocY, IPEndPoint internalEndPoint, string externalUri)
233 { 238 {
234 m_regionLocX = regionLocX;
235 m_regionLocY = regionLocY;
236
237 m_internalEndPoint = internalEndPoint; 239 m_internalEndPoint = internalEndPoint;
238 m_externalHostName = externalUri; 240 m_externalHostName = externalUri;
239 m_serverURI = string.Empty; 241 m_serverURI = string.Empty;
@@ -447,25 +449,66 @@ namespace OpenSim.Framework
447 449
448 /// <summary> 450 /// <summary>
449 /// The x co-ordinate of this region in map tiles (e.g. 1000). 451 /// The x co-ordinate of this region in map tiles (e.g. 1000).
452 /// Coordinate is scaled as world coordinates divided by the legacy region size
453 /// and is thus is the number of legacy regions.
454 /// </summary>
455 public uint LegacyRegionLocX
456 {
457 get { return RegionWorldLocX / Constants.RegionSize; }
458 set { RegionWorldLocX = value * Constants.RegionSize; }
459 }
460
461 /// <summary>
462 /// The y co-ordinate of this region in map tiles (e.g. 1000).
463 /// Coordinate is scaled as world coordinates divided by the legacy region size
464 /// and is thus is the number of legacy regions.
465 /// </summary>
466 public uint LegacyRegionLocY
467 {
468 get { return RegionWorldLocY / Constants.RegionSize; }
469 set { RegionWorldLocY = value * Constants.RegionSize; }
470 }
471
472 /// <summary>
473 /// The x co-ordinate of this region in map tiles (e.g. 1000).
474 /// Coordinate is scaled as world coordinates divided by the legacy region size
475 /// and is thus is the number of legacy regions.
476 /// DO NOT USE FOR NEW CODE! This entrypoint exists for downward compatability with external modules.
450 /// </summary> 477 /// </summary>
451 public uint RegionLocX 478 public uint RegionLocX
452 { 479 {
453 get { return m_regionLocX.Value; } 480 get { return LegacyRegionLocX; }
454 set { m_regionLocX = value; } 481 set { LegacyRegionLocX = value; }
455 } 482 }
456 483
457 /// <summary> 484 /// <summary>
458 /// The y co-ordinate of this region in map tiles (e.g. 1000). 485 /// The y co-ordinate of this region in map tiles (e.g. 1000).
486 /// Coordinate is scaled as world coordinates divided by the legacy region size
487 /// and is thus is the number of legacy regions.
488 /// DO NOT USE FOR NEW CODE! This entrypoint exists for downward compatability with external modules.
459 /// </summary> 489 /// </summary>
460 public uint RegionLocY 490 public uint RegionLocY
461 { 491 {
462 get { return m_regionLocY.Value; } 492 get { return LegacyRegionLocY; }
463 set { m_regionLocY = value; } 493 set { LegacyRegionLocY = value; }
494 }
495
496 public void SetDefaultRegionSize()
497 {
498 RegionWorldLocX = 0;
499 RegionWorldLocY = 0;
500 RegionWorldLocZ = 0;
501 RegionSizeX = Constants.RegionSize;
502 RegionSizeY = Constants.RegionSize;
503 RegionSizeZ = Constants.RegionHeight;
464 } 504 }
465 505
506 // A unique region handle is created from the region's world coordinates.
507 // This cannot be changed because some code expects to receive the region handle and then
508 // compute the region coordinates from it.
466 public ulong RegionHandle 509 public ulong RegionHandle
467 { 510 {
468 get { return Util.UIntsToLong((RegionLocX * (uint) Constants.RegionSize), (RegionLocY * (uint) Constants.RegionSize)); } 511 get { return Util.UIntsToLong(RegionWorldLocX, RegionWorldLocY); }
469 } 512 }
470 513
471 public void SetEndPoint(string ipaddr, int port) 514 public void SetEndPoint(string ipaddr, int port)
@@ -572,8 +615,25 @@ namespace OpenSim.Framework
572 615
573 string[] locationElements = location.Split(new char[] {','}); 616 string[] locationElements = location.Split(new char[] {','});
574 617
575 m_regionLocX = Convert.ToUInt32(locationElements[0]); 618 LegacyRegionLocX = Convert.ToUInt32(locationElements[0]);
576 m_regionLocY = Convert.ToUInt32(locationElements[1]); 619 LegacyRegionLocY = Convert.ToUInt32(locationElements[1]);
620
621 // Region size
622 // Default to legacy region size if not specified.
623 allKeys.Remove("SizeX");
624 string configSizeX = config.GetString("SizeX", Constants.RegionSize.ToString());
625 config.Set("SizeX", configSizeX);
626 RegionSizeX = Convert.ToUInt32(configSizeX);
627 allKeys.Remove("SizeY");
628 string configSizeY = config.GetString("SizeY", Constants.RegionSize.ToString());
629 config.Set("SizeY", configSizeX);
630 RegionSizeY = Convert.ToUInt32(configSizeY);
631 allKeys.Remove("SizeZ");
632 string configSizeZ = config.GetString("SizeZ", Constants.RegionHeight.ToString());
633 config.Set("SizeZ", configSizeX);
634 RegionSizeZ = Convert.ToUInt32(configSizeZ);
635
636 DoRegionSizeSanityChecks();
577 637
578 // InternalAddress 638 // InternalAddress
579 // 639 //
@@ -693,6 +753,48 @@ namespace OpenSim.Framework
693 } 753 }
694 } 754 }
695 755
756 // Make sure user specified region sizes are sane.
757 // Must be multiples of legacy region size (256).
758 private void DoRegionSizeSanityChecks()
759 {
760 if (RegionSizeX != Constants.RegionSize || RegionSizeY != Constants.RegionSize)
761 {
762 // Doing non-legacy region sizes.
763 // Enforce region size to be multiples of the legacy region size (256)
764 uint partial = RegionSizeX % Constants.RegionSize;
765 if (partial != 0)
766 {
767 RegionSizeX -= partial;
768 if (RegionSizeX == 0)
769 RegionSizeX = Constants.RegionSize;
770 m_log.ErrorFormat("{0} Region size must be multiple of {1}. Enforcing {2}.RegionSizeX={3} instead of specified {4}",
771 LogHeader, Constants.RegionSize, m_regionName, RegionSizeX, RegionSizeX + partial);
772 }
773 partial = RegionSizeY % Constants.RegionSize;
774 if (partial != 0)
775 {
776 RegionSizeY -= partial;
777 if (RegionSizeY == 0)
778 RegionSizeY = Constants.RegionSize;
779 m_log.ErrorFormat("{0} Region size must be multiple of {1}. Enforcing {2}.RegionSizeY={3} instead of specified {4}",
780 LogHeader, Constants.RegionSize, m_regionName, RegionSizeY, RegionSizeY + partial);
781 }
782
783 // Because of things in the viewer, regions MUST be square.
784 // Remove this check when viewers have been updated.
785 if (RegionSizeX != RegionSizeY)
786 {
787 uint minSize = Math.Min(RegionSizeX, RegionSizeY);
788 RegionSizeX = minSize;
789 RegionSizeY = minSize;
790 m_log.ErrorFormat("{0} Regions must be square until viewers are updated. Forcing region {1} size to <{2},{3}>",
791 LogHeader, m_regionName, RegionSizeX, RegionSizeY);
792 }
793
794 m_log.InfoFormat("{0} Region {1} size set to <{2},{3}>", LogHeader, m_regionName, RegionSizeX, RegionSizeY);
795 }
796 }
797
696 private void WriteNiniConfig(IConfigSource source) 798 private void WriteNiniConfig(IConfigSource source)
697 { 799 {
698 IConfig config = source.Configs[RegionName]; 800 IConfig config = source.Configs[RegionName];
@@ -704,9 +806,16 @@ namespace OpenSim.Framework
704 806
705 config.Set("RegionUUID", RegionID.ToString()); 807 config.Set("RegionUUID", RegionID.ToString());
706 808
707 string location = String.Format("{0},{1}", m_regionLocX, m_regionLocY); 809 string location = String.Format("{0},{1}", LegacyRegionLocX, LegacyRegionLocY);
708 config.Set("Location", location); 810 config.Set("Location", location);
709 811
812 if (RegionSizeX != Constants.RegionSize || RegionSizeY != Constants.RegionSize)
813 {
814 config.Set("SizeX", RegionSizeX);
815 config.Set("SizeY", RegionSizeY);
816 config.Set("SizeZ", RegionSizeZ);
817 }
818
710 config.Set("InternalAddress", m_internalEndPoint.Address.ToString()); 819 config.Set("InternalAddress", m_internalEndPoint.Address.ToString());
711 config.Set("InternalPort", m_internalEndPoint.Port); 820 config.Set("InternalPort", m_internalEndPoint.Port);
712 821
@@ -789,10 +898,18 @@ namespace OpenSim.Framework
789 RegionID.ToString(), true); 898 RegionID.ToString(), true);
790 configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, 899 configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
791 "Region Name", RegionName, true); 900 "Region Name", RegionName, true);
901
792 configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, 902 configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
793 "Grid Location (X Axis)", m_regionLocX.ToString(), true); 903 "Grid Location (X Axis)", LegacyRegionLocX.ToString(), true);
794 configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, 904 configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
795 "Grid Location (Y Axis)", m_regionLocY.ToString(), true); 905 "Grid Location (Y Axis)", LegacyRegionLocY.ToString(), true);
906 configMember.addConfigurationOption("sim_size_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
907 "Size of region in X dimension", RegionSizeX.ToString(), true);
908 configMember.addConfigurationOption("sim_size_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
909 "Size of region in Y dimension", RegionSizeY.ToString(), true);
910 configMember.addConfigurationOption("sim_size_z", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
911 "Size of region in Z dimension", RegionSizeZ.ToString(), true);
912
796 //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false); 913 //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false);
797 configMember.addConfigurationOption("internal_ip_address", 914 configMember.addConfigurationOption("internal_ip_address",
798 ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, 915 ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS,
@@ -855,10 +972,18 @@ namespace OpenSim.Framework
855 UUID.Random().ToString(), true); 972 UUID.Random().ToString(), true);
856 configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, 973 configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
857 "Region Name", "OpenSim Test", false); 974 "Region Name", "OpenSim Test", false);
975
858 configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, 976 configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
859 "Grid Location (X Axis)", "1000", false); 977 "Grid Location (X Axis)", "1000", false);
860 configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, 978 configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
861 "Grid Location (Y Axis)", "1000", false); 979 "Grid Location (Y Axis)", "1000", false);
980 configMember.addConfigurationOption("sim_size_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
981 "Size of region in X dimension", Constants.RegionSize.ToString(), false);
982 configMember.addConfigurationOption("sim_size_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
983 "Size of region in Y dimension", Constants.RegionSize.ToString(), false);
984 configMember.addConfigurationOption("sim_size_z", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
985 "Size of region in Z dimension", Constants.RegionHeight.ToString(), false);
986
862 //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false); 987 //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false);
863 configMember.addConfigurationOption("internal_ip_address", 988 configMember.addConfigurationOption("internal_ip_address",
864 ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, 989 ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS,
@@ -916,10 +1041,19 @@ namespace OpenSim.Framework
916 RegionName = (string) configuration_result; 1041 RegionName = (string) configuration_result;
917 break; 1042 break;
918 case "sim_location_x": 1043 case "sim_location_x":
919 m_regionLocX = (uint) configuration_result; 1044 LegacyRegionLocX = (uint) configuration_result;
920 break; 1045 break;
921 case "sim_location_y": 1046 case "sim_location_y":
922 m_regionLocY = (uint) configuration_result; 1047 LegacyRegionLocY = (uint) configuration_result;
1048 break;
1049 case "sim_size_x":
1050 RegionSizeX = (uint) configuration_result;
1051 break;
1052 case "sim_size_y":
1053 RegionSizeY = (uint) configuration_result;
1054 break;
1055 case "sim_size_z":
1056 RegionSizeZ = (uint) configuration_result;
923 break; 1057 break;
924 case "internal_ip_address": 1058 case "internal_ip_address":
925 IPAddress address = (IPAddress) configuration_result; 1059 IPAddress address = (IPAddress) configuration_result;
@@ -1000,8 +1134,13 @@ namespace OpenSim.Framework
1000 args["external_host_name"] = OSD.FromString(ExternalHostName); 1134 args["external_host_name"] = OSD.FromString(ExternalHostName);
1001 args["http_port"] = OSD.FromString(HttpPort.ToString()); 1135 args["http_port"] = OSD.FromString(HttpPort.ToString());
1002 args["server_uri"] = OSD.FromString(ServerURI); 1136 args["server_uri"] = OSD.FromString(ServerURI);
1003 args["region_xloc"] = OSD.FromString(RegionLocX.ToString()); 1137
1004 args["region_yloc"] = OSD.FromString(RegionLocY.ToString()); 1138 args["region_xloc"] = OSD.FromString(LegacyRegionLocX.ToString());
1139 args["region_yloc"] = OSD.FromString(LegacyRegionLocY.ToString());
1140 args["region_size_x"] = OSD.FromString(RegionSizeX.ToString());
1141 args["region_size_y"] = OSD.FromString(RegionSizeY.ToString());
1142 args["region_size_z"] = OSD.FromString(RegionSizeZ.ToString());
1143
1005 args["internal_ep_address"] = OSD.FromString(InternalEndPoint.Address.ToString()); 1144 args["internal_ep_address"] = OSD.FromString(InternalEndPoint.Address.ToString());
1006 args["internal_ep_port"] = OSD.FromString(InternalEndPoint.Port.ToString()); 1145 args["internal_ep_port"] = OSD.FromString(InternalEndPoint.Port.ToString());
1007 if ((RemotingAddress != null) && !RemotingAddress.Equals("")) 1146 if ((RemotingAddress != null) && !RemotingAddress.Equals(""))
@@ -1032,14 +1171,21 @@ namespace OpenSim.Framework
1032 { 1171 {
1033 uint locx; 1172 uint locx;
1034 UInt32.TryParse(args["region_xloc"].AsString(), out locx); 1173 UInt32.TryParse(args["region_xloc"].AsString(), out locx);
1035 RegionLocX = locx; 1174 LegacyRegionLocX = locx;
1036 } 1175 }
1037 if (args["region_yloc"] != null) 1176 if (args["region_yloc"] != null)
1038 { 1177 {
1039 uint locy; 1178 uint locy;
1040 UInt32.TryParse(args["region_yloc"].AsString(), out locy); 1179 UInt32.TryParse(args["region_yloc"].AsString(), out locy);
1041 RegionLocY = locy; 1180 LegacyRegionLocY = locy;
1042 } 1181 }
1182 if (args.ContainsKey("region_size_x"))
1183 RegionSizeX = (uint)args["region_size_x"].AsInteger();
1184 if (args.ContainsKey("region_size_y"))
1185 RegionSizeY = (uint)args["region_size_y"].AsInteger();
1186 if (args.ContainsKey("region_size_z"))
1187 RegionSizeZ = (uint)args["region_size_z"].AsInteger();
1188
1043 IPAddress ip_addr = null; 1189 IPAddress ip_addr = null;
1044 if (args["internal_ep_address"] != null) 1190 if (args["internal_ep_address"] != null)
1045 { 1191 {
@@ -1076,23 +1222,5 @@ namespace OpenSim.Framework
1076 regionInfo.ServerURI = serverURI; 1222 regionInfo.ServerURI = serverURI;
1077 return regionInfo; 1223 return regionInfo;
1078 } 1224 }
1079
1080 public Dictionary<string, object> ToKeyValuePairs()
1081 {
1082 Dictionary<string, object> kvp = new Dictionary<string, object>();
1083 kvp["uuid"] = RegionID.ToString();
1084 kvp["locX"] = RegionLocX.ToString();
1085 kvp["locY"] = RegionLocY.ToString();
1086 kvp["external_ip_address"] = ExternalEndPoint.Address.ToString();
1087 kvp["external_port"] = ExternalEndPoint.Port.ToString();
1088 kvp["external_host_name"] = ExternalHostName;
1089 kvp["http_port"] = HttpPort.ToString();
1090 kvp["internal_ip_address"] = InternalEndPoint.Address.ToString();
1091 kvp["internal_port"] = InternalEndPoint.Port.ToString();
1092 kvp["alternate_ports"] = m_allow_alternate_ports.ToString();
1093 kvp["server_uri"] = ServerURI;
1094
1095 return kvp;
1096 }
1097 } 1225 }
1098} 1226}