Merge branch 'master' into careminster

This commit is contained in:
Melanie
2012-01-12 23:22:55 +00:00
11 changed files with 311 additions and 82 deletions

View File

@@ -56,6 +56,24 @@ namespace OpenSim.Region.OptionalModules.World.NPC
}
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "NPCModule"; }
}
public bool IsSharedModule
{
get { return true; }
}
public bool IsNPC(UUID agentId, Scene scene)
{
// FIXME: This implementation could not just use the ScenePresence.PresenceType (and callers could inspect
@@ -248,16 +266,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC
return UUID.Zero;
}
public bool DeleteNPC(UUID agentID, UUID callerID, Scene scene)
public bool DeleteNPC(UUID agentID, Scene scene)
{
lock (m_avatars)
{
NPCAvatar av;
if (m_avatars.TryGetValue(agentID, out av))
{
if (av.OwnerID != UUID.Zero && callerID != UUID.Zero && av.OwnerID != callerID)
return false;
scene.RemoveClient(agentID, false);
m_avatars.Remove(agentID);
@@ -268,22 +283,27 @@ namespace OpenSim.Region.OptionalModules.World.NPC
return false;
}
public void PostInitialise()
public bool CheckPermissions(UUID npcID, UUID callerID)
{
lock (m_avatars)
{
NPCAvatar av;
if (m_avatars.TryGetValue(npcID, out av))
return CheckPermissions(av, callerID);
else
return false;
}
}
public void Close()
/// <summary>
/// Check if the caller has permission to manipulate the given NPC.
/// </summary>
/// <param name="av"></param>
/// <param name="callerID"></param>
/// <returns>true if they do, false if they don't.</returns>
private bool CheckPermissions(NPCAvatar av, UUID callerID)
{
}
public string Name
{
get { return "NPCModule"; }
}
public bool IsSharedModule
{
get { return true; }
return callerID == UUID.Zero || av.OwnerID == UUID.Zero || av.OwnerID == callerID;
}
}
}

View File

@@ -118,6 +118,26 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
Assert.That(umm.GetUserName(npc.UUID), Is.EqualTo(string.Format("{0} {1}", npc.Firstname, npc.Lastname)));
}
[Test]
public void TestRemove()
{
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
Vector3 startPos = new Vector3(128, 128, 30);
INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, scene, sp.Appearance);
npcModule.DeleteNPC(npcId, scene);
ScenePresence deletedNpc = scene.GetScenePresence(npcId);
Assert.That(deletedNpc, Is.Null);
}
[Test]
public void TestAttachments()
{