From 63533412f882fd55c0c40989d97f8a8262bc4e3c Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 6 Apr 2011 18:57:50 +0100
Subject: Improve previous ILandObject method doc.
For test code, take a part name prefix when creating objects, so that these can be more easily identified in the logs
---
.../CoreModules/World/Land/LandManagementModule.cs | 12 +++
.../CoreModules/World/Land/PrimCountModule.cs | 22 +++--
.../World/Land/Tests/PrimCountModuleTests.cs | 102 ++++++++++++---------
3 files changed, 87 insertions(+), 49 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index abc7a3a..bfab7b8 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -612,6 +612,10 @@ namespace OpenSim.Region.CoreModules.World.Land
{
if (landBitmap[x, y])
{
+// m_log.DebugFormat(
+// "[LAND MANAGEMENT MODULE]: Registering parcel {0} for land co-ord ({1}, {2}) on {3}",
+// new_land.LandData.Name, x, y, m_scene.RegionInfo.RegionName);
+
m_landIDList[x, y] = newLandLocalID;
}
}
@@ -741,8 +745,16 @@ namespace OpenSim.Region.CoreModules.World.Land
// Corner case. If an autoreturn happens during sim startup
// we will come here with the list uninitialized
//
+ int landId = m_landIDList[x, y];
+
+// if (landId == 0)
+// m_log.DebugFormat(
+// "[LAND MANAGEMENT MODULE]: No land object found at ({0}, {1}) on {2}",
+// x, y, m_scene.RegionInfo.RegionName);
+
if (m_landList.ContainsKey(m_landIDList[x, y]))
return m_landList[m_landIDList[x, y]];
+
return null;
}
}
diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
index 7a04eb1..dca842a 100644
--- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
@@ -173,24 +173,32 @@ namespace OpenSim.Region.CoreModules.World.Land
// NOTE: Call under Taint Lock
private void AddObject(SceneObjectGroup obj)
- {
-// m_log.DebugFormat("[PRIM COUNT MODULE]: Adding object {0} {1} to prim count", obj.Name, obj.UUID);
-
+ {
if (obj.IsAttachment)
return;
if (((obj.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0))
- return;
+ return;
Vector3 pos = obj.AbsolutePosition;
ILandObject landObject = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y);
// If for some reason there is no land object (perhaps the object is out of bounds) then we can't count it
if (landObject == null)
+ {
+// m_log.WarnFormat(
+// "[PRIM COUNT MODULE]: Found no land object for {0} at position ({1}, {2}) on {3}",
+// obj.Name, pos.X, pos.Y, m_Scene.RegionInfo.RegionName);
+
return;
+ }
LandData landData = landObject.LandData;
// m_log.DebugFormat(
+// "[PRIM COUNT MODULE]: Adding object {0} with {1} parts to prim count for parcel {2} on {3}",
+// obj.Name, obj.Parts.Length, landData.Name, m_Scene.RegionInfo.RegionName);
+
+// m_log.DebugFormat(
// "[PRIM COUNT MODULE]: Object {0} is owned by {1} over land owned by {2}",
// obj.Name, obj.OwnerID, landData.OwnerID);
@@ -473,7 +481,9 @@ namespace OpenSim.Region.CoreModules.World.Land
m_OwnerMap[landData.GlobalID] = landData.OwnerID;
m_SimwideCounts[landData.OwnerID] = 0;
-// m_log.DebugFormat("[PRIM COUNT MODULE]: Adding parcel count for {0}", landData.GlobalID);
+// m_log.DebugFormat(
+// "[PRIM COUNT MODULE]: Initializing parcel count for {0} on {1}",
+// landData.Name, m_Scene.RegionInfo.RegionName);
m_ParcelCounts[landData.GlobalID] = new ParcelCounts();
}
@@ -583,4 +593,4 @@ namespace OpenSim.Region.CoreModules.World.Land
}
}
}
-}
+}
\ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs
index 4acba18..d161bb8 100644
--- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs
+++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs
@@ -51,9 +51,14 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
protected PrimCountModule m_pcm;
///
- /// A parcel that covers the entire sim.
+ /// A parcel that covers the entire sim except for a 1 unit wide strip on the eastern side.
///
protected ILandObject m_lo;
+
+ ///
+ /// A parcel that covers just the eastern strip of the sim.
+ ///
+ protected ILandObject m_lo2;
[SetUp]
public void SetUp()
@@ -63,10 +68,19 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
m_scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(m_scene, lmm, m_pcm);
+ int xParcelDivider = (int)Constants.RegionSize - 1;
+
ILandObject lo = new LandObject(m_userId, false, m_scene);
+ lo.LandData.Name = "m_lo";
lo.SetLandBitmap(
- lo.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize / 4 - 1, (int)Constants.RegionSize / 4 - 1));
+ lo.GetSquareLandBitmap(0, 0, xParcelDivider, (int)Constants.RegionSize));
m_lo = lmm.AddLandObject(lo);
+
+ ILandObject lo2 = new LandObject(m_userId, false, m_scene);
+ lo2.SetLandBitmap(
+ lo2.GetSquareLandBitmap(xParcelDivider, 0, (int)Constants.RegionSize, (int)Constants.RegionSize));
+ lo2.LandData.Name = "m_lo2";
+ m_lo2 = lmm.AddLandObject(lo2);
}
///
@@ -98,7 +112,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
IPrimCounts pc = m_lo.PrimCounts;
- SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x01);
+ SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01);
m_scene.AddNewSceneObject(sog, false);
Assert.That(pc.Owner, Is.EqualTo(3));
@@ -111,7 +125,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
Assert.That(pc.Simulator, Is.EqualTo(3));
// Add a second object and retest
- SceneObjectGroup sog2 = SceneSetupHelpers.CreateSceneObject(2, m_userId, 0x10);
+ SceneObjectGroup sog2 = SceneSetupHelpers.CreateSceneObject(2, m_userId, "b", 0x10);
m_scene.AddNewSceneObject(sog2, false);
Assert.That(pc.Owner, Is.EqualTo(5));
@@ -135,7 +149,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
IPrimCounts pc = m_lo.PrimCounts;
- SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x01);
+ SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01);
m_scene.AddNewSceneObject(sog, false);
m_scene.SceneGraph.DuplicateObject(sog.LocalId, Vector3.Zero, 0, m_userId, UUID.Zero, Quaternion.Identity);
@@ -156,35 +170,37 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
//[Test]
public void TestMoveOwnerObject()
{
-// TestHelper.InMethod();
-//// log4net.Config.XmlConfigurator.Configure();
-//
-// IPrimCounts pc = m_lo.PrimCounts;
-//
-// SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x01);
-// m_scene.AddNewSceneObject(sog, false);
-//
-// Assert.That(pc.Owner, Is.EqualTo(3));
-// Assert.That(pc.Group, Is.EqualTo(0));
-// Assert.That(pc.Others, Is.EqualTo(0));
-// Assert.That(pc.Total, Is.EqualTo(3));
-// Assert.That(pc.Selected, Is.EqualTo(0));
-// Assert.That(pc.Users[m_userId], Is.EqualTo(3));
-// Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0));
-// Assert.That(pc.Simulator, Is.EqualTo(3));
-//
-// // Add a second object and retest
-// SceneObjectGroup sog2 = SceneSetupHelpers.CreateSceneObject(2, m_userId, 0x10);
-// m_scene.AddNewSceneObject(sog2, false);
-//
-// Assert.That(pc.Owner, Is.EqualTo(5));
-// Assert.That(pc.Group, Is.EqualTo(0));
-// Assert.That(pc.Others, Is.EqualTo(0));
-// Assert.That(pc.Total, Is.EqualTo(5));
-// Assert.That(pc.Selected, Is.EqualTo(0));
-// Assert.That(pc.Users[m_userId], Is.EqualTo(5));
-// Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0));
-// Assert.That(pc.Simulator, Is.EqualTo(5));
+ TestHelper.InMethod();
+ log4net.Config.XmlConfigurator.Configure();
+
+ SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01);
+ m_scene.AddNewSceneObject(sog, false);
+ SceneObjectGroup sog2 = SceneSetupHelpers.CreateSceneObject(2, m_userId, "b", 0x10);
+ m_scene.AddNewSceneObject(sog2, false);
+
+ sog.AbsolutePosition = new Vector3(254, 2, 2);
+
+ IPrimCounts pclo1 = m_lo.PrimCounts;
+
+ Assert.That(pclo1.Owner, Is.EqualTo(2));
+ Assert.That(pclo1.Group, Is.EqualTo(0));
+ Assert.That(pclo1.Others, Is.EqualTo(0));
+ Assert.That(pclo1.Total, Is.EqualTo(2));
+ Assert.That(pclo1.Selected, Is.EqualTo(0));
+ Assert.That(pclo1.Users[m_userId], Is.EqualTo(2));
+ Assert.That(pclo1.Users[m_otherUserId], Is.EqualTo(0));
+ Assert.That(pclo1.Simulator, Is.EqualTo(2));
+
+ IPrimCounts pclo2 = m_lo2.PrimCounts;
+
+ Assert.That(pclo2.Owner, Is.EqualTo(3));
+ Assert.That(pclo2.Group, Is.EqualTo(0));
+ Assert.That(pclo2.Others, Is.EqualTo(0));
+ Assert.That(pclo2.Total, Is.EqualTo(3));
+ Assert.That(pclo2.Selected, Is.EqualTo(0));
+ Assert.That(pclo2.Users[m_userId], Is.EqualTo(3));
+ Assert.That(pclo2.Users[m_otherUserId], Is.EqualTo(0));
+ Assert.That(pclo2.Simulator, Is.EqualTo(3));
}
///
@@ -198,8 +214,8 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
IPrimCounts pc = m_lo.PrimCounts;
- m_scene.AddNewSceneObject(SceneSetupHelpers.CreateSceneObject(1, m_userId, 0x1), false);
- SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x10);
+ m_scene.AddNewSceneObject(SceneSetupHelpers.CreateSceneObject(1, m_userId, "a", 0x1), false);
+ SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_userId, "b", 0x10);
m_scene.AddNewSceneObject(sogToDelete, false);
m_scene.DeleteSceneObject(sogToDelete, false);
@@ -223,7 +239,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
IPrimCounts pc = m_lo.PrimCounts;
- SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, 0x01);
+ SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, "a", 0x01);
sog.GroupID = m_groupId;
m_scene.AddNewSceneObject(sog, false);
@@ -254,11 +270,11 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
IPrimCounts pc = m_lo.PrimCounts;
- SceneObjectGroup sogToKeep = SceneSetupHelpers.CreateSceneObject(1, m_userId, 0x1);
+ SceneObjectGroup sogToKeep = SceneSetupHelpers.CreateSceneObject(1, m_userId, "a", 0x1);
sogToKeep.GroupID = m_groupId;
m_scene.AddNewSceneObject(sogToKeep, false);
- SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x10);
+ SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_userId, "b", 0x10);
m_scene.AddNewSceneObject(sogToDelete, false);
m_scene.DeleteSceneObject(sogToDelete, false);
@@ -281,7 +297,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
IPrimCounts pc = m_lo.PrimCounts;
- SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, 0x01);
+ SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, "a", 0x01);
m_scene.AddNewSceneObject(sog, false);
Assert.That(pc.Owner, Is.EqualTo(0));
@@ -302,8 +318,8 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
IPrimCounts pc = m_lo.PrimCounts;
- m_scene.AddNewSceneObject(SceneSetupHelpers.CreateSceneObject(1, m_otherUserId, 0x1), false);
- SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, 0x10);
+ m_scene.AddNewSceneObject(SceneSetupHelpers.CreateSceneObject(1, m_otherUserId, "a", 0x1), false);
+ SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, "b", 0x10);
m_scene.AddNewSceneObject(sogToDelete, false);
m_scene.DeleteSceneObject(sogToDelete, false);
@@ -326,7 +342,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
TestHelper.InMethod();
IPrimCounts pc = m_lo.PrimCounts;
- SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x01);
+ SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01);
m_scene.AddNewSceneObject(sog, false);
m_pcm.TaintPrimCount();
--
cgit v1.1