Extend m_avatars lock in NpcModule.CreateNPC over both creation of NPC scene presence and population of m_avatars.
This is required to stop a race where the SensorRepeat module can detect an NPC avatar before m_avatars is populated. Extending the lock is the easiest to understand solution rather than getting complicated with null checks. Hopefully resolves http://opensimulator.org/mantis/view.php?id=5872iar_mods
parent
6234264211
commit
ce34b359ad
|
@ -140,24 +140,26 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||||
// acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]);
|
// acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
|
|
||||||
scene.AddNewClient(npcAvatar, PresenceType.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);
|
|
||||||
|
|
||||||
sp.CompleteMovement(npcAvatar, false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID);
|
|
||||||
}
|
|
||||||
|
|
||||||
lock (m_avatars)
|
lock (m_avatars)
|
||||||
|
{
|
||||||
|
scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
|
||||||
|
scene.AddNewClient(npcAvatar, PresenceType.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);
|
||||||
|
|
||||||
|
sp.CompleteMovement(npcAvatar, false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID);
|
||||||
|
}
|
||||||
|
|
||||||
m_avatars.Add(npcAvatar.AgentId, npcAvatar);
|
m_avatars.Add(npcAvatar.AgentId, npcAvatar);
|
||||||
|
}
|
||||||
|
|
||||||
m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId);
|
m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue