Add ILandObject.IPrimCounts for the new prim count module.

Not functional yet, but tests now act against this object rather than interrogating the module directly
0.7.1-dev
Justin Clark-Casey (justincc) 2011-03-25 21:47:54 +00:00
parent eaa37d15f2
commit 7f5019b0f2
5 changed files with 52 additions and 31 deletions

View File

@ -72,6 +72,7 @@ namespace OpenSim.Region.CoreModules.World.Land
protected Commander m_commander = new Commander("land");
protected IUserManagement m_userManager;
protected IPrimCountModule m_primCountModule;
// Minimum for parcels to work is 64m even if we don't actually use them.
#pragma warning disable 0429
@ -147,6 +148,7 @@ namespace OpenSim.Region.CoreModules.World.Land
public void RegionLoaded(Scene scene)
{
m_userManager = m_scene.RequestModuleInterface<IUserManagement>();
m_primCountModule = m_scene.RequestModuleInterface<IPrimCountModule>();
}
public void RemoveRegion(Scene scene)
@ -313,6 +315,7 @@ namespace OpenSim.Region.CoreModules.World.Land
fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize));
fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch();
return AddLandObject(fullSimParcel);
}
@ -594,6 +597,11 @@ namespace OpenSim.Region.CoreModules.World.Land
{
ILandObject new_land = land.Copy();
// Only now can we add the prim counts to the land object - we rely on the global ID which is generated
// as a random UUID inside LandData initialization
if (m_primCountModule != null)
new_land.PrimCounts = m_primCountModule.GetPrimCounts(new_land.LandData.GlobalID);
lock (m_landList)
{
int newLandLocalID = ++m_lastLandLocalID;

View File

@ -80,6 +80,8 @@ namespace OpenSim.Region.CoreModules.World.Land
set { m_landData = value; }
}
public IPrimCounts PrimCounts { get; set; }
public UUID RegionUUID
{
get { return m_scene.RegionInfo.RegionID; }

View File

@ -89,6 +89,8 @@ namespace OpenSim.Region.CoreModules.World.Land
{
m_Scene = scene;
m_Scene.RegisterModuleInterface<IPrimCountModule>(this);
m_Scene.EventManager.OnObjectAddedToScene += OnParcelPrimCountAdd;
m_Scene.EventManager.OnObjectBeingRemovedFromScene +=
OnObjectBeingRemovedFromScene;

View File

@ -58,9 +58,9 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
m_scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(m_scene, lmm, m_pcm);
m_lo = new LandObject(m_userId, false, m_scene);
m_lo.SetLandBitmap(m_lo.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize));
lmm.AddLandObject(m_lo);
ILandObject lo = new LandObject(m_userId, false, m_scene);
lo.SetLandBitmap(lo.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize));
m_lo = lmm.AddLandObject(lo);
//scene.loadAllLandObjectsFromStorage(scene.RegionInfo.originRegionID);
}
@ -73,33 +73,35 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
TestHelper.InMethod();
// log4net.Config.XmlConfigurator.Configure();
Assert.That(m_pcm.GetOwnerCount(m_lo.LandData.GlobalID), Is.EqualTo(0));
Assert.That(m_pcm.GetGroupCount(m_lo.LandData.GlobalID), Is.EqualTo(0));
Assert.That(m_pcm.GetOthersCount(m_lo.LandData.GlobalID), Is.EqualTo(0));
Assert.That(m_pcm.GetUserCount(m_lo.LandData.GlobalID, m_userId), Is.EqualTo(0));
Assert.That(m_pcm.GetUserCount(m_lo.LandData.GlobalID, m_dummyUserId), Is.EqualTo(0));
Assert.That(m_pcm.GetSimulatorCount(m_lo.LandData.GlobalID), Is.EqualTo(0));
IPrimCounts pc = m_lo.PrimCounts;
Assert.That(pc.Owner, Is.EqualTo(0));
Assert.That(pc.Group, Is.EqualTo(0));
Assert.That(pc.Others, Is.EqualTo(0));
Assert.That(pc.Users[m_userId], Is.EqualTo(0));
Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0));
Assert.That(pc.Simulator, Is.EqualTo(0));
SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x01);
m_scene.AddNewSceneObject(sog, false);
Assert.That(m_pcm.GetOwnerCount(m_lo.LandData.GlobalID), Is.EqualTo(3));
Assert.That(m_pcm.GetGroupCount(m_lo.LandData.GlobalID), Is.EqualTo(0));
Assert.That(m_pcm.GetOthersCount(m_lo.LandData.GlobalID), Is.EqualTo(0));
Assert.That(m_pcm.GetUserCount(m_lo.LandData.GlobalID, m_userId), Is.EqualTo(3));
Assert.That(m_pcm.GetUserCount(m_lo.LandData.GlobalID, m_dummyUserId), Is.EqualTo(0));
Assert.That(m_pcm.GetSimulatorCount(m_lo.LandData.GlobalID), Is.EqualTo(3));
Assert.That(pc.Owner, Is.EqualTo(3));
Assert.That(pc.Group, Is.EqualTo(0));
Assert.That(pc.Others, Is.EqualTo(0));
Assert.That(pc.Users[m_userId], Is.EqualTo(3));
Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0));
Assert.That(pc.Simulator, Is.EqualTo(3));
// Add a second object and retest
SceneObjectGroup sog2 = SceneSetupHelpers.CreateSceneObject(2, m_userId, 0x10);
m_scene.AddNewSceneObject(sog2, false);
Assert.That(m_pcm.GetOwnerCount(m_lo.LandData.GlobalID), Is.EqualTo(5));
Assert.That(m_pcm.GetGroupCount(m_lo.LandData.GlobalID), Is.EqualTo(0));
Assert.That(m_pcm.GetOthersCount(m_lo.LandData.GlobalID), Is.EqualTo(0));
Assert.That(m_pcm.GetUserCount(m_lo.LandData.GlobalID, m_userId), Is.EqualTo(5));
Assert.That(m_pcm.GetUserCount(m_lo.LandData.GlobalID, m_dummyUserId), Is.EqualTo(0));
Assert.That(m_pcm.GetSimulatorCount(m_lo.LandData.GlobalID), Is.EqualTo(5));
Assert.That(pc.Owner, Is.EqualTo(5));
Assert.That(pc.Group, Is.EqualTo(0));
Assert.That(pc.Others, Is.EqualTo(0));
Assert.That(pc.Users[m_userId], Is.EqualTo(5));
Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0));
Assert.That(pc.Simulator, Is.EqualTo(5));
}
/// <summary>
@ -111,17 +113,19 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
TestHelper.InMethod();
// log4net.Config.XmlConfigurator.Configure();
IPrimCounts pc = m_lo.PrimCounts;
m_scene.AddNewSceneObject(SceneSetupHelpers.CreateSceneObject(1, m_userId, 0x1), false);
SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x10);
m_scene.AddNewSceneObject(sogToDelete, false);
m_scene.DeleteSceneObject(sogToDelete, false);
Assert.That(m_pcm.GetOwnerCount(m_lo.LandData.GlobalID), Is.EqualTo(1));
Assert.That(m_pcm.GetGroupCount(m_lo.LandData.GlobalID), Is.EqualTo(0));
Assert.That(m_pcm.GetOthersCount(m_lo.LandData.GlobalID), Is.EqualTo(0));
Assert.That(m_pcm.GetUserCount(m_lo.LandData.GlobalID, m_userId), Is.EqualTo(1));
Assert.That(m_pcm.GetUserCount(m_lo.LandData.GlobalID, m_dummyUserId), Is.EqualTo(0));
Assert.That(m_pcm.GetSimulatorCount(m_lo.LandData.GlobalID), Is.EqualTo(1));
Assert.That(pc.Owner, Is.EqualTo(1));
Assert.That(pc.Group, Is.EqualTo(0));
Assert.That(pc.Others, Is.EqualTo(0));
Assert.That(pc.Users[m_userId], Is.EqualTo(1));
Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0));
Assert.That(pc.Simulator, Is.EqualTo(1));
}
}
}

View File

@ -45,6 +45,11 @@ namespace OpenSim.Region.Framework.Interfaces
bool[,] LandBitmap { get; set; }
UUID RegionUUID { get; }
/// <summary>
/// Prim counts for this land object.
/// </summary>
IPrimCounts PrimCounts { get; set; }
/// <summary>
/// The start point for the land object. This is the western-most point as one scans land working from
/// north to south.