aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs118
1 files changed, 104 insertions, 14 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
index 9fd347e..d126b26 100644
--- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
@@ -51,8 +51,7 @@ 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 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
56 55
57 private Scene m_Scene; 56 private Scene m_Scene;
58 private Dictionary<UUID, PrimCounts> m_PrimCounts = 57 private Dictionary<UUID, PrimCounts> m_PrimCounts =
@@ -123,6 +122,11 @@ namespace OpenSim.Region.CoreModules.World.Land
123 { 122 {
124 if (!m_Tainted) 123 if (!m_Tainted)
125 AddObject(obj); 124 AddObject(obj);
125// else
126// m_log.DebugFormat(
127// "[PRIM COUNT MODULE]: Ignoring OnParcelPrimCountAdd() for {0} on {1} since count is tainted",
128// obj.Name, m_Scene.RegionInfo.RegionName);
129
126 } 130 }
127 } 131 }
128 132
@@ -133,11 +137,18 @@ namespace OpenSim.Region.CoreModules.World.Land
133 { 137 {
134 if (!m_Tainted) 138 if (!m_Tainted)
135 RemoveObject(obj); 139 RemoveObject(obj);
140// else
141// m_log.DebugFormat(
142// "[PRIM COUNT MODULE]: Ignoring OnObjectBeingRemovedFromScene() for {0} on {1} since count is tainted",
143// obj.Name, m_Scene.RegionInfo.RegionName);
136 } 144 }
137 } 145 }
138 146
139 private void OnParcelPrimCountTainted() 147 private void OnParcelPrimCountTainted()
140 { 148 {
149// m_log.DebugFormat(
150// "[PRIM COUNT MODULE]: OnParcelPrimCountTainted() called on {0}", m_Scene.RegionInfo.RegionName);
151
141 lock (m_TaintLock) 152 lock (m_TaintLock)
142 m_Tainted = true; 153 m_Tainted = true;
143 } 154 }
@@ -163,7 +174,7 @@ namespace OpenSim.Region.CoreModules.World.Land
163 // NOTE: Call under Taint Lock 174 // NOTE: Call under Taint Lock
164 private void AddObject(SceneObjectGroup obj) 175 private void AddObject(SceneObjectGroup obj)
165 { 176 {
166// m_log.DebugFormat("[PRIM COUNT MODULE]: Adding object {0} to prim count", obj.Name); 177// m_log.DebugFormat("[PRIM COUNT MODULE]: Adding object {0} {1} to prim count", obj.Name, obj.UUID);
167 178
168 if (obj.IsAttachment) 179 if (obj.IsAttachment)
169 return; 180 return;
@@ -214,10 +225,16 @@ namespace OpenSim.Region.CoreModules.World.Land
214 // NOTE: Call under Taint Lock 225 // NOTE: Call under Taint Lock
215 private void RemoveObject(SceneObjectGroup obj) 226 private void RemoveObject(SceneObjectGroup obj)
216 { 227 {
228// m_log.DebugFormat("[PRIM COUNT MODULE]: Removing object {0} {1} from prim count", obj.Name, obj.UUID);
229
230 // Currently this is being done by tainting the count instead.
217 } 231 }
218 232
219 public IPrimCounts GetPrimCounts(UUID parcelID) 233 public IPrimCounts GetPrimCounts(UUID parcelID)
220 { 234 {
235// m_log.DebugFormat(
236// "[PRIM COUNT MODULE]: GetPrimCounts for parcel {0} in {1}", parcelID, m_Scene.RegionInfo.RegionName);
237
221 PrimCounts primCounts; 238 PrimCounts primCounts;
222 239
223 lock (m_PrimCounts) 240 lock (m_PrimCounts)
@@ -239,7 +256,7 @@ namespace OpenSim.Region.CoreModules.World.Land
239 /// <returns></returns> 256 /// <returns></returns>
240 public int GetOwnerCount(UUID parcelID) 257 public int GetOwnerCount(UUID parcelID)
241 { 258 {
242// m_log.DebugFormat("[PRIM COUNT MODULE]: GetOwnerCount for {0}", parcelID); 259 int count = 0;
243 260
244 lock (m_TaintLock) 261 lock (m_TaintLock)
245 { 262 {
@@ -248,9 +265,14 @@ namespace OpenSim.Region.CoreModules.World.Land
248 265
249 ParcelCounts counts; 266 ParcelCounts counts;
250 if (m_ParcelCounts.TryGetValue(parcelID, out counts)) 267 if (m_ParcelCounts.TryGetValue(parcelID, out counts))
251 return counts.Owner; 268 count = counts.Owner;
252 } 269 }
253 return 0; 270
271// m_log.DebugFormat(
272// "[PRIM COUNT MODULE]: GetOwnerCount for parcel {0} in {1} returning {2}",
273// parcelID, m_Scene.RegionInfo.RegionName, count);
274
275 return count;
254 } 276 }
255 277
256 /// <summary> 278 /// <summary>
@@ -260,6 +282,8 @@ namespace OpenSim.Region.CoreModules.World.Land
260 /// <returns></returns> 282 /// <returns></returns>
261 public int GetGroupCount(UUID parcelID) 283 public int GetGroupCount(UUID parcelID)
262 { 284 {
285 int count = 0;
286
263 lock (m_TaintLock) 287 lock (m_TaintLock)
264 { 288 {
265 if (m_Tainted) 289 if (m_Tainted)
@@ -267,9 +291,14 @@ namespace OpenSim.Region.CoreModules.World.Land
267 291
268 ParcelCounts counts; 292 ParcelCounts counts;
269 if (m_ParcelCounts.TryGetValue(parcelID, out counts)) 293 if (m_ParcelCounts.TryGetValue(parcelID, out counts))
270 return counts.Group; 294 count = counts.Group;
271 } 295 }
272 return 0; 296
297// m_log.DebugFormat(
298// "[PRIM COUNT MODULE]: GetGroupCount for parcel {0} in {1} returning {2}",
299// parcelID, m_Scene.RegionInfo.RegionName, count);
300
301 return count;
273 } 302 }
274 303
275 /// <summary> 304 /// <summary>
@@ -279,6 +308,35 @@ namespace OpenSim.Region.CoreModules.World.Land
279 /// <returns></returns> 308 /// <returns></returns>
280 public int GetOthersCount(UUID parcelID) 309 public int GetOthersCount(UUID parcelID)
281 { 310 {
311 int count = 0;
312
313 lock (m_TaintLock)
314 {
315 if (m_Tainted)
316 Recount();
317
318 ParcelCounts counts;
319 if (m_ParcelCounts.TryGetValue(parcelID, out counts))
320 count = counts.Others;
321 }
322
323// m_log.DebugFormat(
324// "[PRIM COUNT MODULE]: GetOthersCount for parcel {0} in {1} returning {2}",
325// parcelID, m_Scene.RegionInfo.RegionName, count);
326
327 return count;
328 }
329
330 /// <summary>
331 /// Get the total count of owner, group and others prims on the parcel.
332 /// FIXME: Need to do selected prims once this is reimplemented.
333 /// </summary>
334 /// <param name="parcelID"></param>
335 /// <returns></returns>
336 public int GetTotalCount(UUID parcelID)
337 {
338 int count = 0;
339
282 lock (m_TaintLock) 340 lock (m_TaintLock)
283 { 341 {
284 if (m_Tainted) 342 if (m_Tainted)
@@ -286,9 +344,18 @@ namespace OpenSim.Region.CoreModules.World.Land
286 344
287 ParcelCounts counts; 345 ParcelCounts counts;
288 if (m_ParcelCounts.TryGetValue(parcelID, out counts)) 346 if (m_ParcelCounts.TryGetValue(parcelID, out counts))
289 return counts.Others; 347 {
348 count = counts.Owner;
349 count += counts.Group;
350 count += counts.Others;
351 }
290 } 352 }
291 return 0; 353
354// m_log.DebugFormat(
355// "[PRIM COUNT MODULE]: GetTotalCount for parcel {0} in {1} returning {2}",
356// parcelID, m_Scene.RegionInfo.RegionName, count);
357
358 return count;
292 } 359 }
293 360
294 /// <summary> 361 /// <summary>
@@ -298,6 +365,8 @@ namespace OpenSim.Region.CoreModules.World.Land
298 /// <returns></returns> 365 /// <returns></returns>
299 public int GetSimulatorCount(UUID parcelID) 366 public int GetSimulatorCount(UUID parcelID)
300 { 367 {
368 int count = 0;
369
301 lock (m_TaintLock) 370 lock (m_TaintLock)
302 { 371 {
303 if (m_Tainted) 372 if (m_Tainted)
@@ -308,10 +377,15 @@ namespace OpenSim.Region.CoreModules.World.Land
308 { 377 {
309 int val; 378 int val;
310 if (m_SimwideCounts.TryGetValue(owner, out val)) 379 if (m_SimwideCounts.TryGetValue(owner, out val))
311 return val; 380 count = val;
312 } 381 }
313 } 382 }
314 return 0; 383
384// m_log.DebugFormat(
385// "[PRIM COUNT MODULE]: GetOthersCount for parcel {0} in {1} returning {2}",
386// parcelID, m_Scene.RegionInfo.RegionName, count);
387
388 return count;
315 } 389 }
316 390
317 /// <summary> 391 /// <summary>
@@ -322,6 +396,8 @@ namespace OpenSim.Region.CoreModules.World.Land
322 /// <returns></returns> 396 /// <returns></returns>
323 public int GetUserCount(UUID parcelID, UUID userID) 397 public int GetUserCount(UUID parcelID, UUID userID)
324 { 398 {
399 int count = 0;
400
325 lock (m_TaintLock) 401 lock (m_TaintLock)
326 { 402 {
327 if (m_Tainted) 403 if (m_Tainted)
@@ -332,10 +408,15 @@ namespace OpenSim.Region.CoreModules.World.Land
332 { 408 {
333 int val; 409 int val;
334 if (counts.Users.TryGetValue(userID, out val)) 410 if (counts.Users.TryGetValue(userID, out val))
335 return val; 411 count = val;
336 } 412 }
337 } 413 }
338 return 0; 414
415// m_log.DebugFormat(
416// "[PRIM COUNT MODULE]: GetUserCount for user {0} in parcel {1} in region {2} returning {3}",
417// userID, parcelID, m_Scene.RegionInfo.RegionName, count);
418
419 return count;
339 } 420 }
340 421
341 // NOTE: This method MUST be called while holding the taint lock! 422 // NOTE: This method MUST be called while holding the taint lock!
@@ -367,6 +448,7 @@ namespace OpenSim.Region.CoreModules.World.Land
367 if (!m_OwnerMap.ContainsKey(k)) 448 if (!m_OwnerMap.ContainsKey(k))
368 m_PrimCounts.Remove(k); 449 m_PrimCounts.Remove(k);
369 } 450 }
451
370 m_Tainted = false; 452 m_Tainted = false;
371 } 453 }
372 } 454 }
@@ -408,6 +490,14 @@ namespace OpenSim.Region.CoreModules.World.Land
408 return m_Parent.GetOthersCount(m_ParcelID); 490 return m_Parent.GetOthersCount(m_ParcelID);
409 } 491 }
410 } 492 }
493
494 public int Total
495 {
496 get
497 {
498 return m_Parent.GetTotalCount(m_ParcelID);
499 }
500 }
411 501
412 public int Simulator 502 public int Simulator
413 { 503 {