mirror of
https://github.com/opensim/opensim.git
synced 2026-08-09 02:36:00 +08:00
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:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user