aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/World
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-08-11 21:43:26 +0100
committerJustin Clark-Casey (justincc)2011-08-11 21:43:26 +0100
commit50945dd56029a1280c581ea9b29213ab0e162a0a (patch)
tree826067de13242de2e3137ef68cfae4f87c6c59b8 /OpenSim/Region/OptionalModules/World
parentSplit out to-be-common setup stuff from TestOsOwnerSaveAppearance() (diff)
downloadopensim-SC_OLD-50945dd56029a1280c581ea9b29213ab0e162a0a.zip
opensim-SC_OLD-50945dd56029a1280c581ea9b29213ab0e162a0a.tar.gz
opensim-SC_OLD-50945dd56029a1280c581ea9b29213ab0e162a0a.tar.bz2
opensim-SC_OLD-50945dd56029a1280c581ea9b29213ab0e162a0a.tar.xz
add regression test for osNpcCreate when cloning an in-region avatar
Diffstat (limited to 'OpenSim/Region/OptionalModules/World')
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs29
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs10
2 files changed, 8 insertions, 31 deletions
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
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 46
47 private Dictionary<UUID, NPCAvatar> m_avatars = new Dictionary<UUID, NPCAvatar>(); 47 private Dictionary<UUID, NPCAvatar> m_avatars = new Dictionary<UUID, NPCAvatar>();
48 private Dictionary<UUID, AvatarAppearance> m_appearanceCache = new Dictionary<UUID, AvatarAppearance>();
49 48
50 public void Initialise(Scene scene, IConfigSource source) 49 public void Initialise(Scene scene, IConfigSource source)
51 { 50 {
@@ -124,28 +123,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC
124 } 123 }
125 } 124 }
126 125
127 private AvatarAppearance GetAppearance(UUID target, Scene scene)
128 {
129 if (m_appearanceCache.ContainsKey(target))
130 return m_appearanceCache[target];
131
132 ScenePresence originalPresence = scene.GetScenePresence(target);
133
134 if (originalPresence != null)
135 {
136 AvatarAppearance originalAppearance = originalPresence.Appearance;
137 m_appearanceCache.Add(target, originalAppearance);
138 return originalAppearance;
139 }
140 else
141 {
142 m_log.DebugFormat(
143 "[NPC MODULE]: Avatar {0} is not in the scene for us to grab baked textures from them. Using defaults.", target);
144
145 return new AvatarAppearance();
146 }
147 }
148
149 public bool IsNPC(UUID agentId, Scene scene) 126 public bool IsNPC(UUID agentId, Scene scene)
150 { 127 {
151 ScenePresence sp = scene.GetScenePresence(agentId); 128 ScenePresence sp = scene.GetScenePresence(agentId);
@@ -176,7 +153,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
176 return true; 153 return true;
177 } 154 }
178 155
179 public UUID CreateNPC(string firstname, string lastname, Vector3 position, Scene scene, UUID cloneAppearanceFrom) 156 public UUID CreateNPC(
157 string firstname, string lastname, Vector3 position, Scene scene, AvatarAppearance appearance)
180 { 158 {
181 NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, scene); 159 NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, scene);
182 npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue); 160 npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue);
@@ -191,8 +169,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
191 acd.lastname = lastname; 169 acd.lastname = lastname;
192 acd.ServiceURLs = new Dictionary<string, object>(); 170 acd.ServiceURLs = new Dictionary<string, object>();
193 171
194 AvatarAppearance originalAppearance = GetAppearance(cloneAppearanceFrom, scene); 172 AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true);
195 AvatarAppearance npcAppearance = new AvatarAppearance(originalAppearance, true);
196 acd.Appearance = npcAppearance; 173 acd.Appearance = npcAppearance;
197 174
198// for (int i = 0; i < acd.Appearance.Texture.FaceTextures.Length; i++) 175// for (int i = 0; i < acd.Appearance.Texture.FaceTextures.Length; i++)
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
index 2742b67..f8afc5a 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
@@ -59,7 +59,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
59 AvatarFactoryModule afm = new AvatarFactoryModule(); 59 AvatarFactoryModule afm = new AvatarFactoryModule();
60 TestScene scene = SceneHelpers.SetupScene(); 60 TestScene scene = SceneHelpers.SetupScene();
61 SceneHelpers.SetupSceneModules(scene, config, afm, new NPCModule()); 61 SceneHelpers.SetupSceneModules(scene, config, afm, new NPCModule());
62 IClientAPI originalClient = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)).ControllingClient; 62 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
63// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); 63// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
64 64
65 // 8 is the index of the first baked texture in AvatarAppearance 65 // 8 is the index of the first baked texture in AvatarAppearance
@@ -72,10 +72,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
72 // ScenePresence.SendInitialData() to reset our entire appearance. 72 // ScenePresence.SendInitialData() to reset our entire appearance.
73 scene.AssetService.Store(AssetHelpers.CreateAsset(originalFace8TextureId)); 73 scene.AssetService.Store(AssetHelpers.CreateAsset(originalFace8TextureId));
74 74
75 afm.SetAppearanceFromClient(originalClient, originalTe, null); 75 afm.SetAppearanceFromClient(sp.ControllingClient, originalTe, null);
76 76
77 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); 77 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
78 UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, originalClient.AgentId); 78 UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, sp.Appearance);
79 79
80 ScenePresence npc = scene.GetScenePresence(npcId); 80 ScenePresence npc = scene.GetScenePresence(npcId);
81 81
@@ -96,12 +96,12 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
96 96
97 TestScene scene = SceneHelpers.SetupScene(); 97 TestScene scene = SceneHelpers.SetupScene();
98 SceneHelpers.SetupSceneModules(scene, config, new NPCModule()); 98 SceneHelpers.SetupSceneModules(scene, config, new NPCModule());
99 IClientAPI originalClient = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)).ControllingClient; 99 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
100// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); 100// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
101 101
102 Vector3 startPos = new Vector3(128, 128, 30); 102 Vector3 startPos = new Vector3(128, 128, 30);
103 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); 103 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
104 UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, scene, originalClient.AgentId); 104 UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, scene, sp.Appearance);
105 105
106 ScenePresence npc = scene.GetScenePresence(npcId); 106 ScenePresence npc = scene.GetScenePresence(npcId);
107 Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); 107 Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));