aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-03-06 01:27:30 +0000
committerJustin Clark-Casey (justincc)2012-03-06 01:27:30 +0000
commitd44b7c486a5b51bbfbea2c3d2efd2c9dc0f99d0e (patch)
treeb62aa7e3b623c3e4a86031ea5a289b0a8d3ea32f
parentUpdates to MSSQL store for 0.7.3 to include: (diff)
downloadopensim-SC_OLD-d44b7c486a5b51bbfbea2c3d2efd2c9dc0f99d0e.zip
opensim-SC_OLD-d44b7c486a5b51bbfbea2c3d2efd2c9dc0f99d0e.tar.gz
opensim-SC_OLD-d44b7c486a5b51bbfbea2c3d2efd2c9dc0f99d0e.tar.bz2
opensim-SC_OLD-d44b7c486a5b51bbfbea2c3d2efd2c9dc0f99d0e.tar.xz
Go back to setting appearance directly in NPCModule.SetAppearance() to fix mantis 5914
The part reverted is from commit 2ebb421. Unfortunately, IAvatarFactoryModule.SetAppearance() does not transfer attachments. I'm not sure how to do this separately, unfortunately I'll need to leave it to Dan :) Regression test added for this case. Mantis ref: http://opensimulator.org/mantis/view.php?id=5914
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs20
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs46
2 files changed, 57 insertions, 9 deletions
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index 2052cdb..2b8379d 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -88,22 +88,26 @@ namespace OpenSim.Region.OptionalModules.World.NPC
88 88
89 public bool SetNPCAppearance(UUID agentId, AvatarAppearance appearance, Scene scene) 89 public bool SetNPCAppearance(UUID agentId, AvatarAppearance appearance, Scene scene)
90 { 90 {
91 ScenePresence sp = scene.GetScenePresence(agentId); 91 ScenePresence npc = scene.GetScenePresence(agentId);
92 if (sp == null || sp.IsChildAgent) 92 if (npc == null || npc.IsChildAgent)
93 return false; 93 return false;
94 94
95 lock (m_avatars) 95 lock (m_avatars)
96 if (!m_avatars.ContainsKey(agentId)) 96 if (!m_avatars.ContainsKey(agentId))
97 return false; 97 return false;
98 98
99 // Delete existing sp attachments 99 // Delete existing npc attachments
100 scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, false); 100 scene.AttachmentsModule.DeleteAttachmentsFromScene(npc, false);
101 101
102 // Set new sp appearance. Also sends to clients. 102 // XXX: We can't just use IAvatarFactoryModule.SetAppearance() yet since it doesn't transfer attachments
103 scene.RequestModuleInterface<IAvatarFactoryModule>().SetAppearance(sp, new AvatarAppearance(appearance, true)); 103 AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true);
104 npc.Appearance = npcAppearance;
104 105
105 // Rez needed sp attachments 106 // Rez needed npc attachments
106 scene.AttachmentsModule.RezAttachments(sp); 107 scene.AttachmentsModule.RezAttachments(npc);
108
109 IAvatarFactoryModule module = scene.RequestModuleInterface<IAvatarFactoryModule>();
110 module.SendAppearance(npc.UUID);
107 111
108 return true; 112 return true;
109 } 113 }
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
index d507822..36e2d4a 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
@@ -139,7 +139,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
139 } 139 }
140 140
141 [Test] 141 [Test]
142 public void TestAttachments() 142 public void TestCreateWithAttachments()
143 { 143 {
144 TestHelpers.InMethod(); 144 TestHelpers.InMethod();
145// log4net.Config.XmlConfigurator.Configure(); 145// log4net.Config.XmlConfigurator.Configure();
@@ -179,6 +179,50 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
179 } 179 }
180 180
181 [Test] 181 [Test]
182 public void TestLoadAppearance()
183 {
184 TestHelpers.InMethod();
185// log4net.Config.XmlConfigurator.Configure();
186
187 UUID userId = TestHelpers.ParseTail(0x1);
188 UserAccountHelpers.CreateUserWithInventory(scene, userId);
189 ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId);
190
191 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
192 UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, scene, sp.Appearance);
193
194 // Now add the attachment to the original avatar and use that to load a new appearance
195 // TODO: Could also run tests loading from a notecard though this isn't much different for our purposes here
196 UUID attItemId = TestHelpers.ParseTail(0x2);
197 UUID attAssetId = TestHelpers.ParseTail(0x3);
198 string attName = "att";
199
200 UserInventoryHelpers.CreateInventoryItem(scene, attName, attItemId, attAssetId, sp.UUID, InventoryType.Object);
201
202 am.RezSingleAttachmentFromInventory(sp, attItemId, (uint)AttachmentPoint.Chest);
203
204 npcModule.SetNPCAppearance(npcId, sp.Appearance, scene);
205
206 ScenePresence npc = scene.GetScenePresence(npcId);
207
208 // Check scene presence status
209 Assert.That(npc.HasAttachments(), Is.True);
210 List<SceneObjectGroup> attachments = npc.GetAttachments();
211 Assert.That(attachments.Count, Is.EqualTo(1));
212 SceneObjectGroup attSo = attachments[0];
213
214 // Just for now, we won't test the name since this is (wrongly) the asset part name rather than the item
215 // name. TODO: Do need to fix ultimately since the item may be renamed before being passed on to an NPC.
216// Assert.That(attSo.Name, Is.EqualTo(attName));
217
218 Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
219 Assert.That(attSo.IsAttachment);
220 Assert.That(attSo.UsesPhysics, Is.False);
221 Assert.That(attSo.IsTemporary, Is.False);
222 Assert.That(attSo.OwnerID, Is.EqualTo(npc.UUID));
223 }
224
225 [Test]
182 public void TestMove() 226 public void TestMove()
183 { 227 {
184 TestHelpers.InMethod(); 228 TestHelpers.InMethod();