Add generic EventManager.OnObjectAddedToScene and get PrimCountModule to listen for that rather than EventManager.OnParcelPrimCountAdd

OnParcelPrimCountAdd had the wrong semantics for the PrimCountModule - it was invoked for every entity in the scene, not just new ones, which would screw up the untainted count.
Extend automated test for this scenario.
This commit is contained in:
Justin Clark-Casey (justincc)
2011-03-23 21:50:56 +00:00
parent 9c979dd0fc
commit d011896341
5 changed files with 59 additions and 5 deletions

View File

@@ -854,6 +854,10 @@ namespace OpenSim.Region.CoreModules.World.Land
public void EventManagerOnParcelPrimCountUpdate()
{
// m_log.DebugFormat(
// "[LAND MANAGEMENT MODULE]: Triggered EventManagerOnParcelPrimCountUpdate() for {0}",
// m_scene.RegionInfo.RegionName);
ResetAllLandPrimCounts();
EntityBase[] entities = m_scene.Entities.GetEntities();
foreach (EntityBase obj in entities)

View File

@@ -89,8 +89,7 @@ namespace OpenSim.Region.CoreModules.World.Land
{
m_Scene = scene;
m_Scene.EventManager.OnParcelPrimCountAdd +=
OnParcelPrimCountAdd;
m_Scene.EventManager.OnObjectAddedToScene += OnParcelPrimCountAdd;
m_Scene.EventManager.OnObjectBeingRemovedFromScene +=
OnObjectBeingRemovedFromScene;
m_Scene.EventManager.OnParcelPrimCountTainted +=
@@ -116,6 +115,7 @@ namespace OpenSim.Region.CoreModules.World.Land
private void OnParcelPrimCountAdd(SceneObjectGroup obj)
{
Console.WriteLine("WIBBLE");
// If we're tainted already, don't bother to add. The next
// access will cause a recount anyway
lock (m_TaintLock)
@@ -172,6 +172,10 @@ namespace OpenSim.Region.CoreModules.World.Land
Vector3 pos = obj.AbsolutePosition;
ILandObject landObject = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y);
LandData landData = landObject.LandData;
// m_log.DebugFormat(
// "[PRIM COUNT MODULE]: Object {0} is owned by {1} over land owned by {2}",
// obj.Name, obj.OwnerID, landData.OwnerID);
ParcelCounts parcelCounts;
if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts))
@@ -228,6 +232,8 @@ namespace OpenSim.Region.CoreModules.World.Land
public int GetOwnerCount(UUID parcelID)
{
// m_log.DebugFormat("[PRIM COUNT MODULE]: GetOwnerCount for {0}", parcelID);
lock (m_TaintLock)
{
if (m_Tainted)

View File

@@ -67,6 +67,8 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
= new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero)
{ Name = objName, UUID = objUuid };
Assert.That(pcm.GetOwnerCount(lo.LandData.GlobalID), Is.EqualTo(0));
scene.AddNewSceneObject(new SceneObjectGroup(part), false);
Assert.That(pcm.GetOwnerCount(lo.LandData.GlobalID), Is.EqualTo(1));