Fix issue where loading a new appearance onto an NPC would not remove the previous attachments from the scene.

Addresses http://opensimulator.org/mantis/view.php?id=5636
bulletsim
Justin Clark-Casey (justincc) 2011-08-17 01:35:33 +01:00
parent bd5d35ee32
commit acfdca34fd
3 changed files with 14 additions and 3 deletions

View File

@ -101,7 +101,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
/// <param name="silent"></param> /// <param name="silent"></param>
public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent) public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent)
{ {
m_log.Debug("[ATTACHMENTS MODULE]: Invoking AttachObject"); // m_log.Debug("[ATTACHMENTS MODULE]: Invoking AttachObject");
try try
{ {
@ -466,7 +466,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
{ {
m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero); m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero);
group.DetachToInventoryPrep(); group.DetachToInventoryPrep();
m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString()); // m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString());
// If an item contains scripts, it's always changed. // If an item contains scripts, it's always changed.
// This ensures script state is saved on detach // This ensures script state is saved on detach

View File

@ -96,9 +96,10 @@ namespace OpenSim.Region.Framework.Interfaces
/// <summary> /// <summary>
/// Detach an object from the avatar. /// Detach an object from the avatar.
/// </summary> /// </summary>
/// /// <remarks>
/// This method is called in response to a client's detach request, so we only update the information in /// This method is called in response to a client's detach request, so we only update the information in
/// inventory /// inventory
/// </remarks>
/// <param name="objectLocalID"></param> /// <param name="objectLocalID"></param>
/// <param name="remoteClient"></param> /// <param name="remoteClient"></param>
void DetachObject(uint objectLocalID, IClientAPI remoteClient); void DetachObject(uint objectLocalID, IClientAPI remoteClient);

View File

@ -143,6 +143,16 @@ namespace OpenSim.Region.OptionalModules.World.NPC
if (!m_avatars.ContainsKey(agentId)) if (!m_avatars.ContainsKey(agentId))
return false; return false;
// FIXME: An extremely bad bit of code that reaches directly into the attachments list and manipulates it
List<SceneObjectGroup> attachments = sp.Attachments;
lock (attachments)
{
foreach (SceneObjectGroup att in attachments)
scene.DeleteSceneObject(att, false);
attachments.Clear();
}
AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true);
sp.Appearance = npcAppearance; sp.Appearance = npcAppearance;
sp.RezAttachments(); sp.RezAttachments();