diff options
author | Melanie | 2011-03-27 21:22:31 +0100 |
---|---|---|
committer | Melanie | 2011-03-27 21:22:31 +0100 |
commit | f25749f0259bdfe334f77ab049ac5f892135bbc6 (patch) | |
tree | 5fd38027cbe794a1da1d87009f9975d3792f085a /OpenSim/Region/CoreModules | |
parent | Don't send a windlight profile to clients if windlight is not set for (diff) | |
parent | Add SignpostMarv to contributors (diff) | |
download | opensim-SC_OLD-f25749f0259bdfe334f77ab049ac5f892135bbc6.zip opensim-SC_OLD-f25749f0259bdfe334f77ab049ac5f892135bbc6.tar.gz opensim-SC_OLD-f25749f0259bdfe334f77ab049ac5f892135bbc6.tar.bz2 opensim-SC_OLD-f25749f0259bdfe334f77ab049ac5f892135bbc6.tar.xz |
Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim
Diffstat (limited to '')
4 files changed, 217 insertions, 24 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 98ba8c3..d0727d9 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | |||
@@ -72,6 +72,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
72 | protected Commander m_commander = new Commander("land"); | 72 | protected Commander m_commander = new Commander("land"); |
73 | 73 | ||
74 | protected IUserManagement m_userManager; | 74 | protected IUserManagement m_userManager; |
75 | protected IPrimCountModule m_primCountModule; | ||
75 | 76 | ||
76 | // Minimum for parcels to work is 64m even if we don't actually use them. | 77 | // Minimum for parcels to work is 64m even if we don't actually use them. |
77 | #pragma warning disable 0429 | 78 | #pragma warning disable 0429 |
@@ -147,6 +148,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
147 | public void RegionLoaded(Scene scene) | 148 | public void RegionLoaded(Scene scene) |
148 | { | 149 | { |
149 | m_userManager = m_scene.RequestModuleInterface<IUserManagement>(); | 150 | m_userManager = m_scene.RequestModuleInterface<IUserManagement>(); |
151 | m_primCountModule = m_scene.RequestModuleInterface<IPrimCountModule>(); | ||
150 | } | 152 | } |
151 | 153 | ||
152 | public void RemoveRegion(Scene scene) | 154 | public void RemoveRegion(Scene scene) |
@@ -306,10 +308,14 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
306 | /// <returns>The parcel created.</returns> | 308 | /// <returns>The parcel created.</returns> |
307 | protected ILandObject CreateDefaultParcel() | 309 | protected ILandObject CreateDefaultParcel() |
308 | { | 310 | { |
309 | ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); | 311 | // m_log.DebugFormat( |
312 | // "[LAND MANAGEMENT MODULE]: Creating default parcel for region {0}", m_scene.RegionInfo.RegionName); | ||
313 | |||
314 | ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); | ||
310 | fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); | 315 | fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); |
311 | fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; | 316 | fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; |
312 | fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); | 317 | fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); |
318 | |||
313 | return AddLandObject(fullSimParcel); | 319 | return AddLandObject(fullSimParcel); |
314 | } | 320 | } |
315 | 321 | ||
@@ -579,7 +585,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
579 | } | 585 | } |
580 | else | 586 | else |
581 | { | 587 | { |
582 | m_log.WarnFormat("[LAND]: Invalid local land ID {0}", landLocalID); | 588 | m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Invalid local land ID {0}", landLocalID); |
583 | } | 589 | } |
584 | } | 590 | } |
585 | 591 | ||
@@ -590,6 +596,11 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
590 | public ILandObject AddLandObject(ILandObject land) | 596 | public ILandObject AddLandObject(ILandObject land) |
591 | { | 597 | { |
592 | ILandObject new_land = land.Copy(); | 598 | ILandObject new_land = land.Copy(); |
599 | |||
600 | // Only now can we add the prim counts to the land object - we rely on the global ID which is generated | ||
601 | // as a random UUID inside LandData initialization | ||
602 | if (m_primCountModule != null) | ||
603 | new_land.PrimCounts = m_primCountModule.GetPrimCounts(new_land.LandData.GlobalID); | ||
593 | 604 | ||
594 | lock (m_landList) | 605 | lock (m_landList) |
595 | { | 606 | { |
@@ -630,7 +641,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
630 | { | 641 | { |
631 | if (m_landIDList[x, y] == local_id) | 642 | if (m_landIDList[x, y] == local_id) |
632 | { | 643 | { |
633 | m_log.WarnFormat("[LAND]: Not removing land object {0}; still being used at {1}, {2}", | 644 | m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Not removing land object {0}; still being used at {1}, {2}", |
634 | local_id, x, y); | 645 | local_id, x, y); |
635 | return; | 646 | return; |
636 | //throw new Exception("Could not remove land object. Still being used at " + x + ", " + y); | 647 | //throw new Exception("Could not remove land object. Still being used at " + x + ", " + y); |
@@ -851,6 +862,10 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
851 | 862 | ||
852 | public void EventManagerOnParcelPrimCountUpdate() | 863 | public void EventManagerOnParcelPrimCountUpdate() |
853 | { | 864 | { |
865 | // m_log.DebugFormat( | ||
866 | // "[LAND MANAGEMENT MODULE]: Triggered EventManagerOnParcelPrimCountUpdate() for {0}", | ||
867 | // m_scene.RegionInfo.RegionName); | ||
868 | |||
854 | ResetAllLandPrimCounts(); | 869 | ResetAllLandPrimCounts(); |
855 | EntityBase[] entities = m_scene.Entities.GetEntities(); | 870 | EntityBase[] entities = m_scene.Entities.GetEntities(); |
856 | foreach (EntityBase obj in entities) | 871 | foreach (EntityBase obj in entities) |
@@ -1198,7 +1213,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1198 | } | 1213 | } |
1199 | else | 1214 | else |
1200 | { | 1215 | { |
1201 | m_log.WarnFormat("[PARCEL]: Invalid land object {0} passed for parcel object owner request", local_id); | 1216 | m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Invalid land object {0} passed for parcel object owner request", local_id); |
1202 | } | 1217 | } |
1203 | } | 1218 | } |
1204 | 1219 | ||
@@ -1361,7 +1376,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1361 | { | 1376 | { |
1362 | ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene); | 1377 | ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene); |
1363 | new_land.LandData = data.Copy(); | 1378 | new_land.LandData = data.Copy(); |
1364 | new_land.SetLandBitmapFromByteArray(); | 1379 | new_land.SetLandBitmapFromByteArray(); |
1365 | AddLandObject(new_land); | 1380 | AddLandObject(new_land); |
1366 | } | 1381 | } |
1367 | 1382 | ||
@@ -1426,7 +1441,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1426 | { | 1441 | { |
1427 | IClientAPI client; | 1442 | IClientAPI client; |
1428 | if (! m_scene.TryGetClient(agentID, out client)) { | 1443 | if (! m_scene.TryGetClient(agentID, out client)) { |
1429 | m_log.WarnFormat("[LAND] unable to retrieve IClientAPI for {0}", agentID.ToString()); | 1444 | m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Unable to retrieve IClientAPI for {0}", agentID); |
1430 | return LLSDHelpers.SerialiseLLSDReply(new LLSDEmpty()); | 1445 | return LLSDHelpers.SerialiseLLSDReply(new LLSDEmpty()); |
1431 | } | 1446 | } |
1432 | 1447 | ||
@@ -1475,7 +1490,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1475 | } | 1490 | } |
1476 | else | 1491 | else |
1477 | { | 1492 | { |
1478 | m_log.WarnFormat("[LAND] unable to find parcelID {0}", parcelID); | 1493 | m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Unable to find parcelID {0}", parcelID); |
1479 | } | 1494 | } |
1480 | return LLSDHelpers.SerialiseLLSDReply(new LLSDEmpty()); | 1495 | return LLSDHelpers.SerialiseLLSDReply(new LLSDEmpty()); |
1481 | } | 1496 | } |
@@ -1533,17 +1548,17 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1533 | } | 1548 | } |
1534 | catch (LLSD.LLSDParseException e) | 1549 | catch (LLSD.LLSDParseException e) |
1535 | { | 1550 | { |
1536 | m_log.ErrorFormat("[LAND] Fetch error: {0}", e.Message); | 1551 | m_log.ErrorFormat("[LAND MANAGEMENT MODULE]: Fetch error: {0}", e.Message); |
1537 | m_log.ErrorFormat("[LAND] ... in request {0}", request); | 1552 | m_log.ErrorFormat("[LAND MANAGEMENT MODULE]: ... in request {0}", request); |
1538 | } | 1553 | } |
1539 | catch(InvalidCastException) | 1554 | catch (InvalidCastException) |
1540 | { | 1555 | { |
1541 | m_log.ErrorFormat("[LAND] Wrong type in request {0}", request); | 1556 | m_log.ErrorFormat("[LAND MANAGEMENT MODULE]: Wrong type in request {0}", request); |
1542 | } | 1557 | } |
1543 | 1558 | ||
1544 | LLSDRemoteParcelResponse response = new LLSDRemoteParcelResponse(); | 1559 | LLSDRemoteParcelResponse response = new LLSDRemoteParcelResponse(); |
1545 | response.parcel_id = parcelID; | 1560 | response.parcel_id = parcelID; |
1546 | m_log.DebugFormat("[LAND] got parcelID {0}", parcelID); | 1561 | m_log.DebugFormat("[LAND MANAGEMENT MODULE]: Got parcelID {0}", parcelID); |
1547 | 1562 | ||
1548 | return LLSDHelpers.SerialiseLLSDReply(response); | 1563 | return LLSDHelpers.SerialiseLLSDReply(response); |
1549 | } | 1564 | } |
@@ -1564,7 +1579,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1564 | ExtendedLandData extLandData = new ExtendedLandData(); | 1579 | ExtendedLandData extLandData = new ExtendedLandData(); |
1565 | Util.ParseFakeParcelID(parcel, out extLandData.RegionHandle, | 1580 | Util.ParseFakeParcelID(parcel, out extLandData.RegionHandle, |
1566 | out extLandData.X, out extLandData.Y); | 1581 | out extLandData.X, out extLandData.Y); |
1567 | m_log.DebugFormat("[LAND] got parcelinfo request for regionHandle {0}, x/y {1}/{2}", | 1582 | m_log.DebugFormat("[LAND MANAGEMENT MODULE]: Got parcelinfo request for regionHandle {0}, x/y {1}/{2}", |
1568 | extLandData.RegionHandle, extLandData.X, extLandData.Y); | 1583 | extLandData.RegionHandle, extLandData.X, extLandData.Y); |
1569 | 1584 | ||
1570 | // for this region or for somewhere else? | 1585 | // for this region or for somewhere else? |
@@ -1605,7 +1620,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1605 | info = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y); | 1620 | info = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y); |
1606 | } | 1621 | } |
1607 | // we need to transfer the fake parcelID, not the one in landData, so the viewer can match it to the landmark. | 1622 | // we need to transfer the fake parcelID, not the one in landData, so the viewer can match it to the landmark. |
1608 | m_log.DebugFormat("[LAND] got parcelinfo for parcel {0} in region {1}; sending...", | 1623 | m_log.DebugFormat("[LAND MANAGEMENT MODULE]: got parcelinfo for parcel {0} in region {1}; sending...", |
1609 | data.LandData.Name, data.RegionHandle); | 1624 | data.LandData.Name, data.RegionHandle); |
1610 | // HACK for now | 1625 | // HACK for now |
1611 | RegionInfo r = new RegionInfo(); | 1626 | RegionInfo r = new RegionInfo(); |
@@ -1616,7 +1631,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1616 | remoteClient.SendParcelInfo(r, data.LandData, parcelID, data.X, data.Y); | 1631 | remoteClient.SendParcelInfo(r, data.LandData, parcelID, data.X, data.Y); |
1617 | } | 1632 | } |
1618 | else | 1633 | else |
1619 | m_log.Debug("[LAND] got no parcelinfo; not sending"); | 1634 | m_log.Debug("[LAND MANAGEMENT MODULE]: got no parcelinfo; not sending"); |
1620 | } | 1635 | } |
1621 | 1636 | ||
1622 | public void setParcelOtherCleanTime(IClientAPI remoteClient, int localID, int otherCleanTime) | 1637 | public void setParcelOtherCleanTime(IClientAPI remoteClient, int localID, int otherCleanTime) |
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 46c15ed..749bb3d 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs | |||
@@ -51,7 +51,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
51 | 51 | ||
52 | private int m_lastSeqId = 0; | 52 | private int m_lastSeqId = 0; |
53 | 53 | ||
54 | protected LandData m_landData = new LandData(); | 54 | protected LandData m_landData = new LandData(); |
55 | protected Scene m_scene; | 55 | protected Scene m_scene; |
56 | protected List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>(); | 56 | protected List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>(); |
57 | protected Dictionary<uint, UUID> m_listTransactions = new Dictionary<uint, UUID>(); | 57 | protected Dictionary<uint, UUID> m_listTransactions = new Dictionary<uint, UUID>(); |
@@ -79,6 +79,8 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
79 | 79 | ||
80 | set { m_landData = value; } | 80 | set { m_landData = value; } |
81 | } | 81 | } |
82 | |||
83 | public IPrimCounts PrimCounts { get; set; } | ||
82 | 84 | ||
83 | public UUID RegionUUID | 85 | public UUID RegionUUID |
84 | { | 86 | { |
diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index 34ef67f..9fd347e 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 | ||
diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs new file mode 100644 index 0000000..c9d393f --- /dev/null +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs | |||
@@ -0,0 +1,131 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using log4net.Config; | ||
32 | using NUnit.Framework; | ||
33 | using OpenMetaverse; | ||
34 | using OpenMetaverse.Assets; | ||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Region.Framework.Interfaces; | ||
37 | using OpenSim.Region.Framework.Scenes; | ||
38 | using OpenSim.Tests.Common; | ||
39 | using OpenSim.Tests.Common.Mock; | ||
40 | using OpenSim.Tests.Common.Setup; | ||
41 | |||
42 | namespace OpenSim.Region.CoreModules.World.Land.Tests | ||
43 | { | ||
44 | [TestFixture] | ||
45 | public class PrimCountModuleTests | ||
46 | { | ||
47 | protected UUID m_userId = new UUID("00000000-0000-0000-0000-100000000000"); | ||
48 | protected UUID m_dummyUserId = new UUID("99999999-9999-9999-9999-999999999999"); | ||
49 | protected TestScene m_scene; | ||
50 | protected PrimCountModule m_pcm; | ||
51 | protected ILandObject m_lo; | ||
52 | |||
53 | [SetUp] | ||
54 | public void SetUp() | ||
55 | { | ||
56 | m_pcm = new PrimCountModule(); | ||
57 | LandManagementModule lmm = new LandManagementModule(); | ||
58 | m_scene = SceneSetupHelpers.SetupScene(); | ||
59 | SceneSetupHelpers.SetupSceneModules(m_scene, lmm, m_pcm); | ||
60 | |||
61 | ILandObject lo = new LandObject(m_userId, false, m_scene); | ||
62 | lo.SetLandBitmap(lo.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); | ||
63 | m_lo = lmm.AddLandObject(lo); | ||
64 | //scene.loadAllLandObjectsFromStorage(scene.RegionInfo.originRegionID); | ||
65 | } | ||
66 | |||
67 | /// <summary> | ||
68 | /// Test count after a parcel owner owned object is added. | ||
69 | /// </summary> | ||
70 | [Test] | ||
71 | public void TestAddOwnerObject() | ||
72 | { | ||
73 | TestHelper.InMethod(); | ||
74 | // log4net.Config.XmlConfigurator.Configure(); | ||
75 | |||
76 | IPrimCounts pc = m_lo.PrimCounts; | ||
77 | |||
78 | Assert.That(pc.Owner, Is.EqualTo(0)); | ||
79 | Assert.That(pc.Group, Is.EqualTo(0)); | ||
80 | Assert.That(pc.Others, Is.EqualTo(0)); | ||
81 | Assert.That(pc.Users[m_userId], Is.EqualTo(0)); | ||
82 | Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0)); | ||
83 | Assert.That(pc.Simulator, Is.EqualTo(0)); | ||
84 | |||
85 | SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x01); | ||
86 | m_scene.AddNewSceneObject(sog, false); | ||
87 | |||
88 | Assert.That(pc.Owner, Is.EqualTo(3)); | ||
89 | Assert.That(pc.Group, Is.EqualTo(0)); | ||
90 | Assert.That(pc.Others, Is.EqualTo(0)); | ||
91 | Assert.That(pc.Users[m_userId], Is.EqualTo(3)); | ||
92 | Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0)); | ||
93 | Assert.That(pc.Simulator, Is.EqualTo(3)); | ||
94 | |||
95 | // Add a second object and retest | ||
96 | SceneObjectGroup sog2 = SceneSetupHelpers.CreateSceneObject(2, m_userId, 0x10); | ||
97 | m_scene.AddNewSceneObject(sog2, false); | ||
98 | |||
99 | Assert.That(pc.Owner, Is.EqualTo(5)); | ||
100 | Assert.That(pc.Group, Is.EqualTo(0)); | ||
101 | Assert.That(pc.Others, Is.EqualTo(0)); | ||
102 | Assert.That(pc.Users[m_userId], Is.EqualTo(5)); | ||
103 | Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0)); | ||
104 | Assert.That(pc.Simulator, Is.EqualTo(5)); | ||
105 | } | ||
106 | |||
107 | /// <summary> | ||
108 | /// Test count after a parcel owner owned object is removed. | ||
109 | /// </summary> | ||
110 | [Test] | ||
111 | public void TestRemoveOwnerObject() | ||
112 | { | ||
113 | TestHelper.InMethod(); | ||
114 | // log4net.Config.XmlConfigurator.Configure(); | ||
115 | |||
116 | IPrimCounts pc = m_lo.PrimCounts; | ||
117 | |||
118 | m_scene.AddNewSceneObject(SceneSetupHelpers.CreateSceneObject(1, m_userId, 0x1), false); | ||
119 | SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x10); | ||
120 | m_scene.AddNewSceneObject(sogToDelete, false); | ||
121 | m_scene.DeleteSceneObject(sogToDelete, false); | ||
122 | |||
123 | Assert.That(pc.Owner, Is.EqualTo(1)); | ||
124 | Assert.That(pc.Group, Is.EqualTo(0)); | ||
125 | Assert.That(pc.Others, Is.EqualTo(0)); | ||
126 | Assert.That(pc.Users[m_userId], Is.EqualTo(1)); | ||
127 | Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0)); | ||
128 | Assert.That(pc.Simulator, Is.EqualTo(1)); | ||
129 | } | ||
130 | } | ||
131 | } \ No newline at end of file | ||