aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2014-03-11 23:38:22 +0000
committerJustin Clark-Casey (justincc)2014-03-11 23:38:22 +0000
commitd975b42f6ae01441e261d51976513de422fae3e3 (patch)
tree0f51e1b2206dfcdb7f0e0561f7c9950749ce23f8 /OpenSim/Region
parentDon't start KeyframeMotion timers until all the regions are ready. This preve... (diff)
downloadopensim-SC_OLD-d975b42f6ae01441e261d51976513de422fae3e3.zip
opensim-SC_OLD-d975b42f6ae01441e261d51976513de422fae3e3.tar.gz
opensim-SC_OLD-d975b42f6ae01441e261d51976513de422fae3e3.tar.bz2
opensim-SC_OLD-d975b42f6ae01441e261d51976513de422fae3e3.tar.xz
Instead of auto-creating a parcel on request if one doesn't cover a given location, fill in gaps or extend existing parcel right after initial data load.
This is in line with simpler and still existing behaviour where a default parcel is created if no parcels are in storage at all. Making this change as another step to address current problems with spurious parcels occasionally being created. Also adds regression tests for different load behaviours depending on existing stored parcel data. Relates to http://opensimulator.org/mantis/view.php?id=7035
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs123
-rw-r--r--OpenSim/Region/CoreModules/World/Land/Tests/LandManagementModuleTests.cs155
2 files changed, 211 insertions, 67 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index bbb0176..7f17aff 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -863,72 +863,7 @@ namespace OpenSim.Region.CoreModules.World.Land
863 ); 863 );
864 } 864 }
865 865
866 lock (m_landIDList) 866 return m_landList[m_landIDList[x / 4, y / 4]];
867 {
868 int landID = m_landIDList[x / LandUnit, y / LandUnit];
869 if (landID == 0)
870 {
871 // Zero is the uninitialized value saying there is no parcel for this location.
872 // This sometimes happens when terrain is resized.
873 if (m_landList.Count == 1)
874 {
875 m_log.DebugFormat(
876 "[{0}]: Auto-extending land parcel as landID at {1},{2} is 0 and only one land parcel is present in {3}",
877 LogHeader, x, y, m_scene.Name);
878
879 int onlyParcelID = 0;
880 ILandObject onlyLandObject = null;
881 foreach (KeyValuePair<int, ILandObject> kvp in m_landList)
882 {
883 onlyParcelID = kvp.Key;
884 onlyLandObject = kvp.Value;
885 break;
886 }
887
888 // There is only one parcel. Grow it to fill all the unallocated spaces.
889 for (int xx = 0; xx < m_landIDList.GetLength(0); xx++)
890 for (int yy = 0; yy < m_landIDList.GetLength(1); yy++)
891 if (m_landIDList[xx, yy] == 0)
892 m_landIDList[xx, yy] = onlyParcelID;
893
894 onlyLandObject.LandBitmap = CreateBitmapForID(onlyParcelID);
895 landID = onlyParcelID;
896 }
897 else if (m_landList.Count > 1)
898 {
899 m_log.DebugFormat(
900 "[{0}]: Auto-creating land parcel as landID at {1},{2} is 0 and more than one land parcel is present in {3}",
901 LogHeader, x, y, m_scene.Name);
902
903 // There are several other parcels so we must create a new one for the unassigned space
904 ILandObject newLand = new LandObject(UUID.Zero, false, m_scene);
905 // Claim all the unclaimed "0" ids
906 newLand.SetLandBitmap(CreateBitmapForID(0));
907 newLand.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
908 newLand.LandData.ClaimDate = Util.UnixTimeSinceEpoch();
909 newLand = AddLandObject(newLand);
910
911 if (newLand == null)
912 return null;
913
914 landID = m_lastLandLocalID;
915 }
916 else
917 {
918 // XXX: We're not currently doing anything if there are no parcels, as this might indicate a race
919 // condition where this method is being called before land data is loaded. May need to address
920 // this in another way.
921
922 m_log.WarnFormat(
923 "[{0}]: Ignoring request to auto-create parcel in {1} as there are no other parcels present",
924 LogHeader, m_scene.Name);
925 }
926 }
927
928 ret = m_landList[landID];
929 }
930
931 return ret;
932 } 867 }
933 868
934 // Create a 'parcel is here' bitmap for the parcel identified by the passed landID 869 // Create a 'parcel is here' bitmap for the parcel identified by the passed landID
@@ -1226,6 +1161,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1226 1161
1227 } 1162 }
1228 } 1163 }
1164
1229 if (byteArrayCount != 0) 1165 if (byteArrayCount != 0)
1230 { 1166 {
1231 remote_client.SendLandParcelOverlay(byteArray, sequenceID); 1167 remote_client.SendLandParcelOverlay(byteArray, sequenceID);
@@ -1543,6 +1479,61 @@ namespace OpenSim.Region.CoreModules.World.Land
1543 { 1479 {
1544 for (int i = 0; i < data.Count; i++) 1480 for (int i = 0; i < data.Count; i++)
1545 IncomingLandObjectFromStorage(data[i]); 1481 IncomingLandObjectFromStorage(data[i]);
1482
1483 // Layer data is in landUnit (4m) chunks
1484 for (int y = 0; y < m_scene.RegionInfo.RegionSizeY / Constants.TerrainPatchSize * (Constants.TerrainPatchSize / LandUnit); y++)
1485 {
1486 for (int x = 0; x < m_scene.RegionInfo.RegionSizeX / Constants.TerrainPatchSize * (Constants.TerrainPatchSize / LandUnit); x++)
1487 {
1488 if (m_landIDList[x, y] == 0)
1489 {
1490 if (m_landList.Count == 1)
1491 {
1492 m_log.DebugFormat(
1493 "[{0}]: Auto-extending land parcel as landID at {1},{2} is 0 and only one land parcel is present in {3}",
1494 LogHeader, x, y, m_scene.Name);
1495
1496 int onlyParcelID = 0;
1497 ILandObject onlyLandObject = null;
1498 foreach (KeyValuePair<int, ILandObject> kvp in m_landList)
1499 {
1500 onlyParcelID = kvp.Key;
1501 onlyLandObject = kvp.Value;
1502 break;
1503 }
1504
1505 // There is only one parcel. Grow it to fill all the unallocated spaces.
1506 for (int xx = 0; xx < m_landIDList.GetLength(0); xx++)
1507 for (int yy = 0; yy < m_landIDList.GetLength(1); yy++)
1508 if (m_landIDList[xx, yy] == 0)
1509 m_landIDList[xx, yy] = onlyParcelID;
1510
1511 onlyLandObject.LandBitmap = CreateBitmapForID(onlyParcelID);
1512 }
1513 else if (m_landList.Count > 1)
1514 {
1515 m_log.DebugFormat(
1516 "{0}: Auto-creating land parcel as landID at {1},{2} is 0 and more than one land parcel is present in {3}",
1517 LogHeader, x, y, m_scene.Name);
1518
1519 // There are several other parcels so we must create a new one for the unassigned space
1520 ILandObject newLand = new LandObject(UUID.Zero, false, m_scene);
1521 // Claim all the unclaimed "0" ids
1522 newLand.SetLandBitmap(CreateBitmapForID(0));
1523 newLand.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
1524 newLand.LandData.ClaimDate = Util.UnixTimeSinceEpoch();
1525 newLand = AddLandObject(newLand);
1526 }
1527 else
1528 {
1529 // We should never reach this point as the separate code path when no land data exists should have fired instead.
1530 m_log.WarnFormat(
1531 "{0}: Ignoring request to auto-create parcel in {1} as there are no other parcels present",
1532 LogHeader, m_scene.Name);
1533 }
1534 }
1535 }
1536 }
1546 } 1537 }
1547 } 1538 }
1548 1539
diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/LandManagementModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/LandManagementModuleTests.cs
index a886e33..6d0253d 100644
--- a/OpenSim/Region/CoreModules/World/Land/Tests/LandManagementModuleTests.cs
+++ b/OpenSim/Region/CoreModules/World/Land/Tests/LandManagementModuleTests.cs
@@ -35,7 +35,7 @@ using OpenSim.Tests.Common.Mock;
35 35
36namespace OpenSim.Region.CoreModules.World.Land.Tests 36namespace OpenSim.Region.CoreModules.World.Land.Tests
37{ 37{
38 public class LandManagementModuleTests 38 public class LandManagementModuleTests : OpenSimTestCase
39 { 39 {
40 [Test] 40 [Test]
41 public void TestAddLandObject() 41 public void TestAddLandObject()
@@ -78,6 +78,159 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
78 } 78 }
79 } 79 }
80 80
81 /// <summary>
82 /// Test parcels on region when no land data exists to be loaded.
83 /// </summary>
84 [Test]
85 public void TestLoadWithNoParcels()
86 {
87 TestHelpers.InMethod();
88// TestHelpers.EnableLogging();
89
90 SceneHelpers sh = new SceneHelpers();
91 LandManagementModule lmm = new LandManagementModule();
92 Scene scene = sh.SetupScene();
93 SceneHelpers.SetupSceneModules(scene, lmm);
94
95 scene.loadAllLandObjectsFromStorage(scene.RegionInfo.RegionID);
96
97 ILandObject loAtCoord1 = lmm.GetLandObject(0, 0);
98 Assert.That(loAtCoord1.LandData.LocalID, Is.Not.EqualTo(0));
99 Assert.That(loAtCoord1.LandData.GlobalID, Is.Not.EqualTo(UUID.Zero));
100
101 ILandObject loAtCoord2 = lmm.GetLandObject((int)Constants.RegionSize - 1, ((int)Constants.RegionSize - 1));
102 Assert.That(loAtCoord2.LandData.LocalID, Is.EqualTo(loAtCoord1.LandData.LocalID));
103 Assert.That(loAtCoord2.LandData.GlobalID, Is.EqualTo(loAtCoord1.LandData.GlobalID));
104 }
105
106 /// <summary>
107 /// Test parcels on region when a single parcel already exists but it does not cover the whole region.
108 /// </summary>
109 [Test]
110 public void TestLoadWithSinglePartialCoveringParcel()
111 {
112 TestHelpers.InMethod();
113// TestHelpers.EnableLogging();
114
115 UUID userId = TestHelpers.ParseTail(0x1);
116
117 SceneHelpers sh = new SceneHelpers();
118 LandManagementModule lmm = new LandManagementModule();
119 Scene scene = sh.SetupScene();
120 SceneHelpers.SetupSceneModules(scene, lmm);
121
122 ILandObject originalLo1 = new LandObject(userId, false, scene);
123 originalLo1.LandData.Name = "lo1";
124 originalLo1.SetLandBitmap(
125 originalLo1.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize / 2));
126
127 sh.SimDataService.StoreLandObject(originalLo1);
128
129 scene.loadAllLandObjectsFromStorage(scene.RegionInfo.RegionID);
130
131 ILandObject loAtCoord1 = lmm.GetLandObject(0, 0);
132 Assert.That(loAtCoord1.LandData.Name, Is.EqualTo(originalLo1.LandData.Name));
133 Assert.That(loAtCoord1.LandData.GlobalID, Is.EqualTo(originalLo1.LandData.GlobalID));
134
135 ILandObject loAtCoord2 = lmm.GetLandObject((int)Constants.RegionSize - 1, ((int)Constants.RegionSize - 1));
136 Assert.That(loAtCoord2.LandData.LocalID, Is.EqualTo(loAtCoord1.LandData.LocalID));
137 Assert.That(loAtCoord2.LandData.GlobalID, Is.EqualTo(loAtCoord1.LandData.GlobalID));
138 }
139
140 /// <summary>
141 /// Test parcels on region when a single parcel already exists but it does not cover the whole region.
142 /// </summary>
143 [Test]
144 public void TestLoadWithMultiplePartialCoveringParcels()
145 {
146 TestHelpers.InMethod();
147// TestHelpers.EnableLogging();
148
149 UUID userId = TestHelpers.ParseTail(0x1);
150
151 SceneHelpers sh = new SceneHelpers();
152 LandManagementModule lmm = new LandManagementModule();
153 Scene scene = sh.SetupScene();
154 SceneHelpers.SetupSceneModules(scene, lmm);
155
156 ILandObject originalLo1 = new LandObject(userId, false, scene);
157 originalLo1.LandData.Name = "lo1";
158 originalLo1.SetLandBitmap(
159 originalLo1.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize / 2));
160
161 sh.SimDataService.StoreLandObject(originalLo1);
162
163 ILandObject originalLo2 = new LandObject(userId, false, scene);
164 originalLo2.LandData.Name = "lo2";
165 originalLo2.SetLandBitmap(
166 originalLo2.GetSquareLandBitmap(
167 0, (int)Constants.RegionSize / 2, (int)Constants.RegionSize, ((int)Constants.RegionSize / 4) * 3));
168
169 sh.SimDataService.StoreLandObject(originalLo2);
170
171 scene.loadAllLandObjectsFromStorage(scene.RegionInfo.RegionID);
172
173 ILandObject loAtCoord1 = lmm.GetLandObject(0, 0);
174 Assert.That(loAtCoord1.LandData.Name, Is.EqualTo(originalLo1.LandData.Name));
175 Assert.That(loAtCoord1.LandData.GlobalID, Is.EqualTo(originalLo1.LandData.GlobalID));
176
177 ILandObject loAtCoord2
178 = lmm.GetLandObject((int)Constants.RegionSize - 1, (((int)Constants.RegionSize / 4) * 3) - 1);
179 Assert.That(loAtCoord2.LandData.Name, Is.EqualTo(originalLo2.LandData.Name));
180 Assert.That(loAtCoord2.LandData.GlobalID, Is.EqualTo(originalLo2.LandData.GlobalID));
181
182 ILandObject loAtCoord3 = lmm.GetLandObject((int)Constants.RegionSize - 1, ((int)Constants.RegionSize - 1));
183 Assert.That(loAtCoord3.LandData.LocalID, Is.Not.EqualTo(loAtCoord1.LandData.LocalID));
184 Assert.That(loAtCoord3.LandData.LocalID, Is.Not.EqualTo(loAtCoord2.LandData.LocalID));
185 Assert.That(loAtCoord3.LandData.GlobalID, Is.Not.EqualTo(loAtCoord1.LandData.GlobalID));
186 Assert.That(loAtCoord3.LandData.GlobalID, Is.Not.EqualTo(loAtCoord2.LandData.GlobalID));
187 }
188
189 /// <summary>
190 /// Test parcels on region when whole region is parcelled (which should normally always be the case).
191 /// </summary>
192 [Test]
193 public void TestLoad()
194 {
195 TestHelpers.InMethod();
196// TestHelpers.EnableLogging();
197
198 UUID userId = TestHelpers.ParseTail(0x1);
199
200 SceneHelpers sh = new SceneHelpers();
201 LandManagementModule lmm = new LandManagementModule();
202 Scene scene = sh.SetupScene();
203 SceneHelpers.SetupSceneModules(scene, lmm);
204
205 ILandObject originalLo1 = new LandObject(userId, false, scene);
206 originalLo1.LandData.Name = "lo1";
207 originalLo1.SetLandBitmap(
208 originalLo1.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize / 2));
209
210 sh.SimDataService.StoreLandObject(originalLo1);
211
212 ILandObject originalLo2 = new LandObject(userId, false, scene);
213 originalLo2.LandData.Name = "lo2";
214 originalLo2.SetLandBitmap(
215 originalLo2.GetSquareLandBitmap(0, (int)Constants.RegionSize / 2, (int)Constants.RegionSize, (int)Constants.RegionSize));
216
217 sh.SimDataService.StoreLandObject(originalLo2);
218
219 scene.loadAllLandObjectsFromStorage(scene.RegionInfo.RegionID);
220
221 {
222 ILandObject loAtCoord = lmm.GetLandObject(0, 0);
223 Assert.That(loAtCoord.LandData.Name, Is.EqualTo(originalLo1.LandData.Name));
224 Assert.That(loAtCoord.LandData.GlobalID, Is.EqualTo(originalLo1.LandData.GlobalID));
225 }
226
227 {
228 ILandObject loAtCoord = lmm.GetLandObject((int)Constants.RegionSize - 1, ((int)Constants.RegionSize - 1));
229 Assert.That(loAtCoord.LandData.Name, Is.EqualTo(originalLo2.LandData.Name));
230 Assert.That(loAtCoord.LandData.GlobalID, Is.EqualTo(originalLo2.LandData.GlobalID));
231 }
232 }
233
81 [Test] 234 [Test]
82 public void TestSubdivide() 235 public void TestSubdivide()
83 { 236 {