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.
							parent
							
								
									16c4636048
								
							
						
					
					
						commit
						9c84a8162f
					
				| 
						 | 
				
			
			@ -58,7 +58,7 @@ namespace OpenSim.Region.Framework.Interfaces
 | 
			
		|||
        /// </param>
 | 
			
		||||
        /// <param name="scene"></param>
 | 
			
		||||
        /// <param name="appearance">The avatar appearance to use for the new NPC.</param>
 | 
			
		||||
        /// <returns>The UUID of the ScenePresence created.</returns>
 | 
			
		||||
        /// <returns>The UUID of the ScenePresence created.  UUID.Zero if there was a failure.</returns>
 | 
			
		||||
        UUID CreateNPC(
 | 
			
		||||
            string firstname,
 | 
			
		||||
            string lastname,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -148,22 +148,21 @@ namespace OpenSim.Region.OptionalModules.World.NPC
 | 
			
		|||
                ScenePresence sp;
 | 
			
		||||
                if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
 | 
			
		||||
                {
 | 
			
		||||
                    m_log.DebugFormat(
 | 
			
		||||
                        "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID);
 | 
			
		||||
//                    m_log.DebugFormat(
 | 
			
		||||
//                        "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID);
 | 
			
		||||
 | 
			
		||||
                    sp.CompleteMovement(npcAvatar, false);
 | 
			
		||||
                    m_avatars.Add(npcAvatar.AgentId, npcAvatar);
 | 
			
		||||
                    m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId);
 | 
			
		||||
 | 
			
		||||
                    return npcAvatar.AgentId;
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID);
 | 
			
		||||
                    return UUID.Zero;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                m_avatars.Add(npcAvatar.AgentId, npcAvatar);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId);
 | 
			
		||||
 | 
			
		||||
            return npcAvatar.AgentId;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue