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.0.7.1-dev
parent
9c979dd0fc
commit
d011896341
|
@ -854,6 +854,10 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||||
|
|
||||||
public void EventManagerOnParcelPrimCountUpdate()
|
public void EventManagerOnParcelPrimCountUpdate()
|
||||||
{
|
{
|
||||||
|
// m_log.DebugFormat(
|
||||||
|
// "[LAND MANAGEMENT MODULE]: Triggered EventManagerOnParcelPrimCountUpdate() for {0}",
|
||||||
|
// m_scene.RegionInfo.RegionName);
|
||||||
|
|
||||||
ResetAllLandPrimCounts();
|
ResetAllLandPrimCounts();
|
||||||
EntityBase[] entities = m_scene.Entities.GetEntities();
|
EntityBase[] entities = m_scene.Entities.GetEntities();
|
||||||
foreach (EntityBase obj in entities)
|
foreach (EntityBase obj in entities)
|
||||||
|
|
|
@ -89,8 +89,7 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||||
{
|
{
|
||||||
m_Scene = scene;
|
m_Scene = scene;
|
||||||
|
|
||||||
m_Scene.EventManager.OnParcelPrimCountAdd +=
|
m_Scene.EventManager.OnObjectAddedToScene += OnParcelPrimCountAdd;
|
||||||
OnParcelPrimCountAdd;
|
|
||||||
m_Scene.EventManager.OnObjectBeingRemovedFromScene +=
|
m_Scene.EventManager.OnObjectBeingRemovedFromScene +=
|
||||||
OnObjectBeingRemovedFromScene;
|
OnObjectBeingRemovedFromScene;
|
||||||
m_Scene.EventManager.OnParcelPrimCountTainted +=
|
m_Scene.EventManager.OnParcelPrimCountTainted +=
|
||||||
|
@ -116,6 +115,7 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||||
|
|
||||||
private void OnParcelPrimCountAdd(SceneObjectGroup obj)
|
private void OnParcelPrimCountAdd(SceneObjectGroup obj)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("WIBBLE");
|
||||||
// If we're tainted already, don't bother to add. The next
|
// If we're tainted already, don't bother to add. The next
|
||||||
// access will cause a recount anyway
|
// access will cause a recount anyway
|
||||||
lock (m_TaintLock)
|
lock (m_TaintLock)
|
||||||
|
@ -173,6 +173,10 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||||
ILandObject landObject = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y);
|
ILandObject landObject = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y);
|
||||||
LandData landData = landObject.LandData;
|
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;
|
ParcelCounts parcelCounts;
|
||||||
if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts))
|
if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts))
|
||||||
{
|
{
|
||||||
|
@ -228,6 +232,8 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||||
|
|
||||||
public int GetOwnerCount(UUID parcelID)
|
public int GetOwnerCount(UUID parcelID)
|
||||||
{
|
{
|
||||||
|
// m_log.DebugFormat("[PRIM COUNT MODULE]: GetOwnerCount for {0}", parcelID);
|
||||||
|
|
||||||
lock (m_TaintLock)
|
lock (m_TaintLock)
|
||||||
{
|
{
|
||||||
if (m_Tainted)
|
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)
|
= new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero)
|
||||||
{ Name = objName, UUID = objUuid };
|
{ Name = objName, UUID = objUuid };
|
||||||
|
|
||||||
|
Assert.That(pcm.GetOwnerCount(lo.LandData.GlobalID), Is.EqualTo(0));
|
||||||
|
|
||||||
scene.AddNewSceneObject(new SceneObjectGroup(part), false);
|
scene.AddNewSceneObject(new SceneObjectGroup(part), false);
|
||||||
|
|
||||||
Assert.That(pcm.GetOwnerCount(lo.LandData.GlobalID), Is.EqualTo(1));
|
Assert.That(pcm.GetOwnerCount(lo.LandData.GlobalID), Is.EqualTo(1));
|
||||||
|
|
|
@ -243,6 +243,14 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
public event EstateToolsSunUpdate OnEstateToolsSunUpdate;
|
public event EstateToolsSunUpdate OnEstateToolsSunUpdate;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Triggered when an object is added to the scene.
|
||||||
|
/// </summary>
|
||||||
|
public event Action<SceneObjectGroup> OnObjectAddedToScene;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Triggered when an object is removed from the scene.
|
||||||
|
/// </summary>
|
||||||
public delegate void ObjectBeingRemovedFromScene(SceneObjectGroup obj);
|
public delegate void ObjectBeingRemovedFromScene(SceneObjectGroup obj);
|
||||||
public event ObjectBeingRemovedFromScene OnObjectBeingRemovedFromScene;
|
public event ObjectBeingRemovedFromScene OnObjectBeingRemovedFromScene;
|
||||||
|
|
||||||
|
@ -345,6 +353,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
public delegate void Attach(uint localID, UUID itemID, UUID avatarID);
|
public delegate void Attach(uint localID, UUID itemID, UUID avatarID);
|
||||||
public event Attach OnAttach;
|
public event Attach OnAttach;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called immediately after an object is loaded from storage.
|
/// Called immediately after an object is loaded from storage.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -800,6 +809,27 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void TriggerObjectAddedToScene(SceneObjectGroup obj)
|
||||||
|
{
|
||||||
|
Action<SceneObjectGroup> handler = OnObjectAddedToScene;
|
||||||
|
if (handler != null)
|
||||||
|
{
|
||||||
|
foreach (Action<SceneObjectGroup> d in handler.GetInvocationList())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
d(obj);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat(
|
||||||
|
"[EVENT MANAGER]: Delegate for TriggerObjectAddedToScene failed - continuing. {0} {1}",
|
||||||
|
e.Message, e.StackTrace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void TriggerObjectBeingRemovedFromScene(SceneObjectGroup obj)
|
public void TriggerObjectBeingRemovedFromScene(SceneObjectGroup obj)
|
||||||
{
|
{
|
||||||
ObjectBeingRemovedFromScene handlerObjectBeingRemovedFromScene = OnObjectBeingRemovedFromScene;
|
ObjectBeingRemovedFromScene handlerObjectBeingRemovedFromScene = OnObjectBeingRemovedFromScene;
|
||||||
|
|
|
@ -1957,7 +1957,13 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
/// </param>
|
/// </param>
|
||||||
public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates)
|
public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates)
|
||||||
{
|
{
|
||||||
return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates);
|
if (m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates))
|
||||||
|
{
|
||||||
|
EventManager.TriggerObjectAddedToScene(sceneObject);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1974,7 +1980,13 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
public bool AddNewSceneObject(
|
public bool AddNewSceneObject(
|
||||||
SceneObjectGroup sceneObject, bool attachToBackup, Vector3 pos, Quaternion rot, Vector3 vel)
|
SceneObjectGroup sceneObject, bool attachToBackup, Vector3 pos, Quaternion rot, Vector3 vel)
|
||||||
{
|
{
|
||||||
return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, pos, rot, vel);
|
if (m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, pos, rot, vel))
|
||||||
|
{
|
||||||
|
EventManager.TriggerObjectAddedToScene(sceneObject);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue