Added some sanity checks to AddViewerAgent to prevent duplicate addition (now attempts update).

zircon^2
Adam Frisby 2007-05-14 19:31:05 +00:00
parent 20b4ecbec1
commit 7659d67fdb
1 changed files with 16 additions and 2 deletions

View File

@ -560,14 +560,28 @@ namespace OpenSim.world
} }
} }
lock (Entities) lock (Entities)
{
if (!Entities.ContainsKey(agentClient.AgentID))
{ {
this.Entities.Add(agentClient.AgentID, newAvatar); this.Entities.Add(agentClient.AgentID, newAvatar);
} }
else
{
Entities[agentClient.AgentID] = newAvatar;
}
}
lock (Avatars) lock (Avatars)
{
if (Avatars.ContainsKey(agentClient.AgentID))
{
Avatars[agentClient.AgentID] = newAvatar;
}
else
{ {
this.Avatars.Add(agentClient.AgentID, newAvatar); this.Avatars.Add(agentClient.AgentID, newAvatar);
} }
} }
}
catch (Exception e) catch (Exception e)
{ {
OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM,"World.cs: AddViewerAgent() - Failed with exception " + e.ToString()); OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM,"World.cs: AddViewerAgent() - Failed with exception " + e.ToString());