aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorRobert Adams2013-12-28 06:58:15 -0800
committerRobert Adams2013-12-28 06:58:15 -0800
commit6869633d76b2a6664743a608e4284b8dd7df85a6 (patch)
treee976908cac58662ac37b0dfee8c748f314a259c7 /OpenSim
parentMerge branch 'justincc-master' (diff)
downloadopensim-SC_OLD-6869633d76b2a6664743a608e4284b8dd7df85a6.zip
opensim-SC_OLD-6869633d76b2a6664743a608e4284b8dd7df85a6.tar.gz
opensim-SC_OLD-6869633d76b2a6664743a608e4284b8dd7df85a6.tar.bz2
opensim-SC_OLD-6869633d76b2a6664743a608e4284b8dd7df85a6.tar.xz
Add serialization/deserialization of region size to RegionInfo, GridRegion, and RegionData.
This does not modify interfaces or handling of variable sized regions. This only enables the loading and storing of the region size and the reporting of the region size in grid service responses. The database tables already have the code to load and store the region size.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Constants.cs6
-rw-r--r--OpenSim/Framework/RegionInfo.cs189
-rw-r--r--OpenSim/Services/GridService/GridService.cs14
-rw-r--r--OpenSim/Services/Interfaces/IGridService.cs25
4 files changed, 195 insertions, 39 deletions
diff --git a/OpenSim/Framework/Constants.cs b/OpenSim/Framework/Constants.cs
index a2eb5ee..3468cea 100644
--- a/OpenSim/Framework/Constants.cs
+++ b/OpenSim/Framework/Constants.cs
@@ -30,8 +30,14 @@ namespace OpenSim.Framework
30{ 30{
31 public class Constants 31 public class Constants
32 { 32 {
33 // 'RegionSize' is the legacy region size.
34 // DO NOT USE THIS FOR ANY NEW CODE. Use Scene.RegionInfo.RegionSize[XYZ] as a region might not
35 // be the legacy region size.
33 public const uint RegionSize = 256; 36 public const uint RegionSize = 256;
34 public const uint RegionHeight = 4096; 37 public const uint RegionHeight = 4096;
38 // This could be a parameters but, really, a region of greater than this is pretty unmanageable
39 public const uint MaximumRegionSize = 8192;
40
35 public const byte TerrainPatchSize = 16; 41 public const byte TerrainPatchSize = 16;
36 public const string DefaultTexture = "89556747-24cb-43ed-920b-47caed15465f"; 42 public const string DefaultTexture = "89556747-24cb-43ed-920b-47caed15465f";
37 43
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs
index 24b9c89..857c151 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,10 @@ 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
237 m_internalEndPoint = internalEndPoint; 241 m_internalEndPoint = internalEndPoint;
238 m_externalHostName = externalUri; 242 m_externalHostName = externalUri;
239 m_serverURI = string.Empty; 243 m_serverURI = string.Empty;
@@ -447,25 +451,42 @@ namespace OpenSim.Framework
447 451
448 /// <summary> 452 /// <summary>
449 /// The x co-ordinate of this region in map tiles (e.g. 1000). 453 /// The x co-ordinate of this region in map tiles (e.g. 1000).
454 /// Coordinate is scaled as world coordinates divided by the legacy region size
455 /// and is thus is the number of legacy regions.
450 /// </summary> 456 /// </summary>
451 public uint RegionLocX 457 public uint RegionLocX
452 { 458 {
453 get { return m_regionLocX.Value; } 459 get { return WorldLocX / Constants.RegionSize; }
454 set { m_regionLocX = value; } 460 set { WorldLocX = value * Constants.RegionSize; }
455 } 461 }
456 462
457 /// <summary> 463 /// <summary>
458 /// The y co-ordinate of this region in map tiles (e.g. 1000). 464 /// The y co-ordinate of this region in map tiles (e.g. 1000).
465 /// Coordinate is scaled as world coordinates divided by the legacy region size
466 /// and is thus is the number of legacy regions.
459 /// </summary> 467 /// </summary>
460 public uint RegionLocY 468 public uint RegionLocY
461 { 469 {
462 get { return m_regionLocY.Value; } 470 get { return WorldLocY / Constants.RegionSize; }
463 set { m_regionLocY = value; } 471 set { WorldLocY = value * Constants.RegionSize; }
472 }
473
474 public void SetDefaultRegionSize()
475 {
476 WorldLocX = 0;
477 WorldLocY = 0;
478 WorldLocZ = 0;
479 RegionSizeX = Constants.RegionSize;
480 RegionSizeY = Constants.RegionSize;
481 RegionSizeZ = Constants.RegionHeight;
464 } 482 }
465 483
484 // A unique region handle is created from the region's world coordinates.
485 // This cannot be changed because some code expects to receive the region handle and then
486 // compute the region coordinates from it.
466 public ulong RegionHandle 487 public ulong RegionHandle
467 { 488 {
468 get { return Util.UIntsToLong((RegionLocX * (uint) Constants.RegionSize), (RegionLocY * (uint) Constants.RegionSize)); } 489 get { return Util.UIntsToLong(WorldLocX, WorldLocY); }
469 } 490 }
470 491
471 public void SetEndPoint(string ipaddr, int port) 492 public void SetEndPoint(string ipaddr, int port)
@@ -572,8 +593,25 @@ namespace OpenSim.Framework
572 593
573 string[] locationElements = location.Split(new char[] {','}); 594 string[] locationElements = location.Split(new char[] {','});
574 595
575 m_regionLocX = Convert.ToUInt32(locationElements[0]); 596 RegionLocX = Convert.ToUInt32(locationElements[0]);
576 m_regionLocY = Convert.ToUInt32(locationElements[1]); 597 RegionLocY = Convert.ToUInt32(locationElements[1]);
598
599 // Region size
600 // Default to legacy region size if not specified.
601 allKeys.Remove("SizeX");
602 string configSizeX = config.GetString("SizeX", Constants.RegionSize.ToString());
603 config.Set("SizeX", configSizeX);
604 RegionSizeX = Convert.ToUInt32(configSizeX);
605 allKeys.Remove("SizeY");
606 string configSizeY = config.GetString("SizeY", Constants.RegionSize.ToString());
607 config.Set("SizeY", configSizeX);
608 RegionSizeY = Convert.ToUInt32(configSizeY);
609 allKeys.Remove("SizeZ");
610 string configSizeZ = config.GetString("SizeZ", Constants.RegionHeight.ToString());
611 config.Set("SizeZ", configSizeX);
612 RegionSizeZ = Convert.ToUInt32(configSizeZ);
613
614 DoRegionSizeSanityChecks();
577 615
578 // InternalAddress 616 // InternalAddress
579 // 617 //
@@ -693,6 +731,57 @@ namespace OpenSim.Framework
693 } 731 }
694 } 732 }
695 733
734 // Make sure user specified region sizes are sane.
735 // Must be multiples of legacy region size (256).
736 private void DoRegionSizeSanityChecks()
737 {
738 if (RegionSizeX != Constants.RegionSize || RegionSizeY != Constants.RegionSize)
739 {
740 // Doing non-legacy region sizes.
741 // Enforce region size to be multiples of the legacy region size (256)
742 uint partial = RegionSizeX % Constants.RegionSize;
743 if (partial != 0)
744 {
745 RegionSizeX -= partial;
746 if (RegionSizeX == 0)
747 RegionSizeX = Constants.RegionSize;
748 m_log.ErrorFormat("{0} Region size must be multiple of {1}. Enforcing {2}.RegionSizeX={3} instead of specified {4}",
749 LogHeader, Constants.RegionSize, m_regionName, RegionSizeX, RegionSizeX + partial);
750 }
751 partial = RegionSizeY % Constants.RegionSize;
752 if (partial != 0)
753 {
754 RegionSizeY -= partial;
755 if (RegionSizeY == 0)
756 RegionSizeY = Constants.RegionSize;
757 m_log.ErrorFormat("{0} Region size must be multiple of {1}. Enforcing {2}.RegionSizeY={3} instead of specified {4}",
758 LogHeader, Constants.RegionSize, m_regionName, RegionSizeY, RegionSizeY + partial);
759 }
760
761 // Because of things in the viewer, regions MUST be square.
762 // Remove this check when viewers have been updated.
763 if (RegionSizeX != RegionSizeY)
764 {
765 uint minSize = Math.Min(RegionSizeX, RegionSizeY);
766 RegionSizeX = minSize;
767 RegionSizeY = minSize;
768 m_log.ErrorFormat("{0} Regions must be square until viewers are updated. Forcing region {1} size to <{2},{3}>",
769 LogHeader, m_regionName, RegionSizeX, RegionSizeY);
770 }
771
772 // There is a practical limit to region size.
773 if (RegionSizeX > Constants.MaximumRegionSize || RegionSizeY > Constants.MaximumRegionSize)
774 {
775 RegionSizeX = Util.Clamp<uint>(RegionSizeX, Constants.RegionSize, Constants.MaximumRegionSize);
776 RegionSizeY = Util.Clamp<uint>(RegionSizeY, Constants.RegionSize, Constants.MaximumRegionSize);
777 m_log.ErrorFormat("{0} Region dimensions must be less than {1}. Clamping {2}'s size to <{3},{4}>",
778 LogHeader, Constants.MaximumRegionSize, m_regionName, RegionSizeX, RegionSizeY);
779 }
780
781 m_log.InfoFormat("{0} Region {1} size set to <{2},{3}>", LogHeader, m_regionName, RegionSizeX, RegionSizeY);
782 }
783 }
784
696 private void WriteNiniConfig(IConfigSource source) 785 private void WriteNiniConfig(IConfigSource source)
697 { 786 {
698 IConfig config = source.Configs[RegionName]; 787 IConfig config = source.Configs[RegionName];
@@ -704,9 +793,16 @@ namespace OpenSim.Framework
704 793
705 config.Set("RegionUUID", RegionID.ToString()); 794 config.Set("RegionUUID", RegionID.ToString());
706 795
707 string location = String.Format("{0},{1}", m_regionLocX, m_regionLocY); 796 string location = String.Format("{0},{1}", RegionLocX, RegionLocY);
708 config.Set("Location", location); 797 config.Set("Location", location);
709 798
799 if (RegionSizeX != Constants.RegionSize || RegionSizeY != Constants.RegionSize)
800 {
801 config.Set("SizeX", RegionSizeX);
802 config.Set("SizeY", RegionSizeY);
803 config.Set("SizeZ", RegionSizeZ);
804 }
805
710 config.Set("InternalAddress", m_internalEndPoint.Address.ToString()); 806 config.Set("InternalAddress", m_internalEndPoint.Address.ToString());
711 config.Set("InternalPort", m_internalEndPoint.Port); 807 config.Set("InternalPort", m_internalEndPoint.Port);
712 808
@@ -789,10 +885,18 @@ namespace OpenSim.Framework
789 RegionID.ToString(), true); 885 RegionID.ToString(), true);
790 configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, 886 configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
791 "Region Name", RegionName, true); 887 "Region Name", RegionName, true);
888
792 configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, 889 configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
793 "Grid Location (X Axis)", m_regionLocX.ToString(), true); 890 "Grid Location (X Axis)", RegionLocX.ToString(), true);
794 configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, 891 configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
795 "Grid Location (Y Axis)", m_regionLocY.ToString(), true); 892 "Grid Location (Y Axis)", RegionLocY.ToString(), true);
893 configMember.addConfigurationOption("sim_size_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
894 "Size of region in X dimension", RegionSizeX.ToString(), true);
895 configMember.addConfigurationOption("sim_size_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
896 "Size of region in Y dimension", RegionSizeY.ToString(), true);
897 configMember.addConfigurationOption("sim_size_z", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
898 "Size of region in Z dimension", RegionSizeZ.ToString(), true);
899
796 //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false); 900 //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false);
797 configMember.addConfigurationOption("internal_ip_address", 901 configMember.addConfigurationOption("internal_ip_address",
798 ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, 902 ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS,
@@ -855,10 +959,18 @@ namespace OpenSim.Framework
855 UUID.Random().ToString(), true); 959 UUID.Random().ToString(), true);
856 configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, 960 configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
857 "Region Name", "OpenSim Test", false); 961 "Region Name", "OpenSim Test", false);
962
858 configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, 963 configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
859 "Grid Location (X Axis)", "1000", false); 964 "Grid Location (X Axis)", "1000", false);
860 configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, 965 configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
861 "Grid Location (Y Axis)", "1000", false); 966 "Grid Location (Y Axis)", "1000", false);
967 configMember.addConfigurationOption("sim_size_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
968 "Size of region in X dimension", Constants.RegionSize.ToString(), false);
969 configMember.addConfigurationOption("sim_size_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
970 "Size of region in Y dimension", Constants.RegionSize.ToString(), false);
971 configMember.addConfigurationOption("sim_size_z", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
972 "Size of region in Z dimension", Constants.RegionHeight.ToString(), false);
973
862 //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false); 974 //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false);
863 configMember.addConfigurationOption("internal_ip_address", 975 configMember.addConfigurationOption("internal_ip_address",
864 ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, 976 ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS,
@@ -916,10 +1028,19 @@ namespace OpenSim.Framework
916 RegionName = (string) configuration_result; 1028 RegionName = (string) configuration_result;
917 break; 1029 break;
918 case "sim_location_x": 1030 case "sim_location_x":
919 m_regionLocX = (uint) configuration_result; 1031 RegionLocX = (uint) configuration_result;
920 break; 1032 break;
921 case "sim_location_y": 1033 case "sim_location_y":
922 m_regionLocY = (uint) configuration_result; 1034 RegionLocY = (uint) configuration_result;
1035 break;
1036 case "sim_size_x":
1037 RegionSizeX = (uint) configuration_result;
1038 break;
1039 case "sim_size_y":
1040 RegionSizeY = (uint) configuration_result;
1041 break;
1042 case "sim_size_z":
1043 RegionSizeZ = (uint) configuration_result;
923 break; 1044 break;
924 case "internal_ip_address": 1045 case "internal_ip_address":
925 IPAddress address = (IPAddress) configuration_result; 1046 IPAddress address = (IPAddress) configuration_result;
@@ -1000,8 +1121,13 @@ namespace OpenSim.Framework
1000 args["external_host_name"] = OSD.FromString(ExternalHostName); 1121 args["external_host_name"] = OSD.FromString(ExternalHostName);
1001 args["http_port"] = OSD.FromString(HttpPort.ToString()); 1122 args["http_port"] = OSD.FromString(HttpPort.ToString());
1002 args["server_uri"] = OSD.FromString(ServerURI); 1123 args["server_uri"] = OSD.FromString(ServerURI);
1124
1003 args["region_xloc"] = OSD.FromString(RegionLocX.ToString()); 1125 args["region_xloc"] = OSD.FromString(RegionLocX.ToString());
1004 args["region_yloc"] = OSD.FromString(RegionLocY.ToString()); 1126 args["region_yloc"] = OSD.FromString(RegionLocY.ToString());
1127 args["region_size_x"] = OSD.FromString(RegionSizeX.ToString());
1128 args["region_size_y"] = OSD.FromString(RegionSizeY.ToString());
1129 args["region_size_z"] = OSD.FromString(RegionSizeZ.ToString());
1130
1005 args["internal_ep_address"] = OSD.FromString(InternalEndPoint.Address.ToString()); 1131 args["internal_ep_address"] = OSD.FromString(InternalEndPoint.Address.ToString());
1006 args["internal_ep_port"] = OSD.FromString(InternalEndPoint.Port.ToString()); 1132 args["internal_ep_port"] = OSD.FromString(InternalEndPoint.Port.ToString());
1007 if ((RemotingAddress != null) && !RemotingAddress.Equals("")) 1133 if ((RemotingAddress != null) && !RemotingAddress.Equals(""))
@@ -1040,6 +1166,13 @@ namespace OpenSim.Framework
1040 UInt32.TryParse(args["region_yloc"].AsString(), out locy); 1166 UInt32.TryParse(args["region_yloc"].AsString(), out locy);
1041 RegionLocY = locy; 1167 RegionLocY = locy;
1042 } 1168 }
1169 if (args.ContainsKey("region_size_x"))
1170 RegionSizeX = (uint)args["region_size_x"].AsInteger();
1171 if (args.ContainsKey("region_size_y"))
1172 RegionSizeY = (uint)args["region_size_y"].AsInteger();
1173 if (args.ContainsKey("region_size_z"))
1174 RegionSizeZ = (uint)args["region_size_z"].AsInteger();
1175
1043 IPAddress ip_addr = null; 1176 IPAddress ip_addr = null;
1044 if (args["internal_ep_address"] != null) 1177 if (args["internal_ep_address"] != null)
1045 { 1178 {
@@ -1076,23 +1209,5 @@ namespace OpenSim.Framework
1076 regionInfo.ServerURI = serverURI; 1209 regionInfo.ServerURI = serverURI;
1077 return regionInfo; 1210 return regionInfo;
1078 } 1211 }
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 } 1212 }
1098} 1213}
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs
index e72b7f9..137ce04 100644
--- a/OpenSim/Services/GridService/GridService.cs
+++ b/OpenSim/Services/GridService/GridService.cs
@@ -313,8 +313,9 @@ namespace OpenSim.Services.GridService
313 if (region != null) 313 if (region != null)
314 { 314 {
315 // Not really? Maybe? 315 // Not really? Maybe?
316 List<RegionData> rdatas = m_Database.Get(region.posX - (int)Constants.RegionSize - 1, region.posY - (int)Constants.RegionSize - 1, 316 List<RegionData> rdatas = m_Database.Get(
317 region.posX + (int)Constants.RegionSize + 1, region.posY + (int)Constants.RegionSize + 1, scopeID); 317 region.posX - region.sizeX - 1, region.posY - region.sizeY - 1,
318 region.posX + region.sizeX + 1, region.posY + region.sizeY + 1, scopeID);
318 319
319 foreach (RegionData rdata in rdatas) 320 foreach (RegionData rdata in rdatas)
320 { 321 {
@@ -347,6 +348,11 @@ namespace OpenSim.Services.GridService
347 return null; 348 return null;
348 } 349 }
349 350
351 // Get a region given its base coordinates.
352 // NOTE: this is NOT 'get a region by some point in the region'. The coordinate MUST
353 // be the base coordinate of the region.
354 // The snapping is technically unnecessary but is harmless because regions are always
355 // multiples of the legacy region size (256).
350 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) 356 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
351 { 357 {
352 int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize; 358 int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize;
@@ -441,6 +447,8 @@ namespace OpenSim.Services.GridService
441 RegionData rdata = new RegionData(); 447 RegionData rdata = new RegionData();
442 rdata.posX = (int)rinfo.RegionLocX; 448 rdata.posX = (int)rinfo.RegionLocX;
443 rdata.posY = (int)rinfo.RegionLocY; 449 rdata.posY = (int)rinfo.RegionLocY;
450 rdata.sizeX = rinfo.RegionSizeX;
451 rdata.sizeY = rinfo.RegionSizeY;
444 rdata.RegionID = rinfo.RegionID; 452 rdata.RegionID = rinfo.RegionID;
445 rdata.RegionName = rinfo.RegionName; 453 rdata.RegionName = rinfo.RegionName;
446 rdata.Data = rinfo.ToKeyValuePairs(); 454 rdata.Data = rinfo.ToKeyValuePairs();
@@ -454,6 +462,8 @@ namespace OpenSim.Services.GridService
454 GridRegion rinfo = new GridRegion(rdata.Data); 462 GridRegion rinfo = new GridRegion(rdata.Data);
455 rinfo.RegionLocX = rdata.posX; 463 rinfo.RegionLocX = rdata.posX;
456 rinfo.RegionLocY = rdata.posY; 464 rinfo.RegionLocY = rdata.posY;
465 rinfo.RegionSizeX = rdata.sizeX;
466 rinfo.RegionSizeY = rdata.sizeY;
457 rinfo.RegionID = rdata.RegionID; 467 rinfo.RegionID = rdata.RegionID;
458 rinfo.RegionName = rdata.RegionName; 468 rinfo.RegionName = rdata.RegionName;
459 rinfo.ScopeID = rdata.ScopeID; 469 rinfo.ScopeID = rdata.ScopeID;
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs
index 88ac5b3..651bd97 100644
--- a/OpenSim/Services/Interfaces/IGridService.cs
+++ b/OpenSim/Services/Interfaces/IGridService.cs
@@ -177,6 +177,7 @@ namespace OpenSim.Services.Interfaces
177 177
178 /// <summary> 178 /// <summary>
179 /// The location of this region in meters. 179 /// The location of this region in meters.
180 /// DANGER DANGER! Note that this name means something different in RegionInfo.
180 /// </summary> 181 /// </summary>
181 public int RegionLocX 182 public int RegionLocX
182 { 183 {
@@ -185,8 +186,12 @@ namespace OpenSim.Services.Interfaces
185 } 186 }
186 protected int m_regionLocX; 187 protected int m_regionLocX;
187 188
189 public int RegionSizeX { get; set; }
190 public int RegionSizeY { get; set; }
191
188 /// <summary> 192 /// <summary>
189 /// The location of this region in meters. 193 /// The location of this region in meters.
194 /// DANGER DANGER! Note that this name means something different in RegionInfo.
190 /// </summary> 195 /// </summary>
191 public int RegionLocY 196 public int RegionLocY
192 { 197 {
@@ -218,10 +223,13 @@ namespace OpenSim.Services.Interfaces
218 m_serverURI = string.Empty; 223 m_serverURI = string.Empty;
219 } 224 }
220 225
226 /*
221 public GridRegion(int regionLocX, int regionLocY, IPEndPoint internalEndPoint, string externalUri) 227 public GridRegion(int regionLocX, int regionLocY, IPEndPoint internalEndPoint, string externalUri)
222 { 228 {
223 m_regionLocX = regionLocX; 229 m_regionLocX = regionLocX;
224 m_regionLocY = regionLocY; 230 m_regionLocY = regionLocY;
231 RegionSizeX = (int)Constants.RegionSize;
232 RegionSizeY = (int)Constants.RegionSize;
225 233
226 m_internalEndPoint = internalEndPoint; 234 m_internalEndPoint = internalEndPoint;
227 m_externalHostName = externalUri; 235 m_externalHostName = externalUri;
@@ -231,16 +239,21 @@ namespace OpenSim.Services.Interfaces
231 { 239 {
232 m_regionLocX = regionLocX; 240 m_regionLocX = regionLocX;
233 m_regionLocY = regionLocY; 241 m_regionLocY = regionLocY;
242 RegionSizeX = (int)Constants.RegionSize;
243 RegionSizeY = (int)Constants.RegionSize;
234 244
235 m_externalHostName = externalUri; 245 m_externalHostName = externalUri;
236 246
237 m_internalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)port); 247 m_internalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)port);
238 } 248 }
249 */
239 250
240 public GridRegion(uint xcell, uint ycell) 251 public GridRegion(uint xcell, uint ycell)
241 { 252 {
242 m_regionLocX = (int)(xcell * Constants.RegionSize); 253 m_regionLocX = (int)(xcell * Constants.RegionSize);
243 m_regionLocY = (int)(ycell * Constants.RegionSize); 254 m_regionLocY = (int)(ycell * Constants.RegionSize);
255 RegionSizeX = (int)Constants.RegionSize;
256 RegionSizeY = (int)Constants.RegionSize;
244 } 257 }
245 258
246 public GridRegion(RegionInfo ConvertFrom) 259 public GridRegion(RegionInfo ConvertFrom)
@@ -248,6 +261,8 @@ namespace OpenSim.Services.Interfaces
248 m_regionName = ConvertFrom.RegionName; 261 m_regionName = ConvertFrom.RegionName;
249 m_regionLocX = (int)(ConvertFrom.RegionLocX * Constants.RegionSize); 262 m_regionLocX = (int)(ConvertFrom.RegionLocX * Constants.RegionSize);
250 m_regionLocY = (int)(ConvertFrom.RegionLocY * Constants.RegionSize); 263 m_regionLocY = (int)(ConvertFrom.RegionLocY * Constants.RegionSize);
264 RegionSizeX = (int)ConvertFrom.RegionSizeX;
265 RegionSizeY = (int)ConvertFrom.RegionSizeY;
251 m_internalEndPoint = ConvertFrom.InternalEndPoint; 266 m_internalEndPoint = ConvertFrom.InternalEndPoint;
252 m_externalHostName = ConvertFrom.ExternalHostName; 267 m_externalHostName = ConvertFrom.ExternalHostName;
253 m_httpPort = ConvertFrom.HttpPort; 268 m_httpPort = ConvertFrom.HttpPort;
@@ -266,6 +281,8 @@ namespace OpenSim.Services.Interfaces
266 m_regionName = ConvertFrom.RegionName; 281 m_regionName = ConvertFrom.RegionName;
267 m_regionLocX = ConvertFrom.RegionLocX; 282 m_regionLocX = ConvertFrom.RegionLocX;
268 m_regionLocY = ConvertFrom.RegionLocY; 283 m_regionLocY = ConvertFrom.RegionLocY;
284 RegionSizeX = ConvertFrom.RegionSizeX;
285 RegionSizeY = ConvertFrom.RegionSizeY;
269 m_internalEndPoint = ConvertFrom.InternalEndPoint; 286 m_internalEndPoint = ConvertFrom.InternalEndPoint;
270 m_externalHostName = ConvertFrom.ExternalHostName; 287 m_externalHostName = ConvertFrom.ExternalHostName;
271 m_httpPort = ConvertFrom.HttpPort; 288 m_httpPort = ConvertFrom.HttpPort;
@@ -373,6 +390,8 @@ namespace OpenSim.Services.Interfaces
373 kvp["uuid"] = RegionID.ToString(); 390 kvp["uuid"] = RegionID.ToString();
374 kvp["locX"] = RegionLocX.ToString(); 391 kvp["locX"] = RegionLocX.ToString();
375 kvp["locY"] = RegionLocY.ToString(); 392 kvp["locY"] = RegionLocY.ToString();
393 kvp["sizeX"] = RegionSizeX.ToString();
394 kvp["sizeY"] = RegionSizeY.ToString();
376 kvp["regionName"] = RegionName; 395 kvp["regionName"] = RegionName;
377 kvp["serverIP"] = ExternalHostName; //ExternalEndPoint.Address.ToString(); 396 kvp["serverIP"] = ExternalHostName; //ExternalEndPoint.Address.ToString();
378 kvp["serverHttpPort"] = HttpPort.ToString(); 397 kvp["serverHttpPort"] = HttpPort.ToString();
@@ -399,6 +418,12 @@ namespace OpenSim.Services.Interfaces
399 if (kvp.ContainsKey("locY")) 418 if (kvp.ContainsKey("locY"))
400 RegionLocY = Convert.ToInt32((string)kvp["locY"]); 419 RegionLocY = Convert.ToInt32((string)kvp["locY"]);
401 420
421 if (kvp.ContainsKey("sizeX"))
422 RegionSizeX = Convert.ToInt32((string)kvp["sizeX"]);
423
424 if (kvp.ContainsKey("sizeY"))
425 RegionSizeY = Convert.ToInt32((string)kvp["sizeY"]);
426
402 if (kvp.ContainsKey("regionName")) 427 if (kvp.ContainsKey("regionName"))
403 RegionName = (string)kvp["regionName"]; 428 RegionName = (string)kvp["regionName"];
404 429