aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
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/NPC/NPCModule.cs
parentSplit out to-be-common setup stuff from TestOsOwnerSaveAppearance() (diff)
downloadopensim-SC-50945dd56029a1280c581ea9b29213ab0e162a0a.zip
opensim-SC-50945dd56029a1280c581ea9b29213ab0e162a0a.tar.gz
opensim-SC-50945dd56029a1280c581ea9b29213ab0e162a0a.tar.bz2
opensim-SC-50945dd56029a1280c581ea9b29213ab0e162a0a.tar.xz
add regression test for osNpcCreate when cloning an in-region avatar
Diffstat (limited to 'OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs')
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs29
1 files changed, 3 insertions, 26 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++)