diff options
Diffstat (limited to 'OpenSim/Framework/RegionInfo.cs')
-rw-r--r-- | OpenSim/Framework/RegionInfo.cs | 191 |
1 files changed, 154 insertions, 37 deletions
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 24b9c89..1de30af 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 WorldLocX = 0; |
148 | public uint WorldLocY = 0; | ||
149 | public uint WorldLocZ = 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,12 @@ 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; | 239 | RegionLocX = legacyRegionLocX; |
235 | m_regionLocY = regionLocY; | 240 | RegionLocY = legacyRegionLocY; |
236 | 241 | RegionSizeX = Constants.RegionSize; | |
242 | RegionSizeY = Constants.RegionSize; | ||
237 | m_internalEndPoint = internalEndPoint; | 243 | m_internalEndPoint = internalEndPoint; |
238 | m_externalHostName = externalUri; | 244 | m_externalHostName = externalUri; |
239 | m_serverURI = string.Empty; | 245 | m_serverURI = string.Empty; |
@@ -447,25 +453,42 @@ namespace OpenSim.Framework | |||
447 | 453 | ||
448 | /// <summary> | 454 | /// <summary> |
449 | /// The x co-ordinate of this region in map tiles (e.g. 1000). | 455 | /// The x co-ordinate of this region in map tiles (e.g. 1000). |
456 | /// Coordinate is scaled as world coordinates divided by the legacy region size | ||
457 | /// and is thus is the number of legacy regions. | ||
450 | /// </summary> | 458 | /// </summary> |
451 | public uint RegionLocX | 459 | public uint RegionLocX |
452 | { | 460 | { |
453 | get { return m_regionLocX.Value; } | 461 | get { return WorldLocX / Constants.RegionSize; } |
454 | set { m_regionLocX = value; } | 462 | set { WorldLocX = value * Constants.RegionSize; } |
455 | } | 463 | } |
456 | 464 | ||
457 | /// <summary> | 465 | /// <summary> |
458 | /// The y co-ordinate of this region in map tiles (e.g. 1000). | 466 | /// The y co-ordinate of this region in map tiles (e.g. 1000). |
467 | /// Coordinate is scaled as world coordinates divided by the legacy region size | ||
468 | /// and is thus is the number of legacy regions. | ||
459 | /// </summary> | 469 | /// </summary> |
460 | public uint RegionLocY | 470 | public uint RegionLocY |
461 | { | 471 | { |
462 | get { return m_regionLocY.Value; } | 472 | get { return WorldLocY / Constants.RegionSize; } |
463 | set { m_regionLocY = value; } | 473 | set { WorldLocY = value * Constants.RegionSize; } |
474 | } | ||
475 | |||
476 | public void SetDefaultRegionSize() | ||
477 | { | ||
478 | WorldLocX = 0; | ||
479 | WorldLocY = 0; | ||
480 | WorldLocZ = 0; | ||
481 | RegionSizeX = Constants.RegionSize; | ||
482 | RegionSizeY = Constants.RegionSize; | ||
483 | RegionSizeZ = Constants.RegionHeight; | ||
464 | } | 484 | } |
465 | 485 | ||
486 | // A unique region handle is created from the region's world coordinates. | ||
487 | // This cannot be changed because some code expects to receive the region handle and then | ||
488 | // compute the region coordinates from it. | ||
466 | public ulong RegionHandle | 489 | public ulong RegionHandle |
467 | { | 490 | { |
468 | get { return Util.UIntsToLong((RegionLocX * (uint) Constants.RegionSize), (RegionLocY * (uint) Constants.RegionSize)); } | 491 | get { return Util.UIntsToLong(WorldLocX, WorldLocY); } |
469 | } | 492 | } |
470 | 493 | ||
471 | public void SetEndPoint(string ipaddr, int port) | 494 | public void SetEndPoint(string ipaddr, int port) |
@@ -572,8 +595,25 @@ namespace OpenSim.Framework | |||
572 | 595 | ||
573 | string[] locationElements = location.Split(new char[] {','}); | 596 | string[] locationElements = location.Split(new char[] {','}); |
574 | 597 | ||
575 | m_regionLocX = Convert.ToUInt32(locationElements[0]); | 598 | RegionLocX = Convert.ToUInt32(locationElements[0]); |
576 | m_regionLocY = Convert.ToUInt32(locationElements[1]); | 599 | RegionLocY = Convert.ToUInt32(locationElements[1]); |
600 | |||
601 | // Region size | ||
602 | // Default to legacy region size if not specified. | ||
603 | allKeys.Remove("SizeX"); | ||
604 | string configSizeX = config.GetString("SizeX", Constants.RegionSize.ToString()); | ||
605 | config.Set("SizeX", configSizeX); | ||
606 | RegionSizeX = Convert.ToUInt32(configSizeX); | ||
607 | allKeys.Remove("SizeY"); | ||
608 | string configSizeY = config.GetString("SizeY", Constants.RegionSize.ToString()); | ||
609 | config.Set("SizeY", configSizeX); | ||
610 | RegionSizeY = Convert.ToUInt32(configSizeY); | ||
611 | allKeys.Remove("SizeZ"); | ||
612 | string configSizeZ = config.GetString("SizeZ", Constants.RegionHeight.ToString()); | ||
613 | config.Set("SizeZ", configSizeX); | ||
614 | RegionSizeZ = Convert.ToUInt32(configSizeZ); | ||
615 | |||
616 | DoRegionSizeSanityChecks(); | ||
577 | 617 | ||
578 | // InternalAddress | 618 | // InternalAddress |
579 | // | 619 | // |
@@ -693,6 +733,57 @@ namespace OpenSim.Framework | |||
693 | } | 733 | } |
694 | } | 734 | } |
695 | 735 | ||
736 | // Make sure user specified region sizes are sane. | ||
737 | // Must be multiples of legacy region size (256). | ||
738 | private void DoRegionSizeSanityChecks() | ||
739 | { | ||
740 | if (RegionSizeX != Constants.RegionSize || RegionSizeY != Constants.RegionSize) | ||
741 | { | ||
742 | // Doing non-legacy region sizes. | ||
743 | // Enforce region size to be multiples of the legacy region size (256) | ||
744 | uint partial = RegionSizeX % Constants.RegionSize; | ||
745 | if (partial != 0) | ||
746 | { | ||
747 | RegionSizeX -= partial; | ||
748 | if (RegionSizeX == 0) | ||
749 | RegionSizeX = Constants.RegionSize; | ||
750 | m_log.ErrorFormat("{0} Region size must be multiple of {1}. Enforcing {2}.RegionSizeX={3} instead of specified {4}", | ||
751 | LogHeader, Constants.RegionSize, m_regionName, RegionSizeX, RegionSizeX + partial); | ||
752 | } | ||
753 | partial = RegionSizeY % Constants.RegionSize; | ||
754 | if (partial != 0) | ||
755 | { | ||
756 | RegionSizeY -= partial; | ||
757 | if (RegionSizeY == 0) | ||
758 | RegionSizeY = Constants.RegionSize; | ||
759 | m_log.ErrorFormat("{0} Region size must be multiple of {1}. Enforcing {2}.RegionSizeY={3} instead of specified {4}", | ||
760 | LogHeader, Constants.RegionSize, m_regionName, RegionSizeY, RegionSizeY + partial); | ||
761 | } | ||
762 | |||
763 | // Because of things in the viewer, regions MUST be square. | ||
764 | // Remove this check when viewers have been updated. | ||
765 | if (RegionSizeX != RegionSizeY) | ||
766 | { | ||
767 | uint minSize = Math.Min(RegionSizeX, RegionSizeY); | ||
768 | RegionSizeX = minSize; | ||
769 | RegionSizeY = minSize; | ||
770 | m_log.ErrorFormat("{0} Regions must be square until viewers are updated. Forcing region {1} size to <{2},{3}>", | ||
771 | LogHeader, m_regionName, RegionSizeX, RegionSizeY); | ||
772 | } | ||
773 | |||
774 | // There is a practical limit to region size. | ||
775 | if (RegionSizeX > Constants.MaximumRegionSize || RegionSizeY > Constants.MaximumRegionSize) | ||
776 | { | ||
777 | RegionSizeX = Util.Clamp<uint>(RegionSizeX, Constants.RegionSize, Constants.MaximumRegionSize); | ||
778 | RegionSizeY = Util.Clamp<uint>(RegionSizeY, Constants.RegionSize, Constants.MaximumRegionSize); | ||
779 | m_log.ErrorFormat("{0} Region dimensions must be less than {1}. Clamping {2}'s size to <{3},{4}>", | ||
780 | LogHeader, Constants.MaximumRegionSize, m_regionName, RegionSizeX, RegionSizeY); | ||
781 | } | ||
782 | |||
783 | m_log.InfoFormat("{0} Region {1} size set to <{2},{3}>", LogHeader, m_regionName, RegionSizeX, RegionSizeY); | ||
784 | } | ||
785 | } | ||
786 | |||
696 | private void WriteNiniConfig(IConfigSource source) | 787 | private void WriteNiniConfig(IConfigSource source) |
697 | { | 788 | { |
698 | IConfig config = source.Configs[RegionName]; | 789 | IConfig config = source.Configs[RegionName]; |
@@ -704,9 +795,16 @@ namespace OpenSim.Framework | |||
704 | 795 | ||
705 | config.Set("RegionUUID", RegionID.ToString()); | 796 | config.Set("RegionUUID", RegionID.ToString()); |
706 | 797 | ||
707 | string location = String.Format("{0},{1}", m_regionLocX, m_regionLocY); | 798 | string location = String.Format("{0},{1}", RegionLocX, RegionLocY); |
708 | config.Set("Location", location); | 799 | config.Set("Location", location); |
709 | 800 | ||
801 | if (RegionSizeX != Constants.RegionSize || RegionSizeY != Constants.RegionSize) | ||
802 | { | ||
803 | config.Set("SizeX", RegionSizeX); | ||
804 | config.Set("SizeY", RegionSizeY); | ||
805 | config.Set("SizeZ", RegionSizeZ); | ||
806 | } | ||
807 | |||
710 | config.Set("InternalAddress", m_internalEndPoint.Address.ToString()); | 808 | config.Set("InternalAddress", m_internalEndPoint.Address.ToString()); |
711 | config.Set("InternalPort", m_internalEndPoint.Port); | 809 | config.Set("InternalPort", m_internalEndPoint.Port); |
712 | 810 | ||
@@ -789,10 +887,18 @@ namespace OpenSim.Framework | |||
789 | RegionID.ToString(), true); | 887 | RegionID.ToString(), true); |
790 | configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, | 888 | configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, |
791 | "Region Name", RegionName, true); | 889 | "Region Name", RegionName, true); |
890 | |||
792 | configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | 891 | configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, |
793 | "Grid Location (X Axis)", m_regionLocX.ToString(), true); | 892 | "Grid Location (X Axis)", RegionLocX.ToString(), true); |
794 | configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | 893 | configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, |
795 | "Grid Location (Y Axis)", m_regionLocY.ToString(), true); | 894 | "Grid Location (Y Axis)", RegionLocY.ToString(), true); |
895 | configMember.addConfigurationOption("sim_size_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | ||
896 | "Size of region in X dimension", RegionSizeX.ToString(), true); | ||
897 | configMember.addConfigurationOption("sim_size_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | ||
898 | "Size of region in Y dimension", RegionSizeY.ToString(), true); | ||
899 | configMember.addConfigurationOption("sim_size_z", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | ||
900 | "Size of region in Z dimension", RegionSizeZ.ToString(), true); | ||
901 | |||
796 | //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false); | 902 | //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false); |
797 | configMember.addConfigurationOption("internal_ip_address", | 903 | configMember.addConfigurationOption("internal_ip_address", |
798 | ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, | 904 | ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, |
@@ -855,10 +961,18 @@ namespace OpenSim.Framework | |||
855 | UUID.Random().ToString(), true); | 961 | UUID.Random().ToString(), true); |
856 | configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, | 962 | configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, |
857 | "Region Name", "OpenSim Test", false); | 963 | "Region Name", "OpenSim Test", false); |
964 | |||
858 | configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | 965 | configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, |
859 | "Grid Location (X Axis)", "1000", false); | 966 | "Grid Location (X Axis)", "1000", false); |
860 | configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | 967 | configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, |
861 | "Grid Location (Y Axis)", "1000", false); | 968 | "Grid Location (Y Axis)", "1000", false); |
969 | configMember.addConfigurationOption("sim_size_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | ||
970 | "Size of region in X dimension", Constants.RegionSize.ToString(), false); | ||
971 | configMember.addConfigurationOption("sim_size_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | ||
972 | "Size of region in Y dimension", Constants.RegionSize.ToString(), false); | ||
973 | configMember.addConfigurationOption("sim_size_z", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | ||
974 | "Size of region in Z dimension", Constants.RegionHeight.ToString(), false); | ||
975 | |||
862 | //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false); | 976 | //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false); |
863 | configMember.addConfigurationOption("internal_ip_address", | 977 | configMember.addConfigurationOption("internal_ip_address", |
864 | ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, | 978 | ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, |
@@ -916,10 +1030,19 @@ namespace OpenSim.Framework | |||
916 | RegionName = (string) configuration_result; | 1030 | RegionName = (string) configuration_result; |
917 | break; | 1031 | break; |
918 | case "sim_location_x": | 1032 | case "sim_location_x": |
919 | m_regionLocX = (uint) configuration_result; | 1033 | RegionLocX = (uint) configuration_result; |
920 | break; | 1034 | break; |
921 | case "sim_location_y": | 1035 | case "sim_location_y": |
922 | m_regionLocY = (uint) configuration_result; | 1036 | RegionLocY = (uint) configuration_result; |
1037 | break; | ||
1038 | case "sim_size_x": | ||
1039 | RegionSizeX = (uint) configuration_result; | ||
1040 | break; | ||
1041 | case "sim_size_y": | ||
1042 | RegionSizeY = (uint) configuration_result; | ||
1043 | break; | ||
1044 | case "sim_size_z": | ||
1045 | RegionSizeZ = (uint) configuration_result; | ||
923 | break; | 1046 | break; |
924 | case "internal_ip_address": | 1047 | case "internal_ip_address": |
925 | IPAddress address = (IPAddress) configuration_result; | 1048 | IPAddress address = (IPAddress) configuration_result; |
@@ -1000,8 +1123,13 @@ namespace OpenSim.Framework | |||
1000 | args["external_host_name"] = OSD.FromString(ExternalHostName); | 1123 | args["external_host_name"] = OSD.FromString(ExternalHostName); |
1001 | args["http_port"] = OSD.FromString(HttpPort.ToString()); | 1124 | args["http_port"] = OSD.FromString(HttpPort.ToString()); |
1002 | args["server_uri"] = OSD.FromString(ServerURI); | 1125 | args["server_uri"] = OSD.FromString(ServerURI); |
1126 | |||
1003 | args["region_xloc"] = OSD.FromString(RegionLocX.ToString()); | 1127 | args["region_xloc"] = OSD.FromString(RegionLocX.ToString()); |
1004 | args["region_yloc"] = OSD.FromString(RegionLocY.ToString()); | 1128 | args["region_yloc"] = OSD.FromString(RegionLocY.ToString()); |
1129 | args["region_size_x"] = OSD.FromString(RegionSizeX.ToString()); | ||
1130 | args["region_size_y"] = OSD.FromString(RegionSizeY.ToString()); | ||
1131 | args["region_size_z"] = OSD.FromString(RegionSizeZ.ToString()); | ||
1132 | |||
1005 | args["internal_ep_address"] = OSD.FromString(InternalEndPoint.Address.ToString()); | 1133 | args["internal_ep_address"] = OSD.FromString(InternalEndPoint.Address.ToString()); |
1006 | args["internal_ep_port"] = OSD.FromString(InternalEndPoint.Port.ToString()); | 1134 | args["internal_ep_port"] = OSD.FromString(InternalEndPoint.Port.ToString()); |
1007 | if ((RemotingAddress != null) && !RemotingAddress.Equals("")) | 1135 | if ((RemotingAddress != null) && !RemotingAddress.Equals("")) |
@@ -1040,6 +1168,13 @@ namespace OpenSim.Framework | |||
1040 | UInt32.TryParse(args["region_yloc"].AsString(), out locy); | 1168 | UInt32.TryParse(args["region_yloc"].AsString(), out locy); |
1041 | RegionLocY = locy; | 1169 | RegionLocY = locy; |
1042 | } | 1170 | } |
1171 | if (args.ContainsKey("region_size_x")) | ||
1172 | RegionSizeX = (uint)args["region_size_x"].AsInteger(); | ||
1173 | if (args.ContainsKey("region_size_y")) | ||
1174 | RegionSizeY = (uint)args["region_size_y"].AsInteger(); | ||
1175 | if (args.ContainsKey("region_size_z")) | ||
1176 | RegionSizeZ = (uint)args["region_size_z"].AsInteger(); | ||
1177 | |||
1043 | IPAddress ip_addr = null; | 1178 | IPAddress ip_addr = null; |
1044 | if (args["internal_ep_address"] != null) | 1179 | if (args["internal_ep_address"] != null) |
1045 | { | 1180 | { |
@@ -1076,23 +1211,5 @@ namespace OpenSim.Framework | |||
1076 | regionInfo.ServerURI = serverURI; | 1211 | regionInfo.ServerURI = serverURI; |
1077 | return regionInfo; | 1212 | return regionInfo; |
1078 | } | 1213 | } |
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 | } | 1214 | } |
1098 | } | 1215 | } |