From f4c165afe7003ad6276ad7d015fd1c9164a84328 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 6 Mar 2010 08:21:54 -0800 Subject: Bug fix: store correct position information upon logout. Fixes mantis #4608 --- .../Presence/PresenceDetector.cs | 29 +++++++++++++--------- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneBase.cs | 15 +++++++++++ .../Framework/Scenes/Tests/SceneBaseTests.cs | 5 ++++ 4 files changed, 38 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs index 891fc14..e98df28 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs @@ -77,23 +77,28 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence public void OnNewClient(IClientAPI client) { - client.OnLogout += OnLogout; + client.OnConnectionClosed += OnConnectionClose; } - public void OnLogout(IClientAPI client) + public void OnConnectionClose(IClientAPI client) { - client.OnLogout -= OnLogout; - - ScenePresence sp = null; - Vector3 position = new Vector3(128, 128, 0); - Vector3 lookat = new Vector3(0, 1, 0); - - if (m_aScene.TryGetAvatar(client.AgentId, out sp)) + if (client.IsLoggingOut) { - position = sp.AbsolutePosition; - lookat = sp.Lookat; + object sp = null; + Vector3 position = new Vector3(128, 128, 0); + Vector3 lookat = new Vector3(0, 1, 0); + + if (client.Scene.TryGetAvatar(client.AgentId, out sp)) + { + if (sp is ScenePresence) + { + position = ((ScenePresence)sp).AbsolutePosition; + lookat = ((ScenePresence)sp).Lookat; + } + } + + m_PresenceService.LogoutAgent(client.SessionId, position, lookat); } - m_PresenceService.LogoutAgent(client.SessionId, position, lookat); } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 30c69a8..1eb3117 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4216,7 +4216,7 @@ namespace OpenSim.Region.Framework.Scenes return m_sceneGraph.GetGroupByPrim(localID); } - public bool TryGetAvatar(UUID avatarId, out ScenePresence avatar) + public override bool TryGetAvatar(UUID avatarId, out ScenePresence avatar) { return m_sceneGraph.TryGetAvatar(avatarId, out avatar); } diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index 4f6e824..74476ed 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs @@ -190,6 +190,21 @@ namespace OpenSim.Region.Framework.Scenes /// public abstract void RemoveClient(UUID agentID); + public bool TryGetAvatar(UUID agentID, out object scenePresence) + { + scenePresence = null; + ScenePresence sp = null; + if (TryGetAvatar(agentID, out sp)) + { + scenePresence = sp; + return true; + } + + return false; + } + + public abstract bool TryGetAvatar(UUID agentID, out ScenePresence scenePresence); + #endregion /// diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs index 8230f32..840039c 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs @@ -65,6 +65,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests { throw new NotImplementedException(); } + + public override bool TryGetAvatar(UUID agentID, out ScenePresence scenePresence) + { + throw new NotImplementedException(); + } } [Test] -- cgit v1.1