aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/RegionInfo.cs
diff options
context:
space:
mode:
authorMelanie Thielker2014-06-21 00:39:55 +0200
committerMelanie Thielker2014-06-21 00:39:55 +0200
commit159fcbf150b7da0e229b29aa7b94793484543d12 (patch)
treeb8c0ff3b4c758a3fba8315b556c923ef4c02a185 /OpenSim/Framework/RegionInfo.cs
parentMerge commit '68c8633ba18f0a11cfc0ed04d1d0c7c59e6cec76' (diff)
parentMerge branch 'master' into careminster (diff)
downloadopensim-SC-159fcbf150b7da0e229b29aa7b94793484543d12.zip
opensim-SC-159fcbf150b7da0e229b29aa7b94793484543d12.tar.gz
opensim-SC-159fcbf150b7da0e229b29aa7b94793484543d12.tar.bz2
opensim-SC-159fcbf150b7da0e229b29aa7b94793484543d12.tar.xz
Merge branch 'master' of ssh://3dhosting.de/var/git/careminster
Conflicts: OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
Diffstat (limited to 'OpenSim/Framework/RegionInfo.cs')
-rw-r--r--OpenSim/Framework/RegionInfo.cs172
1 files changed, 153 insertions, 19 deletions
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs
index 24ec181..ae2ff63 100644
--- a/OpenSim/Framework/RegionInfo.cs
+++ b/OpenSim/Framework/RegionInfo.cs
@@ -100,6 +100,7 @@ namespace OpenSim.Framework
100 public class RegionInfo 100 public class RegionInfo
101 { 101 {
102 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 102 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
103 private static readonly string LogHeader = "[REGION INFO]";
103 104
104 public bool commFailTF = false; 105 public bool commFailTF = false;
105 public ConfigurationMember configMember; 106 public ConfigurationMember configMember;
@@ -139,16 +140,20 @@ namespace OpenSim.Framework
139 public bool m_allow_alternate_ports; 140 public bool m_allow_alternate_ports;
140 protected string m_externalHostName; 141 protected string m_externalHostName;
141 protected IPEndPoint m_internalEndPoint; 142 protected IPEndPoint m_internalEndPoint;
142 protected uint? m_regionLocX;
143 protected uint? m_regionLocY;
144 protected uint m_remotingPort; 143 protected uint m_remotingPort;
145 public UUID RegionID = UUID.Zero; 144 public UUID RegionID = UUID.Zero;
146 public string RemotingAddress; 145 public string RemotingAddress;
147 public UUID ScopeID = UUID.Zero; 146 public UUID ScopeID = UUID.Zero;
148 private UUID m_maptileStaticUUID = UUID.Zero; 147 private UUID m_maptileStaticUUID = UUID.Zero;
149 148
150 private Dictionary<String, String> m_otherSettings = new Dictionary<string, string>(); 149 public uint WorldLocX = 0;
150 public uint WorldLocY = 0;
151 public uint WorldLocZ = 0;
152 public uint RegionSizeX = Constants.RegionSize;
153 public uint RegionSizeY = Constants.RegionSize;
154 public uint RegionSizeZ = Constants.RegionHeight;
151 155
156 private Dictionary<String, String> m_otherSettings = new Dictionary<string, string>();
152 157
153 // Apparently, we're applying the same estatesettings regardless of whether it's local or remote. 158 // Apparently, we're applying the same estatesettings regardless of whether it's local or remote.
154 159
@@ -233,11 +238,12 @@ namespace OpenSim.Framework
233 m_serverURI = string.Empty; 238 m_serverURI = string.Empty;
234 } 239 }
235 240
236 public RegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri) 241 public RegionInfo(uint legacyRegionLocX, uint legacyRegionLocY, IPEndPoint internalEndPoint, string externalUri)
237 { 242 {
238 m_regionLocX = regionLocX; 243 RegionLocX = legacyRegionLocX;
239 m_regionLocY = regionLocY; 244 RegionLocY = legacyRegionLocY;
240 245 RegionSizeX = Constants.RegionSize;
246 RegionSizeY = Constants.RegionSize;
241 m_internalEndPoint = internalEndPoint; 247 m_internalEndPoint = internalEndPoint;
242 m_externalHostName = externalUri; 248 m_externalHostName = externalUri;
243 m_serverURI = string.Empty; 249 m_serverURI = string.Empty;
@@ -451,25 +457,42 @@ namespace OpenSim.Framework
451 457
452 /// <summary> 458 /// <summary>
453 /// The x co-ordinate of this region in map tiles (e.g. 1000). 459 /// The x co-ordinate of this region in map tiles (e.g. 1000).
460 /// Coordinate is scaled as world coordinates divided by the legacy region size
461 /// and is thus is the number of legacy regions.
454 /// </summary> 462 /// </summary>
455 public uint RegionLocX 463 public uint RegionLocX
456 { 464 {
457 get { return m_regionLocX.Value; } 465 get { return WorldLocX / Constants.RegionSize; }
458 set { m_regionLocX = value; } 466 set { WorldLocX = value * Constants.RegionSize; }
459 } 467 }
460 468
461 /// <summary> 469 /// <summary>
462 /// The y co-ordinate of this region in map tiles (e.g. 1000). 470 /// The y co-ordinate of this region in map tiles (e.g. 1000).
471 /// Coordinate is scaled as world coordinates divided by the legacy region size
472 /// and is thus is the number of legacy regions.
463 /// </summary> 473 /// </summary>
464 public uint RegionLocY 474 public uint RegionLocY
465 { 475 {
466 get { return m_regionLocY.Value; } 476 get { return WorldLocY / Constants.RegionSize; }
467 set { m_regionLocY = value; } 477 set { WorldLocY = value * Constants.RegionSize; }
468 } 478 }
469 479
480 public void SetDefaultRegionSize()
481 {
482 WorldLocX = 0;
483 WorldLocY = 0;
484 WorldLocZ = 0;
485 RegionSizeX = Constants.RegionSize;
486 RegionSizeY = Constants.RegionSize;
487 RegionSizeZ = Constants.RegionHeight;
488 }
489
490 // A unique region handle is created from the region's world coordinates.
491 // This cannot be changed because some code expects to receive the region handle and then
492 // compute the region coordinates from it.
470 public ulong RegionHandle 493 public ulong RegionHandle
471 { 494 {
472 get { return Util.UIntsToLong((RegionLocX * (uint) Constants.RegionSize), (RegionLocY * (uint) Constants.RegionSize)); } 495 get { return Util.UIntsToLong(WorldLocX, WorldLocY); }
473 } 496 }
474 497
475 public void SetEndPoint(string ipaddr, int port) 498 public void SetEndPoint(string ipaddr, int port)
@@ -576,8 +599,25 @@ namespace OpenSim.Framework
576 599
577 string[] locationElements = location.Split(new char[] {','}); 600 string[] locationElements = location.Split(new char[] {','});
578 601
579 m_regionLocX = Convert.ToUInt32(locationElements[0]); 602 RegionLocX = Convert.ToUInt32(locationElements[0]);
580 m_regionLocY = Convert.ToUInt32(locationElements[1]); 603 RegionLocY = Convert.ToUInt32(locationElements[1]);
604
605 // Region size
606 // Default to legacy region size if not specified.
607 allKeys.Remove("SizeX");
608 string configSizeX = config.GetString("SizeX", Constants.RegionSize.ToString());
609 config.Set("SizeX", configSizeX);
610 RegionSizeX = Convert.ToUInt32(configSizeX);
611 allKeys.Remove("SizeY");
612 string configSizeY = config.GetString("SizeY", Constants.RegionSize.ToString());
613 config.Set("SizeY", configSizeX);
614 RegionSizeY = Convert.ToUInt32(configSizeY);
615 allKeys.Remove("SizeZ");
616 string configSizeZ = config.GetString("SizeZ", Constants.RegionHeight.ToString());
617 config.Set("SizeZ", configSizeX);
618 RegionSizeZ = Convert.ToUInt32(configSizeZ);
619
620 DoRegionSizeSanityChecks();
581 621
582 // InternalAddress 622 // InternalAddress
583 // 623 //
@@ -697,6 +737,57 @@ namespace OpenSim.Framework
697 } 737 }
698 } 738 }
699 739
740 // Make sure user specified region sizes are sane.
741 // Must be multiples of legacy region size (256).
742 private void DoRegionSizeSanityChecks()
743 {
744 if (RegionSizeX != Constants.RegionSize || RegionSizeY != Constants.RegionSize)
745 {
746 // Doing non-legacy region sizes.
747 // Enforce region size to be multiples of the legacy region size (256)
748 uint partial = RegionSizeX % Constants.RegionSize;
749 if (partial != 0)
750 {
751 RegionSizeX -= partial;
752 if (RegionSizeX == 0)
753 RegionSizeX = Constants.RegionSize;
754 m_log.ErrorFormat("{0} Region size must be multiple of {1}. Enforcing {2}.RegionSizeX={3} instead of specified {4}",
755 LogHeader, Constants.RegionSize, m_regionName, RegionSizeX, RegionSizeX + partial);
756 }
757 partial = RegionSizeY % Constants.RegionSize;
758 if (partial != 0)
759 {
760 RegionSizeY -= partial;
761 if (RegionSizeY == 0)
762 RegionSizeY = Constants.RegionSize;
763 m_log.ErrorFormat("{0} Region size must be multiple of {1}. Enforcing {2}.RegionSizeY={3} instead of specified {4}",
764 LogHeader, Constants.RegionSize, m_regionName, RegionSizeY, RegionSizeY + partial);
765 }
766
767 // Because of things in the viewer, regions MUST be square.
768 // Remove this check when viewers have been updated.
769 if (RegionSizeX != RegionSizeY)
770 {
771 uint minSize = Math.Min(RegionSizeX, RegionSizeY);
772 RegionSizeX = minSize;
773 RegionSizeY = minSize;
774 m_log.ErrorFormat("{0} Regions must be square until viewers are updated. Forcing region {1} size to <{2},{3}>",
775 LogHeader, m_regionName, RegionSizeX, RegionSizeY);
776 }
777
778 // There is a practical limit to region size.
779 if (RegionSizeX > Constants.MaximumRegionSize || RegionSizeY > Constants.MaximumRegionSize)
780 {
781 RegionSizeX = Util.Clamp<uint>(RegionSizeX, Constants.RegionSize, Constants.MaximumRegionSize);
782 RegionSizeY = Util.Clamp<uint>(RegionSizeY, Constants.RegionSize, Constants.MaximumRegionSize);
783 m_log.ErrorFormat("{0} Region dimensions must be less than {1}. Clamping {2}'s size to <{3},{4}>",
784 LogHeader, Constants.MaximumRegionSize, m_regionName, RegionSizeX, RegionSizeY);
785 }
786
787 m_log.InfoFormat("{0} Region {1} size set to <{2},{3}>", LogHeader, m_regionName, RegionSizeX, RegionSizeY);
788 }
789 }
790
700 private void WriteNiniConfig(IConfigSource source) 791 private void WriteNiniConfig(IConfigSource source)
701 { 792 {
702 IConfig config = source.Configs[RegionName]; 793 IConfig config = source.Configs[RegionName];
@@ -708,11 +799,17 @@ namespace OpenSim.Framework
708 799
709 config.Set("RegionUUID", RegionID.ToString()); 800 config.Set("RegionUUID", RegionID.ToString());
710 801
711 string location = String.Format("{0},{1}", m_regionLocX, m_regionLocY); 802 string location = String.Format("{0},{1}", RegionLocX, RegionLocY);
712 config.Set("Location", location); 803 config.Set("Location", location);
713 804
714 if (DataStore != String.Empty) 805 if (DataStore != String.Empty)
715 config.Set("Datastore", DataStore); 806 config.Set("Datastore", DataStore);
807 if (RegionSizeX != Constants.RegionSize || RegionSizeY != Constants.RegionSize)
808 {
809 config.Set("SizeX", RegionSizeX);
810 config.Set("SizeY", RegionSizeY);
811 config.Set("SizeZ", RegionSizeZ);
812 }
716 813
717 config.Set("InternalAddress", m_internalEndPoint.Address.ToString()); 814 config.Set("InternalAddress", m_internalEndPoint.Address.ToString());
718 config.Set("InternalPort", m_internalEndPoint.Port); 815 config.Set("InternalPort", m_internalEndPoint.Port);
@@ -796,10 +893,18 @@ namespace OpenSim.Framework
796 RegionID.ToString(), true); 893 RegionID.ToString(), true);
797 configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, 894 configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
798 "Region Name", RegionName, true); 895 "Region Name", RegionName, true);
896
799 configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, 897 configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
800 "Grid Location (X Axis)", m_regionLocX.ToString(), true); 898 "Grid Location (X Axis)", RegionLocX.ToString(), true);
801 configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, 899 configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
802 "Grid Location (Y Axis)", m_regionLocY.ToString(), true); 900 "Grid Location (Y Axis)", RegionLocY.ToString(), true);
901 configMember.addConfigurationOption("sim_size_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
902 "Size of region in X dimension", RegionSizeX.ToString(), true);
903 configMember.addConfigurationOption("sim_size_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
904 "Size of region in Y dimension", RegionSizeY.ToString(), true);
905 configMember.addConfigurationOption("sim_size_z", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
906 "Size of region in Z dimension", RegionSizeZ.ToString(), true);
907
803 //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false); 908 //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false);
804 configMember.addConfigurationOption("internal_ip_address", 909 configMember.addConfigurationOption("internal_ip_address",
805 ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, 910 ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS,
@@ -862,10 +967,18 @@ namespace OpenSim.Framework
862 UUID.Random().ToString(), true); 967 UUID.Random().ToString(), true);
863 configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, 968 configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
864 "Region Name", "OpenSim Test", false); 969 "Region Name", "OpenSim Test", false);
970
865 configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, 971 configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
866 "Grid Location (X Axis)", "1000", false); 972 "Grid Location (X Axis)", "1000", false);
867 configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, 973 configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
868 "Grid Location (Y Axis)", "1000", false); 974 "Grid Location (Y Axis)", "1000", false);
975 configMember.addConfigurationOption("sim_size_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
976 "Size of region in X dimension", Constants.RegionSize.ToString(), false);
977 configMember.addConfigurationOption("sim_size_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
978 "Size of region in Y dimension", Constants.RegionSize.ToString(), false);
979 configMember.addConfigurationOption("sim_size_z", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
980 "Size of region in Z dimension", Constants.RegionHeight.ToString(), false);
981
869 //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false); 982 //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false);
870 configMember.addConfigurationOption("internal_ip_address", 983 configMember.addConfigurationOption("internal_ip_address",
871 ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, 984 ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS,
@@ -923,10 +1036,19 @@ namespace OpenSim.Framework
923 RegionName = (string) configuration_result; 1036 RegionName = (string) configuration_result;
924 break; 1037 break;
925 case "sim_location_x": 1038 case "sim_location_x":
926 m_regionLocX = (uint) configuration_result; 1039 RegionLocX = (uint) configuration_result;
927 break; 1040 break;
928 case "sim_location_y": 1041 case "sim_location_y":
929 m_regionLocY = (uint) configuration_result; 1042 RegionLocY = (uint) configuration_result;
1043 break;
1044 case "sim_size_x":
1045 RegionSizeX = (uint) configuration_result;
1046 break;
1047 case "sim_size_y":
1048 RegionSizeY = (uint) configuration_result;
1049 break;
1050 case "sim_size_z":
1051 RegionSizeZ = (uint) configuration_result;
930 break; 1052 break;
931 case "datastore": 1053 case "datastore":
932 DataStore = (string) configuration_result; 1054 DataStore = (string) configuration_result;
@@ -1010,8 +1132,13 @@ namespace OpenSim.Framework
1010 args["external_host_name"] = OSD.FromString(ExternalHostName); 1132 args["external_host_name"] = OSD.FromString(ExternalHostName);
1011 args["http_port"] = OSD.FromString(HttpPort.ToString()); 1133 args["http_port"] = OSD.FromString(HttpPort.ToString());
1012 args["server_uri"] = OSD.FromString(ServerURI); 1134 args["server_uri"] = OSD.FromString(ServerURI);
1135
1013 args["region_xloc"] = OSD.FromString(RegionLocX.ToString()); 1136 args["region_xloc"] = OSD.FromString(RegionLocX.ToString());
1014 args["region_yloc"] = OSD.FromString(RegionLocY.ToString()); 1137 args["region_yloc"] = OSD.FromString(RegionLocY.ToString());
1138 args["region_size_x"] = OSD.FromString(RegionSizeX.ToString());
1139 args["region_size_y"] = OSD.FromString(RegionSizeY.ToString());
1140 args["region_size_z"] = OSD.FromString(RegionSizeZ.ToString());
1141
1015 args["internal_ep_address"] = OSD.FromString(InternalEndPoint.Address.ToString()); 1142 args["internal_ep_address"] = OSD.FromString(InternalEndPoint.Address.ToString());
1016 args["internal_ep_port"] = OSD.FromString(InternalEndPoint.Port.ToString()); 1143 args["internal_ep_port"] = OSD.FromString(InternalEndPoint.Port.ToString());
1017 if ((RemotingAddress != null) && !RemotingAddress.Equals("")) 1144 if ((RemotingAddress != null) && !RemotingAddress.Equals(""))
@@ -1050,6 +1177,13 @@ namespace OpenSim.Framework
1050 UInt32.TryParse(args["region_yloc"].AsString(), out locy); 1177 UInt32.TryParse(args["region_yloc"].AsString(), out locy);
1051 RegionLocY = locy; 1178 RegionLocY = locy;
1052 } 1179 }
1180 if (args.ContainsKey("region_size_x"))
1181 RegionSizeX = (uint)args["region_size_x"].AsInteger();
1182 if (args.ContainsKey("region_size_y"))
1183 RegionSizeY = (uint)args["region_size_y"].AsInteger();
1184 if (args.ContainsKey("region_size_z"))
1185 RegionSizeZ = (uint)args["region_size_z"].AsInteger();
1186
1053 IPAddress ip_addr = null; 1187 IPAddress ip_addr = null;
1054 if (args["internal_ep_address"] != null) 1188 if (args["internal_ep_address"] != null)
1055 { 1189 {