diff options
author | Robert Adams | 2015-03-29 16:45:00 -0700 |
---|---|---|
committer | Robert Adams | 2015-03-29 16:45:00 -0700 |
commit | df14b40e88e658a2adb50d45c941fb016a2952eb (patch) | |
tree | 4d9b7f8a62b0999af7c1971c232809ade765fc8b /OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | |
parent | varregion: any conversions of use of Constants.RegionSize converted into (diff) | |
download | opensim-SC_OLD-df14b40e88e658a2adb50d45c941fb016a2952eb.zip opensim-SC_OLD-df14b40e88e658a2adb50d45c941fb016a2952eb.tar.gz opensim-SC_OLD-df14b40e88e658a2adb50d45c941fb016a2952eb.tar.bz2 opensim-SC_OLD-df14b40e88e658a2adb50d45c941fb016a2952eb.tar.xz |
varregion: update LandManagementModule and LandObject for variable sized regions.
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | 63 |
1 files changed, 34 insertions, 29 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 9279066..4aee6a5 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | |||
@@ -64,6 +64,12 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
64 | public class LandManagementModule : INonSharedRegionModule | 64 | public class LandManagementModule : INonSharedRegionModule |
65 | { | 65 | { |
66 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 66 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
67 | private static readonly string LogHeader = "[LAND MANAGEMENT MODULE]"; | ||
68 | |||
69 | /// <summary> | ||
70 | /// Minimum land unit size in region co-ordinates. | ||
71 | /// </summary> | ||
72 | public const int landUnit = 4; | ||
67 | 73 | ||
68 | private static readonly string remoteParcelRequestPath = "0009/"; | 74 | private static readonly string remoteParcelRequestPath = "0009/"; |
69 | 75 | ||
@@ -74,15 +80,10 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
74 | protected IPrimCountModule m_primCountModule; | 80 | protected IPrimCountModule m_primCountModule; |
75 | protected IDialogModule m_Dialog; | 81 | protected IDialogModule m_Dialog; |
76 | 82 | ||
77 | // Minimum for parcels to work is 64m even if we don't actually use them. | ||
78 | #pragma warning disable 0429 | ||
79 | private const int landArrayMax = ((int)((int)Constants.RegionSize / 4) >= 64) ? (int)((int)Constants.RegionSize / 4) : 64; | ||
80 | #pragma warning restore 0429 | ||
81 | |||
82 | /// <value> | 83 | /// <value> |
83 | /// Local land ids at specified region co-ordinates (region size / 4) | 84 | /// Local land ids at specified region co-ordinates (region size / 4) |
84 | /// </value> | 85 | /// </value> |
85 | private readonly int[,] m_landIDList = new int[landArrayMax, landArrayMax]; | 86 | private int[,] m_landIDList; |
86 | 87 | ||
87 | /// <value> | 88 | /// <value> |
88 | /// Land objects keyed by local id | 89 | /// Land objects keyed by local id |
@@ -123,7 +124,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
123 | public void AddRegion(Scene scene) | 124 | public void AddRegion(Scene scene) |
124 | { | 125 | { |
125 | m_scene = scene; | 126 | m_scene = scene; |
126 | m_landIDList.Initialize(); | 127 | m_landIDList = new int[m_scene.RegionInfo.RegionSizeX / landUnit, m_scene.RegionInfo.RegionSizeY / landUnit]; |
127 | landChannel = new LandChannel(scene, this); | 128 | landChannel = new LandChannel(scene, this); |
128 | 129 | ||
129 | parcelInfoCache = new Cache(); | 130 | parcelInfoCache = new Cache(); |
@@ -235,7 +236,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
235 | public void UpdateLandObject(int local_id, LandData data) | 236 | public void UpdateLandObject(int local_id, LandData data) |
236 | { | 237 | { |
237 | LandData newData = data.Copy(); | 238 | LandData newData = data.Copy(); |
238 | newData.LocalID = local_id; | 239 | newData.LocalID = local_id; |
239 | 240 | ||
240 | ILandObject land; | 241 | ILandObject land; |
241 | lock (m_landList) | 242 | lock (m_landList) |
@@ -264,7 +265,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
264 | { | 265 | { |
265 | m_landList.Clear(); | 266 | m_landList.Clear(); |
266 | m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; | 267 | m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; |
267 | m_landIDList.Initialize(); | 268 | m_landIDList = new int[m_scene.RegionInfo.RegionSizeX / landUnit, m_scene.RegionInfo.RegionSizeY / landUnit]; |
268 | } | 269 | } |
269 | } | 270 | } |
270 | 271 | ||
@@ -274,11 +275,11 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
274 | /// <returns>The parcel created.</returns> | 275 | /// <returns>The parcel created.</returns> |
275 | protected ILandObject CreateDefaultParcel() | 276 | protected ILandObject CreateDefaultParcel() |
276 | { | 277 | { |
277 | m_log.DebugFormat( | 278 | m_log.DebugFormat("{0} Creating default parcel for region {1}", LogHeader, m_scene.RegionInfo.RegionName); |
278 | "[LAND MANAGEMENT MODULE]: Creating default parcel for region {0}", m_scene.RegionInfo.RegionName); | ||
279 | 279 | ||
280 | ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); | 280 | ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); |
281 | fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); | 281 | fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, |
282 | (int)m_scene.RegionInfo.RegionSizeX, (int)m_scene.RegionInfo.RegionSizeY)); | ||
282 | fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; | 283 | fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; |
283 | fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); | 284 | fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); |
284 | 285 | ||
@@ -569,9 +570,9 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
569 | new_land.LandData.LocalID = newLandLocalID; | 570 | new_land.LandData.LocalID = newLandLocalID; |
570 | 571 | ||
571 | bool[,] landBitmap = new_land.GetLandBitmap(); | 572 | bool[,] landBitmap = new_land.GetLandBitmap(); |
572 | for (int x = 0; x < landArrayMax; x++) | 573 | for (int x = 0; x < landBitmap.GetLength(0); x++) |
573 | { | 574 | { |
574 | for (int y = 0; y < landArrayMax; y++) | 575 | for (int y = 0; y < landBitmap.GetLength(1); y++) |
575 | { | 576 | { |
576 | if (landBitmap[x, y]) | 577 | if (landBitmap[x, y]) |
577 | { | 578 | { |
@@ -601,9 +602,9 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
601 | ILandObject land; | 602 | ILandObject land; |
602 | lock (m_landList) | 603 | lock (m_landList) |
603 | { | 604 | { |
604 | for (int x = 0; x < 64; x++) | 605 | for (int x = 0; x < m_landIDList.GetLength(0); x++) |
605 | { | 606 | { |
606 | for (int y = 0; y < 64; y++) | 607 | for (int y = 0; y < m_landIDList.GetLength(1); y++) |
607 | { | 608 | { |
608 | if (m_landIDList[x, y] == local_id) | 609 | if (m_landIDList[x, y] == local_id) |
609 | { | 610 | { |
@@ -656,9 +657,9 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
656 | bool[,] landBitmapSlave = slave.GetLandBitmap(); | 657 | bool[,] landBitmapSlave = slave.GetLandBitmap(); |
657 | lock (m_landList) | 658 | lock (m_landList) |
658 | { | 659 | { |
659 | for (int x = 0; x < 64; x++) | 660 | for (int x = 0; x < landBitmapSlave.GetLength(0); x++) |
660 | { | 661 | { |
661 | for (int y = 0; y < 64; y++) | 662 | for (int y = 0; y < landBitmapSlave.GetLength(1); y++) |
662 | { | 663 | { |
663 | if (landBitmapSlave[x, y]) | 664 | if (landBitmapSlave[x, y]) |
664 | { | 665 | { |
@@ -695,20 +696,23 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
695 | int x; | 696 | int x; |
696 | int y; | 697 | int y; |
697 | 698 | ||
698 | if (x_float > Constants.RegionSize || x_float < 0 || y_float > Constants.RegionSize || y_float < 0) | 699 | if (x_float >= m_scene.RegionInfo.RegionSizeX || x_float < 0 || y_float >= m_scene.RegionInfo.RegionSizeX || y_float < 0) |
699 | return null; | 700 | return null; |
700 | 701 | ||
701 | try | 702 | try |
702 | { | 703 | { |
703 | x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float) / 4.0)); | 704 | x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float) / (float)landUnit)); |
704 | y = Convert.ToInt32(Math.Floor(Convert.ToDouble(y_float) / 4.0)); | 705 | y = Convert.ToInt32(Math.Floor(Convert.ToDouble(y_float) / (float)landUnit)); |
705 | } | 706 | } |
706 | catch (OverflowException) | 707 | catch (OverflowException) |
707 | { | 708 | { |
708 | return null; | 709 | return null; |
709 | } | 710 | } |
710 | 711 | ||
711 | if (x >= 64 || y >= 64 || x < 0 || y < 0) | 712 | if (x >= (m_scene.RegionInfo.RegionSizeX / landUnit) |
713 | || y >= (m_scene.RegionInfo.RegionSizeY / landUnit) | ||
714 | || x < 0 | ||
715 | || y < 0) | ||
712 | { | 716 | { |
713 | return null; | 717 | return null; |
714 | } | 718 | } |
@@ -740,20 +744,20 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
740 | int avx = (int)x; | 744 | int avx = (int)x; |
741 | if (avx < 0) | 745 | if (avx < 0) |
742 | avx = 0; | 746 | avx = 0; |
743 | else if (avx >= (int)Constants.RegionSize) | 747 | else if (avx >= m_scene.RegionInfo.RegionSizeX) |
744 | avx = (int)Constants.RegionSize - 1; | 748 | avx = (int)Constants.RegionSize - 1; |
745 | 749 | ||
746 | int avy = (int)y; | 750 | int avy = (int)y; |
747 | if (avy < 0) | 751 | if (avy < 0) |
748 | avy = 0; | 752 | avy = 0; |
749 | else if (avy >= (int)Constants.RegionSize) | 753 | else if (avy >= m_scene.RegionInfo.RegionSizeY) |
750 | avy = (int)Constants.RegionSize - 1; | 754 | avy = (int)Constants.RegionSize - 1; |
751 | 755 | ||
752 | lock (m_landIDList) | 756 | lock (m_landIDList) |
753 | { | 757 | { |
754 | try | 758 | try |
755 | { | 759 | { |
756 | return m_landList[m_landIDList[avx / 4, avy / 4]]; | 760 | return m_landList[m_landIDList[avx / landUnit, avy / landUnit]]; |
757 | } | 761 | } |
758 | catch (IndexOutOfRangeException) | 762 | catch (IndexOutOfRangeException) |
759 | { | 763 | { |
@@ -764,7 +768,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
764 | 768 | ||
765 | public ILandObject GetLandObject(int x, int y) | 769 | public ILandObject GetLandObject(int x, int y) |
766 | { | 770 | { |
767 | if (x >= Convert.ToInt32(Constants.RegionSize) || y >= Convert.ToInt32(Constants.RegionSize) || x < 0 || y < 0) | 771 | if (x >= m_scene.RegionInfo.RegionSizeX || y >= m_scene.RegionInfo.RegionSizeY || x < 0 || y < 0) |
768 | { | 772 | { |
769 | // These exceptions here will cause a lot of complaints from the users specifically because | 773 | // These exceptions here will cause a lot of complaints from the users specifically because |
770 | // they happen every time at border crossings | 774 | // they happen every time at border crossings |
@@ -1057,9 +1061,10 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1057 | int byteArrayCount = 0; | 1061 | int byteArrayCount = 0; |
1058 | int sequenceID = 0; | 1062 | int sequenceID = 0; |
1059 | 1063 | ||
1060 | for (int y = 0; y < Constants.RegionSize; y += 4) | 1064 | // Layer data is in landUnit (4m) chunks |
1065 | for (int y = 0; y < m_scene.RegionInfo.RegionSizeY; y += landUnit) | ||
1061 | { | 1066 | { |
1062 | for (int x = 0; x < Constants.RegionSize; x += 4) | 1067 | for (int x = 0; x < m_scene.RegionInfo.RegionSizeX; x += landUnit) |
1063 | { | 1068 | { |
1064 | byte tempByte = 0; //This represents the byte for the current 4x4 | 1069 | byte tempByte = 0; //This represents the byte for the current 4x4 |
1065 | 1070 | ||
@@ -1769,7 +1774,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1769 | { | 1774 | { |
1770 | // most likely still cached from building the extLandData entry | 1775 | // most likely still cached from building the extLandData entry |
1771 | uint x = 0, y = 0; | 1776 | uint x = 0, y = 0; |
1772 | Utils.LongToUInts(data.RegionHandle, out x, out y); | 1777 | Util.RegionHandleToWorldLoc(data.RegionHandle, out x, out y); |
1773 | info = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y); | 1778 | info = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y); |
1774 | } | 1779 | } |
1775 | // we need to transfer the fake parcelID, not the one in landData, so the viewer can match it to the landmark. | 1780 | // we need to transfer the fake parcelID, not the one in landData, so the viewer can match it to the landmark. |