Merge branch 'master' into careminster

Conflicts:
	OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
avinationmerge
Melanie 2012-03-06 01:18:37 +00:00
commit af46650bae
2 changed files with 57 additions and 12 deletions

View File

@ -88,25 +88,26 @@ namespace OpenSim.Region.OptionalModules.World.NPC
public bool SetNPCAppearance(UUID agentId, AvatarAppearance appearance, Scene scene) public bool SetNPCAppearance(UUID agentId, AvatarAppearance appearance, Scene scene)
{ {
ScenePresence sp = scene.GetScenePresence(agentId); ScenePresence npc = scene.GetScenePresence(agentId);
if (sp == null || sp.IsChildAgent) if (npc == null || npc.IsChildAgent)
return false; return false;
lock (m_avatars) lock (m_avatars)
if (!m_avatars.ContainsKey(agentId)) if (!m_avatars.ContainsKey(agentId))
return false; return false;
// Delete existing sp attachments // Delete existing npc attachments
scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, false); scene.AttachmentsModule.DeleteAttachmentsFromScene(npc, false);
AvatarAppearance app = new AvatarAppearance(appearance, true); // XXX: We can't just use IAvatarFactoryModule.SetAppearance() yet since it doesn't transfer attachments
sp.Appearance = app; AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true);
npc.Appearance = npcAppearance;
// Set new sp appearance. Also sends to clients.
scene.RequestModuleInterface<IAvatarFactoryModule>().SetAppearance(sp, app);
// Rez needed sp attachments // Rez needed npc attachments
scene.AttachmentsModule.RezAttachments(sp); scene.AttachmentsModule.RezAttachments(npc);
IAvatarFactoryModule module = scene.RequestModuleInterface<IAvatarFactoryModule>();
module.SendAppearance(npc.UUID);
return true; return true;
} }

View File

@ -139,7 +139,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
} }
[Test] [Test]
public void TestAttachments() public void TestCreateWithAttachments()
{ {
TestHelpers.InMethod(); TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure(); // log4net.Config.XmlConfigurator.Configure();
@ -178,6 +178,50 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
Assert.That(attSo.OwnerID, Is.EqualTo(npc.UUID)); Assert.That(attSo.OwnerID, Is.EqualTo(npc.UUID));
} }
[Test]
public void TestLoadAppearance()
{
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
UUID userId = TestHelpers.ParseTail(0x1);
UserAccountHelpers.CreateUserWithInventory(scene, userId);
ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId);
INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, scene, sp.Appearance);
// Now add the attachment to the original avatar and use that to load a new appearance
// TODO: Could also run tests loading from a notecard though this isn't much different for our purposes here
UUID attItemId = TestHelpers.ParseTail(0x2);
UUID attAssetId = TestHelpers.ParseTail(0x3);
string attName = "att";
UserInventoryHelpers.CreateInventoryItem(scene, attName, attItemId, attAssetId, sp.UUID, InventoryType.Object);
am.RezSingleAttachmentFromInventory(sp, attItemId, (uint)AttachmentPoint.Chest);
npcModule.SetNPCAppearance(npcId, sp.Appearance, scene);
ScenePresence npc = scene.GetScenePresence(npcId);
// Check scene presence status
Assert.That(npc.HasAttachments(), Is.True);
List<SceneObjectGroup> attachments = npc.GetAttachments();
Assert.That(attachments.Count, Is.EqualTo(1));
SceneObjectGroup attSo = attachments[0];
// Just for now, we won't test the name since this is (wrongly) the asset part name rather than the item
// name. TODO: Do need to fix ultimately since the item may be renamed before being passed on to an NPC.
// Assert.That(attSo.Name, Is.EqualTo(attName));
Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
Assert.That(attSo.IsAttachment);
Assert.That(attSo.UsesPhysics, Is.False);
Assert.That(attSo.IsTemporary, Is.False);
Assert.That(attSo.OwnerID, Is.EqualTo(npc.UUID));
}
[Test] [Test]
public void TestMove() public void TestMove()
{ {