From 9d95f9bcf4decd7f9cfcbc8c51a2a9cae567b8bb Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 8 Feb 2008 19:53:18 +0000 Subject: Minor ScenePresence related refactoring --- OpenSim/Region/Environment/Scenes/Scene.cs | 22 ++++++++++++++++--- OpenSim/Region/Environment/Scenes/SceneManager.cs | 26 ++++++++++------------- 2 files changed, 30 insertions(+), 18 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index bd7f59d..3480530 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -1407,12 +1407,28 @@ namespace OpenSim.Region.Environment.Scenes lock (m_scenePresences) { - m_scenePresences.Remove(agentID); + if (m_scenePresences.Remove(agentID)) + { + //m_log.Info(String.Format("[SCENE] Removed scene presence {0}", agentID)); + } + else + { + m_log.Warn( + String.Format("[SCENE] Tried to remove non-existent scene prescence with agent ID {0} from scene ScenePresences list", agentID)); + } } lock (Entities) { - Entities.Remove(agentID); + if (Entities.Remove(agentID)) + { + //m_log.Info(String.Format("[SCENE] Removed scene presence {0} from entities list", agentID)); + } + else + { + m_log.Warn( + String.Format("[SCENE] Tried to remove non-existent scene prescence with agent ID {0} from scene Entities list", agentID)); + } } try @@ -1425,7 +1441,7 @@ namespace OpenSim.Region.Environment.Scenes } catch (Exception e) { - m_log.Error("Scene.cs:RemoveClient exception: " + e.ToString()); + m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); } // Remove client agent from profile, so new logins will work diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs index 7156428..9f066d3 100644 --- a/OpenSim/Region/Environment/Scenes/SceneManager.cs +++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs @@ -316,21 +316,17 @@ namespace OpenSim.Region.Environment.Scenes List avatars = new List(); ForEachCurrentScene(delegate(Scene scene) - { - List EntitieList = scene.GetEntities(); + { + List scenePrescences = scene.GetScenePresences(); - foreach (EntityBase entity in EntitieList) - { - if (entity is ScenePresence) - { - ScenePresence scenePrescence = entity as ScenePresence; - if (!scenePrescence.IsChildAgent) - { - avatars.Add(scenePrescence); - } - } - } - }); + foreach (ScenePresence scenePrescence in scenePrescences) + { + if (!scenePrescence.IsChildAgent) + { + avatars.Add(scenePrescence); + } + } + }); return avatars; } @@ -423,4 +419,4 @@ namespace OpenSim.Region.Environment.Scenes m_localScenes.ForEach(action); } } -} \ No newline at end of file +} -- cgit v1.1