aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorDiva Canto2010-03-06 08:21:54 -0800
committerDiva Canto2010-03-06 08:21:54 -0800
commitf4c165afe7003ad6276ad7d015fd1c9164a84328 (patch)
tree33274c973c23edee794964f1104fd60e02d82555 /OpenSim
parentMerge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff)
downloadopensim-SC_OLD-f4c165afe7003ad6276ad7d015fd1c9164a84328.zip
opensim-SC_OLD-f4c165afe7003ad6276ad7d015fd1c9164a84328.tar.gz
opensim-SC_OLD-f4c165afe7003ad6276ad7d015fd1c9164a84328.tar.bz2
opensim-SC_OLD-f4c165afe7003ad6276ad7d015fd1c9164a84328.tar.xz
Bug fix: store correct position information upon logout. Fixes mantis #4608
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/IScene.cs2
-rw-r--r--OpenSim/Framework/Util.cs18
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs29
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneBase.cs15
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs5
6 files changed, 58 insertions, 13 deletions
diff --git a/OpenSim/Framework/IScene.cs b/OpenSim/Framework/IScene.cs
index 27b3d47..86d63f8 100644
--- a/OpenSim/Framework/IScene.cs
+++ b/OpenSim/Framework/IScene.cs
@@ -91,6 +91,8 @@ namespace OpenSim.Framework
91 /// </exception> 91 /// </exception>
92 bool PresenceChildStatus(UUID agentId); 92 bool PresenceChildStatus(UUID agentId);
93 93
94 bool TryGetAvatar(UUID agentID, out object scenePresence);
95
94 T RequestModuleInterface<T>(); 96 T RequestModuleInterface<T>();
95 T[] RequestModuleInterfaces<T>(); 97 T[] RequestModuleInterfaces<T>();
96 98
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 10af925..64f6118 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -29,6 +29,7 @@ using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Data; 31using System.Data;
32using System.Diagnostics;
32using System.Globalization; 33using System.Globalization;
33using System.IO; 34using System.IO;
34using System.IO.Compression; 35using System.IO.Compression;
@@ -1443,6 +1444,7 @@ namespace OpenSim.Framework
1443 } 1444 }
1444 1445
1445 #endregion FireAndForget Threading Pattern 1446 #endregion FireAndForget Threading Pattern
1447
1446 /// <summary> 1448 /// <summary>
1447 /// Environment.TickCount is an int but it counts all 32 bits so it goes positive 1449 /// Environment.TickCount is an int but it counts all 32 bits so it goes positive
1448 /// and negative every 24.9 days. This trims down TickCount so it doesn't wrap 1450 /// and negative every 24.9 days. This trims down TickCount so it doesn't wrap
@@ -1467,5 +1469,21 @@ namespace OpenSim.Framework
1467 Int32 diff = EnvironmentTickCount() - prevValue; 1469 Int32 diff = EnvironmentTickCount() - prevValue;
1468 return (diff >= 0) ? diff : (diff + EnvironmentTickCountMask + 1); 1470 return (diff >= 0) ? diff : (diff + EnvironmentTickCountMask + 1);
1469 } 1471 }
1472
1473 /// <summary>
1474 /// Prints the call stack at any given point. Useful for debugging.
1475 /// </summary>
1476 public static void PrintCallStack()
1477 {
1478 StackTrace stackTrace = new StackTrace(); // get call stack
1479 StackFrame[] stackFrames = stackTrace.GetFrames(); // get method calls (frames)
1480
1481 // write call stack method names
1482 foreach (StackFrame stackFrame in stackFrames)
1483 {
1484 m_log.Debug(stackFrame.GetMethod().DeclaringType + "." + stackFrame.GetMethod().Name); // write method name
1485 }
1486 }
1487
1470 } 1488 }
1471} 1489}
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
77 77
78 public void OnNewClient(IClientAPI client) 78 public void OnNewClient(IClientAPI client)
79 { 79 {
80 client.OnLogout += OnLogout; 80 client.OnConnectionClosed += OnConnectionClose;
81 } 81 }
82 82
83 public void OnLogout(IClientAPI client) 83 public void OnConnectionClose(IClientAPI client)
84 { 84 {
85 client.OnLogout -= OnLogout; 85 if (client.IsLoggingOut)
86
87 ScenePresence sp = null;
88 Vector3 position = new Vector3(128, 128, 0);
89 Vector3 lookat = new Vector3(0, 1, 0);
90
91 if (m_aScene.TryGetAvatar(client.AgentId, out sp))
92 { 86 {
93 position = sp.AbsolutePosition; 87 object sp = null;
94 lookat = sp.Lookat; 88 Vector3 position = new Vector3(128, 128, 0);
89 Vector3 lookat = new Vector3(0, 1, 0);
90
91 if (client.Scene.TryGetAvatar(client.AgentId, out sp))
92 {
93 if (sp is ScenePresence)
94 {
95 position = ((ScenePresence)sp).AbsolutePosition;
96 lookat = ((ScenePresence)sp).Lookat;
97 }
98 }
99
100 m_PresenceService.LogoutAgent(client.SessionId, position, lookat);
95 } 101 }
96 m_PresenceService.LogoutAgent(client.SessionId, position, lookat);
97 102
98 } 103 }
99 } 104 }
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
4216 return m_sceneGraph.GetGroupByPrim(localID); 4216 return m_sceneGraph.GetGroupByPrim(localID);
4217 } 4217 }
4218 4218
4219 public bool TryGetAvatar(UUID avatarId, out ScenePresence avatar) 4219 public override bool TryGetAvatar(UUID avatarId, out ScenePresence avatar)
4220 { 4220 {
4221 return m_sceneGraph.TryGetAvatar(avatarId, out avatar); 4221 return m_sceneGraph.TryGetAvatar(avatarId, out avatar);
4222 } 4222 }
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
190 /// <param name="agentID"></param> 190 /// <param name="agentID"></param>
191 public abstract void RemoveClient(UUID agentID); 191 public abstract void RemoveClient(UUID agentID);
192 192
193 public bool TryGetAvatar(UUID agentID, out object scenePresence)
194 {
195 scenePresence = null;
196 ScenePresence sp = null;
197 if (TryGetAvatar(agentID, out sp))
198 {
199 scenePresence = sp;
200 return true;
201 }
202
203 return false;
204 }
205
206 public abstract bool TryGetAvatar(UUID agentID, out ScenePresence scenePresence);
207
193 #endregion 208 #endregion
194 209
195 /// <summary> 210 /// <summary>
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
65 { 65 {
66 throw new NotImplementedException(); 66 throw new NotImplementedException();
67 } 67 }
68
69 public override bool TryGetAvatar(UUID agentID, out ScenePresence scenePresence)
70 {
71 throw new NotImplementedException();
72 }
68 } 73 }
69 74
70 [Test] 75 [Test]