diff options
author | Justin Clark-Casey (justincc) | 2011-03-23 21:50:56 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-03-23 21:53:14 +0000 |
commit | d011896341d09ce6c10a801264e663b6a19f0b48 (patch) | |
tree | 02369e0c5a2103e8f42f5bf6128814de9e2afaf5 /OpenSim/Region | |
parent | Fix a typo in the SQLite DLL config and amend the instructions for running on... (diff) | |
download | opensim-SC_OLD-d011896341d09ce6c10a801264e663b6a19f0b48.zip opensim-SC_OLD-d011896341d09ce6c10a801264e663b6a19f0b48.tar.gz opensim-SC_OLD-d011896341d09ce6c10a801264e663b6a19f0b48.tar.bz2 opensim-SC_OLD-d011896341d09ce6c10a801264e663b6a19f0b48.tar.xz |
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.
Diffstat (limited to 'OpenSim/Region')
5 files changed, 59 insertions, 5 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 514be4f..4d887a8 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | |||
@@ -854,6 +854,10 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
854 | 854 | ||
855 | public void EventManagerOnParcelPrimCountUpdate() | 855 | public void EventManagerOnParcelPrimCountUpdate() |
856 | { | 856 | { |
857 | // m_log.DebugFormat( | ||
858 | // "[LAND MANAGEMENT MODULE]: Triggered EventManagerOnParcelPrimCountUpdate() for {0}", | ||
859 | // m_scene.RegionInfo.RegionName); | ||
860 | |||
857 | ResetAllLandPrimCounts(); | 861 | ResetAllLandPrimCounts(); |
858 | EntityBase[] entities = m_scene.Entities.GetEntities(); | 862 | EntityBase[] entities = m_scene.Entities.GetEntities(); |
859 | foreach (EntityBase obj in entities) | 863 | foreach (EntityBase obj in entities) |
diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index c71264c..5371aaf 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs | |||
@@ -89,8 +89,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
89 | { | 89 | { |
90 | m_Scene = scene; | 90 | m_Scene = scene; |
91 | 91 | ||
92 | m_Scene.EventManager.OnParcelPrimCountAdd += | 92 | m_Scene.EventManager.OnObjectAddedToScene += OnParcelPrimCountAdd; |
93 | OnParcelPrimCountAdd; | ||
94 | m_Scene.EventManager.OnObjectBeingRemovedFromScene += | 93 | m_Scene.EventManager.OnObjectBeingRemovedFromScene += |
95 | OnObjectBeingRemovedFromScene; | 94 | OnObjectBeingRemovedFromScene; |
96 | m_Scene.EventManager.OnParcelPrimCountTainted += | 95 | m_Scene.EventManager.OnParcelPrimCountTainted += |
@@ -116,6 +115,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
116 | 115 | ||
117 | private void OnParcelPrimCountAdd(SceneObjectGroup obj) | 116 | private void OnParcelPrimCountAdd(SceneObjectGroup obj) |
118 | { | 117 | { |
118 | Console.WriteLine("WIBBLE"); | ||
119 | // If we're tainted already, don't bother to add. The next | 119 | // If we're tainted already, don't bother to add. The next |
120 | // access will cause a recount anyway | 120 | // access will cause a recount anyway |
121 | lock (m_TaintLock) | 121 | lock (m_TaintLock) |
@@ -172,6 +172,10 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
172 | Vector3 pos = obj.AbsolutePosition; | 172 | Vector3 pos = obj.AbsolutePosition; |
173 | ILandObject landObject = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y); | 173 | ILandObject landObject = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y); |
174 | LandData landData = landObject.LandData; | 174 | LandData landData = landObject.LandData; |
175 | |||
176 | // m_log.DebugFormat( | ||
177 | // "[PRIM COUNT MODULE]: Object {0} is owned by {1} over land owned by {2}", | ||
178 | // obj.Name, obj.OwnerID, landData.OwnerID); | ||
175 | 179 | ||
176 | ParcelCounts parcelCounts; | 180 | ParcelCounts parcelCounts; |
177 | if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts)) | 181 | if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts)) |
@@ -228,6 +232,8 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
228 | 232 | ||
229 | public int GetOwnerCount(UUID parcelID) | 233 | public int GetOwnerCount(UUID parcelID) |
230 | { | 234 | { |
235 | // m_log.DebugFormat("[PRIM COUNT MODULE]: GetOwnerCount for {0}", parcelID); | ||
236 | |||
231 | lock (m_TaintLock) | 237 | lock (m_TaintLock) |
232 | { | 238 | { |
233 | if (m_Tainted) | 239 | if (m_Tainted) |
diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs index 402965f..fd332ed 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs | |||
@@ -67,6 +67,8 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests | |||
67 | = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) | 67 | = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) |
68 | { Name = objName, UUID = objUuid }; | 68 | { Name = objName, UUID = objUuid }; |
69 | 69 | ||
70 | Assert.That(pcm.GetOwnerCount(lo.LandData.GlobalID), Is.EqualTo(0)); | ||
71 | |||
70 | scene.AddNewSceneObject(new SceneObjectGroup(part), false); | 72 | scene.AddNewSceneObject(new SceneObjectGroup(part), false); |
71 | 73 | ||
72 | Assert.That(pcm.GetOwnerCount(lo.LandData.GlobalID), Is.EqualTo(1)); | 74 | Assert.That(pcm.GetOwnerCount(lo.LandData.GlobalID), Is.EqualTo(1)); |
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index c321a15..fd62535 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs | |||
@@ -242,7 +242,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
242 | public delegate void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID); | 242 | public delegate void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID); |
243 | 243 | ||
244 | public event EstateToolsSunUpdate OnEstateToolsSunUpdate; | 244 | public event EstateToolsSunUpdate OnEstateToolsSunUpdate; |
245 | |||
246 | /// <summary> | ||
247 | /// Triggered when an object is added to the scene. | ||
248 | /// </summary> | ||
249 | public event Action<SceneObjectGroup> OnObjectAddedToScene; | ||
245 | 250 | ||
251 | /// <summary> | ||
252 | /// Triggered when an object is removed from the scene. | ||
253 | /// </summary> | ||
246 | public delegate void ObjectBeingRemovedFromScene(SceneObjectGroup obj); | 254 | public delegate void ObjectBeingRemovedFromScene(SceneObjectGroup obj); |
247 | public event ObjectBeingRemovedFromScene OnObjectBeingRemovedFromScene; | 255 | public event ObjectBeingRemovedFromScene OnObjectBeingRemovedFromScene; |
248 | 256 | ||
@@ -345,6 +353,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
345 | public delegate void Attach(uint localID, UUID itemID, UUID avatarID); | 353 | public delegate void Attach(uint localID, UUID itemID, UUID avatarID); |
346 | public event Attach OnAttach; | 354 | public event Attach OnAttach; |
347 | 355 | ||
356 | |||
348 | /// <summary> | 357 | /// <summary> |
349 | /// Called immediately after an object is loaded from storage. | 358 | /// Called immediately after an object is loaded from storage. |
350 | /// </summary> | 359 | /// </summary> |
@@ -800,6 +809,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
800 | } | 809 | } |
801 | } | 810 | } |
802 | 811 | ||
812 | public void TriggerObjectAddedToScene(SceneObjectGroup obj) | ||
813 | { | ||
814 | Action<SceneObjectGroup> handler = OnObjectAddedToScene; | ||
815 | if (handler != null) | ||
816 | { | ||
817 | foreach (Action<SceneObjectGroup> d in handler.GetInvocationList()) | ||
818 | { | ||
819 | try | ||
820 | { | ||
821 | d(obj); | ||
822 | } | ||
823 | catch (Exception e) | ||
824 | { | ||
825 | m_log.ErrorFormat( | ||
826 | "[EVENT MANAGER]: Delegate for TriggerObjectAddedToScene failed - continuing. {0} {1}", | ||
827 | e.Message, e.StackTrace); | ||
828 | } | ||
829 | } | ||
830 | } | ||
831 | } | ||
832 | |||
803 | public void TriggerObjectBeingRemovedFromScene(SceneObjectGroup obj) | 833 | public void TriggerObjectBeingRemovedFromScene(SceneObjectGroup obj) |
804 | { | 834 | { |
805 | ObjectBeingRemovedFromScene handlerObjectBeingRemovedFromScene = OnObjectBeingRemovedFromScene; | 835 | ObjectBeingRemovedFromScene handlerObjectBeingRemovedFromScene = OnObjectBeingRemovedFromScene; |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 4d2519d..d407a6f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -1956,8 +1956,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1956 | /// If false, it is left to the caller to schedule the update | 1956 | /// If false, it is left to the caller to schedule the update |
1957 | /// </param> | 1957 | /// </param> |
1958 | public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) | 1958 | public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) |
1959 | { | 1959 | { |
1960 | return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates); | 1960 | if (m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates)) |
1961 | { | ||
1962 | EventManager.TriggerObjectAddedToScene(sceneObject); | ||
1963 | return true; | ||
1964 | } | ||
1965 | |||
1966 | return false; | ||
1961 | } | 1967 | } |
1962 | 1968 | ||
1963 | /// <summary> | 1969 | /// <summary> |
@@ -1974,7 +1980,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1974 | public bool AddNewSceneObject( | 1980 | public bool AddNewSceneObject( |
1975 | SceneObjectGroup sceneObject, bool attachToBackup, Vector3 pos, Quaternion rot, Vector3 vel) | 1981 | SceneObjectGroup sceneObject, bool attachToBackup, Vector3 pos, Quaternion rot, Vector3 vel) |
1976 | { | 1982 | { |
1977 | return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, pos, rot, vel); | 1983 | if (m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, pos, rot, vel)) |
1984 | { | ||
1985 | EventManager.TriggerObjectAddedToScene(sceneObject); | ||
1986 | return true; | ||
1987 | } | ||
1988 | |||
1989 | return false; | ||
1978 | } | 1990 | } |
1979 | 1991 | ||
1980 | /// <summary> | 1992 | /// <summary> |