From 52b711af824eff047f8e65139cf7bdfb150f270f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 25 Jun 2010 18:55:20 +0100 Subject: stop KeyNotFoundException() being thrown in RemoveScenePresence if the agent isn't present in the presence dictionary the code to do this was there but was being circumvented by newmap[agentID] before the check actually took place --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 673674d..240c688 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -599,7 +599,7 @@ namespace OpenSim.Region.Framework.Scenes if (!Entities.Remove(agentID)) { m_log.WarnFormat( - "[SCENE] Tried to remove non-existent scene presence with agent ID {0} from scene Entities list", + "[SCENE]: Tried to remove non-existent scene presence with agent ID {0} from scene Entities list", agentID); } @@ -607,12 +607,13 @@ namespace OpenSim.Region.Framework.Scenes { Dictionary newmap = new Dictionary(m_scenePresenceMap); List newlist = new List(m_scenePresenceArray); - - // Remember the old presene reference from the dictionary - ScenePresence oldref = newmap[agentID]; + // Remove the presence reference from the dictionary - if (newmap.Remove(agentID)) + if (newmap.ContainsKey(agentID)) { + ScenePresence oldref = newmap[agentID]; + newmap.Remove(agentID); + // Find the index in the list where the old ref was stored and remove the reference newlist.RemoveAt(newlist.IndexOf(oldref)); // Swap out the dictionary and list with new references @@ -621,7 +622,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - m_log.WarnFormat("[SCENE] Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); + m_log.WarnFormat("[SCENE]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); } } } -- cgit v1.1