diff options
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs | 61 |
1 files changed, 53 insertions, 8 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index 2d1979f..62fd2b0 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs | |||
@@ -51,8 +51,8 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
51 | 51 | ||
52 | public class PrimCountModule : IPrimCountModule, INonSharedRegionModule | 52 | public class PrimCountModule : IPrimCountModule, INonSharedRegionModule |
53 | { | 53 | { |
54 | private static readonly ILog m_log = | 54 | // private static readonly ILog m_log = |
55 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 55 | // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
56 | 56 | ||
57 | private Scene m_Scene; | 57 | private Scene m_Scene; |
58 | private Dictionary<UUID, PrimCounts> m_PrimCounts = | 58 | private Dictionary<UUID, PrimCounts> m_PrimCounts = |
@@ -64,10 +64,16 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
64 | private Dictionary<UUID, ParcelCounts> m_ParcelCounts = | 64 | private Dictionary<UUID, ParcelCounts> m_ParcelCounts = |
65 | new Dictionary<UUID, ParcelCounts>(); | 65 | new Dictionary<UUID, ParcelCounts>(); |
66 | 66 | ||
67 | // For now, a simple simwide taint to get this up. Later parcel based | 67 | |
68 | // taint to allow recounting a parcel if only ownership has changed | 68 | /// <value> |
69 | // without recounting the whole sim. | 69 | /// For now, a simple simwide taint to get this up. Later parcel based |
70 | /// taint to allow recounting a parcel if only ownership has changed | ||
71 | /// without recounting the whole sim. | ||
72 | /// | ||
73 | /// We start out tainted so that the first get call resets the various prim counts. | ||
74 | /// <value> | ||
70 | private bool m_Tainted = true; | 75 | private bool m_Tainted = true; |
76 | |||
71 | private Object m_TaintLock = new Object(); | 77 | private Object m_TaintLock = new Object(); |
72 | 78 | ||
73 | public Type ReplaceableInterface | 79 | public Type ReplaceableInterface |
@@ -82,9 +88,10 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
82 | public void AddRegion(Scene scene) | 88 | public void AddRegion(Scene scene) |
83 | { | 89 | { |
84 | m_Scene = scene; | 90 | m_Scene = scene; |
91 | |||
92 | m_Scene.RegisterModuleInterface<IPrimCountModule>(this); | ||
85 | 93 | ||
86 | m_Scene.EventManager.OnParcelPrimCountAdd += | 94 | m_Scene.EventManager.OnObjectAddedToScene += OnParcelPrimCountAdd; |
87 | OnParcelPrimCountAdd; | ||
88 | m_Scene.EventManager.OnObjectBeingRemovedFromScene += | 95 | m_Scene.EventManager.OnObjectBeingRemovedFromScene += |
89 | OnObjectBeingRemovedFromScene; | 96 | OnObjectBeingRemovedFromScene; |
90 | m_Scene.EventManager.OnParcelPrimCountTainted += | 97 | m_Scene.EventManager.OnParcelPrimCountTainted += |
@@ -156,6 +163,8 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
156 | // NOTE: Call under Taint Lock | 163 | // NOTE: Call under Taint Lock |
157 | private void AddObject(SceneObjectGroup obj) | 164 | private void AddObject(SceneObjectGroup obj) |
158 | { | 165 | { |
166 | // m_log.DebugFormat("[PRIM COUNT MODULE]: Adding object {0} to prim count", obj.Name); | ||
167 | |||
159 | if (obj.IsAttachment) | 168 | if (obj.IsAttachment) |
160 | return; | 169 | return; |
161 | if (((obj.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0)) | 170 | if (((obj.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0)) |
@@ -164,6 +173,10 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
164 | Vector3 pos = obj.AbsolutePosition; | 173 | Vector3 pos = obj.AbsolutePosition; |
165 | ILandObject landObject = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y); | 174 | ILandObject landObject = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y); |
166 | LandData landData = landObject.LandData; | 175 | LandData landData = landObject.LandData; |
176 | |||
177 | // m_log.DebugFormat( | ||
178 | // "[PRIM COUNT MODULE]: Object {0} is owned by {1} over land owned by {2}", | ||
179 | // obj.Name, obj.OwnerID, landData.OwnerID); | ||
167 | 180 | ||
168 | ParcelCounts parcelCounts; | 181 | ParcelCounts parcelCounts; |
169 | if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts)) | 182 | if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts)) |
@@ -218,8 +231,16 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
218 | return primCounts; | 231 | return primCounts; |
219 | } | 232 | } |
220 | 233 | ||
234 | |||
235 | /// <summary> | ||
236 | /// Get the number of prims on the parcel that are owned by the parcel owner. | ||
237 | /// </summary> | ||
238 | /// <param name="parcelID"></param> | ||
239 | /// <returns></returns> | ||
221 | public int GetOwnerCount(UUID parcelID) | 240 | public int GetOwnerCount(UUID parcelID) |
222 | { | 241 | { |
242 | // m_log.DebugFormat("[PRIM COUNT MODULE]: GetOwnerCount for {0}", parcelID); | ||
243 | |||
223 | lock (m_TaintLock) | 244 | lock (m_TaintLock) |
224 | { | 245 | { |
225 | if (m_Tainted) | 246 | if (m_Tainted) |
@@ -232,6 +253,11 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
232 | return 0; | 253 | return 0; |
233 | } | 254 | } |
234 | 255 | ||
256 | /// <summary> | ||
257 | /// Get the number of prims on the parcel that have been set to the group that owns the parcel. | ||
258 | /// </summary> | ||
259 | /// <param name="parcelID"></param> | ||
260 | /// <returns></returns> | ||
235 | public int GetGroupCount(UUID parcelID) | 261 | public int GetGroupCount(UUID parcelID) |
236 | { | 262 | { |
237 | lock (m_TaintLock) | 263 | lock (m_TaintLock) |
@@ -246,6 +272,11 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
246 | return 0; | 272 | return 0; |
247 | } | 273 | } |
248 | 274 | ||
275 | /// <summary> | ||
276 | /// Get the number of prims on the parcel that are not owned by the parcel owner or set to the parcel group. | ||
277 | /// </summary> | ||
278 | /// <param name="parcelID"></param> | ||
279 | /// <returns></returns> | ||
249 | public int GetOthersCount(UUID parcelID) | 280 | public int GetOthersCount(UUID parcelID) |
250 | { | 281 | { |
251 | lock (m_TaintLock) | 282 | lock (m_TaintLock) |
@@ -260,6 +291,11 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
260 | return 0; | 291 | return 0; |
261 | } | 292 | } |
262 | 293 | ||
294 | /// <summary> | ||
295 | /// Get the number of prims that are in the entire simulator for the owner of this parcel. | ||
296 | /// </summary> | ||
297 | /// <param name="parcelID"></param> | ||
298 | /// <returns></returns> | ||
263 | public int GetSimulatorCount(UUID parcelID) | 299 | public int GetSimulatorCount(UUID parcelID) |
264 | { | 300 | { |
265 | lock (m_TaintLock) | 301 | lock (m_TaintLock) |
@@ -278,6 +314,12 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
278 | return 0; | 314 | return 0; |
279 | } | 315 | } |
280 | 316 | ||
317 | /// <summary> | ||
318 | /// Get the number of prims that a particular user owns on this parcel. | ||
319 | /// </summary> | ||
320 | /// <param name="parcelID"></param> | ||
321 | /// <param name="userID"></param> | ||
322 | /// <returns></returns> | ||
281 | public int GetUserCount(UUID parcelID, UUID userID) | 323 | public int GetUserCount(UUID parcelID, UUID userID) |
282 | { | 324 | { |
283 | lock (m_TaintLock) | 325 | lock (m_TaintLock) |
@@ -299,18 +341,21 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
299 | // NOTE: This method MUST be called while holding the taint lock! | 341 | // NOTE: This method MUST be called while holding the taint lock! |
300 | private void Recount() | 342 | private void Recount() |
301 | { | 343 | { |
344 | // m_log.DebugFormat("[PRIM COUNT MODULE]: Recounting prims on {0}", m_Scene.RegionInfo.RegionName); | ||
345 | |||
302 | m_OwnerMap.Clear(); | 346 | m_OwnerMap.Clear(); |
303 | m_SimwideCounts.Clear(); | 347 | m_SimwideCounts.Clear(); |
304 | m_ParcelCounts.Clear(); | 348 | m_ParcelCounts.Clear(); |
305 | 349 | ||
306 | List<ILandObject> land = m_Scene.LandChannel.AllParcels(); | 350 | List<ILandObject> land = m_Scene.LandChannel.AllParcels(); |
307 | 351 | ||
308 | foreach (ILandObject l in land) | 352 | foreach (ILandObject l in land) |
309 | { | 353 | { |
310 | LandData landData = l.LandData; | 354 | LandData landData = l.LandData; |
311 | 355 | ||
312 | m_OwnerMap[landData.GlobalID] = landData.OwnerID; | 356 | m_OwnerMap[landData.GlobalID] = landData.OwnerID; |
313 | m_SimwideCounts[landData.OwnerID] = 0; | 357 | m_SimwideCounts[landData.OwnerID] = 0; |
358 | // m_log.DebugFormat("[PRIM COUNT MODULE]: Adding parcel count for {0}", landData.GlobalID); | ||
314 | m_ParcelCounts[landData.GlobalID] = new ParcelCounts(); | 359 | m_ParcelCounts[landData.GlobalID] = new ParcelCounts(); |
315 | } | 360 | } |
316 | 361 | ||