aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-02-09 01:17:59 +0000
committerJustin Clark-Casey (justincc)2012-02-09 01:17:59 +0000
commit9c84a8162f700fc2eb35018389c12fcfedc02587 (patch)
tree663c57d6ed5a4eb071fbd7e1ab69315dcb34c067
parentAdd NPC torture tests for 100, 1000 and 2000 create and delete NPC calls. (diff)
downloadopensim-SC_OLD-9c84a8162f700fc2eb35018389c12fcfedc02587.zip
opensim-SC_OLD-9c84a8162f700fc2eb35018389c12fcfedc02587.tar.gz
opensim-SC_OLD-9c84a8162f700fc2eb35018389c12fcfedc02587.tar.bz2
opensim-SC_OLD-9c84a8162f700fc2eb35018389c12fcfedc02587.tar.xz
If NPCModule.CreateNPC() fails to create the required ScenePresence (which should in theory never happen), don't add the NPC to the npc list but return UUID.Zero instead.
-rw-r--r--OpenSim/Region/Framework/Interfaces/INPCModule.cs2
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs15
2 files changed, 8 insertions, 9 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/INPCModule.cs b/OpenSim/Region/Framework/Interfaces/INPCModule.cs
index 2731291..dc3ff89 100644
--- a/OpenSim/Region/Framework/Interfaces/INPCModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/INPCModule.cs
@@ -58,7 +58,7 @@ namespace OpenSim.Region.Framework.Interfaces
58 /// </param> 58 /// </param>
59 /// <param name="scene"></param> 59 /// <param name="scene"></param>
60 /// <param name="appearance">The avatar appearance to use for the new NPC.</param> 60 /// <param name="appearance">The avatar appearance to use for the new NPC.</param>
61 /// <returns>The UUID of the ScenePresence created.</returns> 61 /// <returns>The UUID of the ScenePresence created. UUID.Zero if there was a failure.</returns>
62 UUID CreateNPC( 62 UUID CreateNPC(
63 string firstname, 63 string firstname,
64 string lastname, 64 string lastname,
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index 8701431..dc6eefc 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -148,22 +148,21 @@ namespace OpenSim.Region.OptionalModules.World.NPC
148 ScenePresence sp; 148 ScenePresence sp;
149 if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) 149 if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
150 { 150 {
151 m_log.DebugFormat( 151// m_log.DebugFormat(
152 "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID); 152// "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID);
153 153
154 sp.CompleteMovement(npcAvatar, false); 154 sp.CompleteMovement(npcAvatar, false);
155 m_avatars.Add(npcAvatar.AgentId, npcAvatar);
156 m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId);
157
158 return npcAvatar.AgentId;
155 } 159 }
156 else 160 else
157 { 161 {
158 m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID); 162 m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID);
163 return UUID.Zero;
159 } 164 }
160
161 m_avatars.Add(npcAvatar.AgentId, npcAvatar);
162 } 165 }
163
164 m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId);
165
166 return npcAvatar.AgentId;
167 } 166 }
168 167
169 public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget) 168 public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget)