From e869eeb0bfc48c769f680970f99e4c67dd5a1a70 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 9 Aug 2011 03:51:34 +0100 Subject: Implement first draft functions for saving and loading NPC appearance from storage. This works by serializing and deserializing NPC AvatarAppearance to a notecard in the prim inventory and making the required baked textures permanent. By using notecards, we avoid lots of awkward, technical and user-unfriendly issues concerning retaining asset references and creating a new asset type. Notecards also allow different appearances to be swapped and manipulated easily. This also allows stored NPC appearances to work transparently with OARs/IARs since the UUID scan will pick up and store the necessary references from the notecard text. This works in my basic test but is not at all ready for user use or bug reporting yet. --- .../Region/OptionalModules/World/NPC/NPCModule.cs | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 4f21d9d..d966345 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -137,6 +137,35 @@ namespace OpenSim.Region.OptionalModules.World.NPC } } + public bool IsNPC(UUID agentId, Scene scene) + { + ScenePresence sp = scene.GetScenePresence(agentId); + if (sp == null || sp.IsChildAgent) + return false; + + lock (m_avatars) + return m_avatars.ContainsKey(agentId); + } + + public bool SetNPCAppearance(UUID agentId, AvatarAppearance appearance, Scene scene) + { + ScenePresence sp = scene.GetScenePresence(agentId); + if (sp == null || sp.IsChildAgent) + return false; + + lock (m_avatars) + if (!m_avatars.ContainsKey(agentId)) + return false; + + AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); + sp.Appearance = npcAppearance; + + IAvatarFactory module = scene.RequestModuleInterface(); + module.SendAppearance(sp.UUID); + + return true; + } + public UUID CreateNPC(string firstname, string lastname, Vector3 position, Scene scene, UUID cloneAppearanceFrom) { NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, scene); -- cgit v1.1 From 92e96d394a1712ed16b0a7835dd2ccfde01f3fee Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 9 Aug 2011 23:11:07 +0100 Subject: When an NPC is created, stop telling neighbouring regions to expect a child agent --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index d966345..88867f2 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -201,13 +201,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC m_log.DebugFormat( "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID); - // Shouldn't call this - temporary. - sp.CompleteMovement(npcAvatar); - -// sp.SendAppearanceToAllOtherAgents(); -// -// // Send animations back to the avatar as well -// sp.Animator.SendAnimPack(); + sp.CompleteMovement(npcAvatar, false); } else { -- cgit v1.1 From cba54090c759d1b21701179493f8399eb1b7a60f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 9 Aug 2011 23:25:52 +0100 Subject: When an NPC appearance is loaded, rez the attachments too --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 88867f2..068eec8 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -159,6 +159,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); sp.Appearance = npcAppearance; + sp.RezAttachments(); IAvatarFactory module = scene.RequestModuleInterface(); module.SendAppearance(sp.UUID); -- cgit v1.1 From 195c1dc9b8b8511980d9a607a242b24a5a91da17 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 10 Aug 2011 00:26:38 +0100 Subject: implement osNpcStopMoveTo() to cancel any current move target --- .../Region/OptionalModules/World/NPC/NPCModule.cs | 37 ++++++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 068eec8..87cb322 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -217,7 +217,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC return npcAvatar.AgentId; } - public void MoveToTarget(UUID agentID, Scene scene, Vector3 pos) + public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos) { lock (m_avatars) { @@ -230,22 +230,49 @@ namespace OpenSim.Region.OptionalModules.World.NPC "[NPC MODULE]: Moving {0} to {1} in {2}", sp.Name, pos, scene.RegionInfo.RegionName); sp.MoveToTarget(pos); + + return true; + } + } + + return false; + } + + public bool StopMoveToTarget(UUID agentID, Scene scene) + { + lock (m_avatars) + { + if (m_avatars.ContainsKey(agentID)) + { + ScenePresence sp; + scene.TryGetScenePresence(agentID, out sp); + + sp.Velocity = Vector3.Zero; + sp.ResetMoveToTarget(); + + return true; } } + + return false; } - public void Say(UUID agentID, Scene scene, string text) + public bool Say(UUID agentID, Scene scene, string text) { lock (m_avatars) { if (m_avatars.ContainsKey(agentID)) { m_avatars[agentID].Say(text); + + return true; } } + + return false; } - public void DeleteNPC(UUID agentID, Scene scene) + public bool DeleteNPC(UUID agentID, Scene scene) { lock (m_avatars) { @@ -253,8 +280,12 @@ namespace OpenSim.Region.OptionalModules.World.NPC { scene.RemoveClient(agentID); m_avatars.Remove(agentID); + + return true; } } + + return false; } public void PostInitialise() -- cgit v1.1 From 4cb8d6379ddb39cfb8b30a63475e154a00a78110 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 10 Aug 2011 00:59:31 +0100 Subject: Stop trying to deregister caps or close child agents when an NPC is removed --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 87cb322..7b9457a 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -278,7 +278,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC { if (m_avatars.ContainsKey(agentID)) { - scene.RemoveClient(agentID); + scene.RemoveClient(agentID, false); m_avatars.Remove(agentID); return true; -- cgit v1.1 From 5d6c9644faf6aeac38410af9cff97adfef88d7aa Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 10 Aug 2011 01:47:37 +0100 Subject: early code to allow scripts to force npcs not to fly when moving to target this is to allow walking on prims. it will be up to the script writer to be sure that there is a continuous path. currently implemented in osNpcMoveToTarget(), but none of this is final. --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 7b9457a..d0b5a94 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -217,7 +217,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC return npcAvatar.AgentId; } - public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos) + public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly) { lock (m_avatars) { @@ -229,7 +229,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC m_log.DebugFormat( "[NPC MODULE]: Moving {0} to {1} in {2}", sp.Name, pos, scene.RegionInfo.RegionName); - sp.MoveToTarget(pos); + sp.MoveToTarget(pos, noFly); return true; } -- cgit v1.1 From 7f499ff3f386d57bcd81ebb3f58f110011100604 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 10 Aug 2011 23:56:19 +0100 Subject: Add a OS_NPC_LAND_AT_TARGET option to osMoveToTarget() Default for this function is now not to automatically land. This allows better control by scripts when an avatar is going to be landing on a prim rather than the ground. Stopping the avatar involves faking a collision, to avoid the pid controller making it overshoot. A better approach would be to gradually slow the avatar as we near the target --- .../Region/OptionalModules/World/NPC/NPCModule.cs | 33 ++++++++++++++-------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index d0b5a94..f38af46 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -75,19 +75,25 @@ namespace OpenSim.Region.OptionalModules.World.NPC // We are close enough to the target m_log.DebugFormat("[NPC MODULE]: Stopping movement of npc {0}", presence.Name); + presence.Velocity = Vector3.Zero; + presence.AbsolutePosition = presence.MoveToPositionTarget; + presence.ResetMoveToTarget(); + if (presence.PhysicsActor.Flying) { - Vector3 targetPos = presence.MoveToPositionTarget; - float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y]; - if (targetPos.Z - terrainHeight < 0.2) - { + for (int i = 0; i < 5; i++) + presence.PhysicsActor.IsColliding = true; + +// Vector3 targetPos = presence.MoveToPositionTarget; + if (m_avatars[presence.UUID].LandAtTarget) presence.PhysicsActor.Flying = false; - } - } - presence.Velocity = Vector3.Zero; - presence.AbsolutePosition = presence.MoveToPositionTarget; - presence.ResetMoveToTarget(); +// float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y]; +// if (targetPos.Z - terrainHeight < 0.2) +// { +// presence.PhysicsActor.Flying = false; +// } + } // FIXME: This doesn't work if (presence.PhysicsActor.Flying) @@ -217,7 +223,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC return npcAvatar.AgentId; } - public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly) + public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget) { lock (m_avatars) { @@ -227,8 +233,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC scene.TryGetScenePresence(agentID, out sp); m_log.DebugFormat( - "[NPC MODULE]: Moving {0} to {1} in {2}", sp.Name, pos, scene.RegionInfo.RegionName); + "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", + sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget); + m_avatars[agentID].LandAtTarget = landAtTarget; sp.MoveToTarget(pos, noFly); return true; @@ -263,6 +271,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC { if (m_avatars.ContainsKey(agentID)) { + ScenePresence sp; + scene.TryGetScenePresence(agentID, out sp); + m_avatars[agentID].Say(text); return true; -- cgit v1.1 From 4402851b086e7faf0d441d2ae0d5f6a3e1ea04b8 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 11 Aug 2011 01:56:42 +0100 Subject: Get NPCs to revert to the correct 'resting' animation (e.g. stand or hover) after finishing their movement. This also fixes judder after an avatar has finished "go here"/autopilot movement in a viewer. This meant reseting the SP.AgentControlFlags since the Animator uses these to determine the correct default animation. --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index f38af46..0e313df 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -95,11 +95,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC // } } - // FIXME: This doesn't work - if (presence.PhysicsActor.Flying) - presence.Animator.TrySetMovementAnimation("HOVER"); - else - presence.Animator.TrySetMovementAnimation("STAND"); +// m_log.DebugFormat( +// "[NPC MODULE]: AgentControlFlags {0}, MovementFlag {1} for {2}", +// presence.AgentControlFlags, presence.MovementFlag, presence.Name); } else { -- cgit v1.1 From 36f7d36fa1556d2b9356bc9bc5d9b16fc81eb96a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 11 Aug 2011 02:54:15 +0100 Subject: instead of setting avatar rotation twice in SP.HandleAgentUpdate(), eliminate the second setting in AddNewMovement() --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 0e313df..9b86abb 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -107,7 +107,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC Vector3 agent_control_v3 = new Vector3(); presence.HandleMoveToTargetUpdate(ref agent_control_v3, presence.Rotation); - presence.AddNewMovement(agent_control_v3, presence.Rotation); + presence.AddNewMovement(agent_control_v3); } // //// presence.DoMoveToPositionUpdate((0, presence.MoveToPositionTarget, null); -- cgit v1.1 From 1aa171189397f34d7d18fb358f7bd767d241675a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 11 Aug 2011 03:05:51 +0100 Subject: eliminate the rotation parameter from SP.HandleMoveToTargetUpdate(). This can just use the currently set Rotation looks like I spoke to soon about eliminating jerkiness on "go here"/autopilot. It's still there. --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 9b86abb..580d7ef 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -81,6 +81,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC if (presence.PhysicsActor.Flying) { + // A horrible hack to stop the NPC dead in its tracks rather than having them overshoot + // the target if flying. + // We really need to be more subtle (slow the avatar as it approaches the target) or at + // least be able to set collision status once, rather than 5 times to give it enough + // weighting so that that PhysicsActor thinks it really is colliding. for (int i = 0; i < 5; i++) presence.PhysicsActor.IsColliding = true; @@ -106,7 +111,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget); Vector3 agent_control_v3 = new Vector3(); - presence.HandleMoveToTargetUpdate(ref agent_control_v3, presence.Rotation); + presence.HandleMoveToTargetUpdate(ref agent_control_v3); presence.AddNewMovement(agent_control_v3); } // -- cgit v1.1 From 50945dd56029a1280c581ea9b29213ab0e162a0a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 11 Aug 2011 21:43:26 +0100 Subject: add regression test for osNpcCreate when cloning an in-region avatar --- .../Region/OptionalModules/World/NPC/NPCModule.cs | 29 +++------------------- 1 file changed, 3 insertions(+), 26 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 580d7ef..c764c20 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -45,7 +45,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Dictionary m_avatars = new Dictionary(); - private Dictionary m_appearanceCache = new Dictionary(); public void Initialise(Scene scene, IConfigSource source) { @@ -124,28 +123,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC } } - private AvatarAppearance GetAppearance(UUID target, Scene scene) - { - if (m_appearanceCache.ContainsKey(target)) - return m_appearanceCache[target]; - - ScenePresence originalPresence = scene.GetScenePresence(target); - - if (originalPresence != null) - { - AvatarAppearance originalAppearance = originalPresence.Appearance; - m_appearanceCache.Add(target, originalAppearance); - return originalAppearance; - } - else - { - m_log.DebugFormat( - "[NPC MODULE]: Avatar {0} is not in the scene for us to grab baked textures from them. Using defaults.", target); - - return new AvatarAppearance(); - } - } - public bool IsNPC(UUID agentId, Scene scene) { ScenePresence sp = scene.GetScenePresence(agentId); @@ -176,7 +153,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC return true; } - public UUID CreateNPC(string firstname, string lastname, Vector3 position, Scene scene, UUID cloneAppearanceFrom) + public UUID CreateNPC( + string firstname, string lastname, Vector3 position, Scene scene, AvatarAppearance appearance) { NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, scene); npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue); @@ -191,8 +169,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC acd.lastname = lastname; acd.ServiceURLs = new Dictionary(); - AvatarAppearance originalAppearance = GetAppearance(cloneAppearanceFrom, scene); - AvatarAppearance npcAppearance = new AvatarAppearance(originalAppearance, true); + AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); acd.Appearance = npcAppearance; // for (int i = 0; i < acd.Appearance.Texture.FaceTextures.Length; i++) -- cgit v1.1 From 4b88f04c0afd36f9e88680bbafb7ccc4680fd504 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 12 Aug 2011 22:46:42 +0100 Subject: minor: On "login disable/enable" always tell the user the final login status, rather than remaining silent if it was already on/off --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index c764c20..11fda6d 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -105,9 +105,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC } else { - m_log.DebugFormat( - "[NPC MODULE]: Updating npc {0} at {1} for next movement to {2}", - presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget); +// m_log.DebugFormat( +// "[NPC MODULE]: Updating npc {0} at {1} for next movement to {2}", +// presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget); Vector3 agent_control_v3 = new Vector3(); presence.HandleMoveToTargetUpdate(ref agent_control_v3); -- cgit v1.1 From acfdca34fd9bf6d66d144ae5c0a325dd5e864517 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 17 Aug 2011 01:35:33 +0100 Subject: 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 --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 11fda6d..3b7ae9d 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -143,6 +143,16 @@ namespace OpenSim.Region.OptionalModules.World.NPC if (!m_avatars.ContainsKey(agentId)) return false; + // FIXME: An extremely bad bit of code that reaches directly into the attachments list and manipulates it + List attachments = sp.Attachments; + lock (attachments) + { + foreach (SceneObjectGroup att in attachments) + scene.DeleteSceneObject(att, false); + + attachments.Clear(); + } + AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); sp.Appearance = npcAppearance; sp.RezAttachments(); -- cgit v1.1 From c1a34cd8da293e63d3cba70b5271c9a297789db2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 18 Aug 2011 00:53:05 +0100 Subject: Don't try to save changed attachment states when an NPC with attachments is removed from the scene. This is done by introducing a PresenceType enum into ScenePresence which currently has two values, User and Npc. This seems better than a SaveAttachments flag in terms of code comprehension, though I'm still slightly uneasy about introducing these semantics to core objects --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 3b7ae9d..c1da803 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -190,7 +190,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC // } scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd); - scene.AddNewClient(npcAvatar); + scene.AddNewClient(npcAvatar, PresenceType.Npc); ScenePresence sp; if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) -- cgit v1.1