diff options
Diffstat (limited to '')
5 files changed, 163 insertions, 34 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index c0c2ca7..1f782f5 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs | |||
@@ -48,6 +48,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
48 | private static readonly ILog m_log = | 48 | private static readonly ILog m_log = |
49 | LogManager.GetLogger( | 49 | LogManager.GetLogger( |
50 | MethodBase.GetCurrentMethod().DeclaringType); | 50 | MethodBase.GetCurrentMethod().DeclaringType); |
51 | private static string LogHeader = "[LOCAL GRID SERVICE CONNECTOR]"; | ||
51 | 52 | ||
52 | private IGridService m_GridService; | 53 | private IGridService m_GridService; |
53 | private Dictionary<UUID, RegionCache> m_LocalCache = new Dictionary<UUID, RegionCache>(); | 54 | private Dictionary<UUID, RegionCache> m_LocalCache = new Dictionary<UUID, RegionCache>(); |
@@ -56,11 +57,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
56 | 57 | ||
57 | public LocalGridServicesConnector() | 58 | public LocalGridServicesConnector() |
58 | { | 59 | { |
60 | m_log.DebugFormat("{0} LocalGridServicesConnector no parms.", LogHeader); | ||
59 | } | 61 | } |
60 | 62 | ||
61 | public LocalGridServicesConnector(IConfigSource source) | 63 | public LocalGridServicesConnector(IConfigSource source) |
62 | { | 64 | { |
63 | m_log.Debug("[LOCAL GRID SERVICE CONNECTOR]: LocalGridServicesConnector instantiated directly."); | 65 | m_log.DebugFormat("{0} LocalGridServicesConnector instantiated directly.", LogHeader); |
64 | InitialiseService(source); | 66 | InitialiseService(source); |
65 | } | 67 | } |
66 | 68 | ||
@@ -92,15 +94,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
92 | 94 | ||
93 | private void InitialiseService(IConfigSource source) | 95 | private void InitialiseService(IConfigSource source) |
94 | { | 96 | { |
95 | IConfig assetConfig = source.Configs["GridService"]; | 97 | IConfig config = source.Configs["GridService"]; |
96 | if (assetConfig == null) | 98 | if (config == null) |
97 | { | 99 | { |
98 | m_log.Error("[LOCAL GRID SERVICE CONNECTOR]: GridService missing from OpenSim.ini"); | 100 | m_log.Error("[LOCAL GRID SERVICE CONNECTOR]: GridService missing from OpenSim.ini"); |
99 | return; | 101 | return; |
100 | } | 102 | } |
101 | 103 | ||
102 | string serviceDll = assetConfig.GetString("LocalServiceModule", | 104 | string serviceDll = config.GetString("LocalServiceModule", String.Empty); |
103 | String.Empty); | ||
104 | 105 | ||
105 | if (serviceDll == String.Empty) | 106 | if (serviceDll == String.Empty) |
106 | { | 107 | { |
@@ -142,10 +143,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
142 | 143 | ||
143 | scene.RegisterModuleInterface<IGridService>(this); | 144 | scene.RegisterModuleInterface<IGridService>(this); |
144 | 145 | ||
145 | if (m_LocalCache.ContainsKey(scene.RegionInfo.RegionID)) | 146 | lock (m_LocalCache) |
146 | m_log.ErrorFormat("[LOCAL GRID SERVICE CONNECTOR]: simulator seems to have more than one region with the same UUID. Please correct this!"); | 147 | { |
147 | else | 148 | if (m_LocalCache.ContainsKey(scene.RegionInfo.RegionID)) |
148 | m_LocalCache.Add(scene.RegionInfo.RegionID, new RegionCache(scene)); | 149 | m_log.ErrorFormat("[LOCAL GRID SERVICE CONNECTOR]: simulator seems to have more than one region with the same UUID. Please correct this!"); |
150 | else | ||
151 | m_LocalCache.Add(scene.RegionInfo.RegionID, new RegionCache(scene)); | ||
152 | } | ||
149 | } | 153 | } |
150 | 154 | ||
151 | public void RemoveRegion(Scene scene) | 155 | public void RemoveRegion(Scene scene) |
@@ -153,8 +157,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
153 | if (!m_Enabled) | 157 | if (!m_Enabled) |
154 | return; | 158 | return; |
155 | 159 | ||
156 | m_LocalCache[scene.RegionInfo.RegionID].Clear(); | 160 | lock (m_LocalCache) |
157 | m_LocalCache.Remove(scene.RegionInfo.RegionID); | 161 | { |
162 | m_LocalCache[scene.RegionInfo.RegionID].Clear(); | ||
163 | m_LocalCache.Remove(scene.RegionInfo.RegionID); | ||
164 | } | ||
158 | } | 165 | } |
159 | 166 | ||
160 | public void RegionLoaded(Scene scene) | 167 | public void RegionLoaded(Scene scene) |
@@ -185,23 +192,59 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
185 | return m_GridService.GetRegionByUUID(scopeID, regionID); | 192 | return m_GridService.GetRegionByUUID(scopeID, regionID); |
186 | } | 193 | } |
187 | 194 | ||
195 | // Get a region given its base coordinates. | ||
196 | // NOTE: this is NOT 'get a region by some point in the region'. The coordinate MUST | ||
197 | // be the base coordinate of the region. | ||
188 | public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) | 198 | public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) |
189 | { | 199 | { |
190 | GridRegion region = null; | 200 | GridRegion region = null; |
201 | uint regionX = Util.WorldToRegionLoc((uint)x); | ||
202 | uint regionY = Util.WorldToRegionLoc((uint)y); | ||
203 | |||
204 | // Sanity check | ||
205 | if ((Util.RegionToWorldLoc(regionX) != (uint)x) || (Util.RegionToWorldLoc(regionY) != (uint)y)) | ||
206 | { | ||
207 | m_log.WarnFormat("{0} GetRegionByPosition. Bad position requested: not the base of the region. Requested Pos=<{1},{2}>, Should Be=<{3},{4}>", | ||
208 | LogHeader, x, y, Util.RegionToWorldLoc(regionX), Util.RegionToWorldLoc(regionY)); | ||
209 | } | ||
191 | 210 | ||
192 | // First see if it's a neighbour, even if it isn't on this sim. | 211 | // First see if it's a neighbour, even if it isn't on this sim. |
193 | // Neighbour data is cached in memory, so this is fast | 212 | // Neighbour data is cached in memory, so this is fast |
194 | foreach (RegionCache rcache in m_LocalCache.Values) | 213 | |
214 | lock (m_LocalCache) | ||
195 | { | 215 | { |
196 | region = rcache.GetRegionByPosition(x, y); | 216 | foreach (RegionCache rcache in m_LocalCache.Values) |
197 | if (region != null) | ||
198 | { | 217 | { |
199 | return region; | 218 | region = rcache.GetRegionByPosition(x, y); |
219 | if (region != null) | ||
220 | { | ||
221 | m_log.DebugFormat("{0} GetRegionByPosition. Found region {1} in cache (of region {2}). Pos=<{3},{4}>", | ||
222 | LogHeader, region.RegionName, rcache.RegionName, | ||
223 | Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY)); | ||
224 | break; | ||
225 | } | ||
200 | } | 226 | } |
201 | } | 227 | } |
202 | 228 | ||
203 | // Then try on this sim (may be a lookup in DB if this is using MySql). | 229 | // Then try on this sim (may be a lookup in DB if this is using MySql). |
204 | return m_GridService.GetRegionByPosition(scopeID, x, y); | 230 | if (region == null) |
231 | { | ||
232 | region = m_GridService.GetRegionByPosition(scopeID, x, y); | ||
233 | |||
234 | if (region == null) | ||
235 | { | ||
236 | m_log.DebugFormat("{0} GetRegionByPosition. Region not found by grid service. Pos=<{1},{2}>", | ||
237 | LogHeader, regionX, regionY); | ||
238 | } | ||
239 | else | ||
240 | { | ||
241 | m_log.DebugFormat("{0} GetRegionByPosition. Got region {1} from grid service. Pos=<{2},{3}>", | ||
242 | LogHeader, region.RegionName, | ||
243 | Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY)); | ||
244 | } | ||
245 | } | ||
246 | |||
247 | return region; | ||
205 | } | 248 | } |
206 | 249 | ||
207 | public GridRegion GetRegionByName(UUID scopeID, string regionName) | 250 | public GridRegion GetRegionByName(UUID scopeID, string regionName) |
@@ -224,6 +267,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
224 | return m_GridService.GetDefaultRegions(scopeID); | 267 | return m_GridService.GetDefaultRegions(scopeID); |
225 | } | 268 | } |
226 | 269 | ||
270 | public List<GridRegion> GetDefaultHypergridRegions(UUID scopeID) | ||
271 | { | ||
272 | return m_GridService.GetDefaultHypergridRegions(scopeID); | ||
273 | } | ||
274 | |||
227 | public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y) | 275 | public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y) |
228 | { | 276 | { |
229 | return m_GridService.GetFallbackRegions(scopeID, x, y); | 277 | return m_GridService.GetFallbackRegions(scopeID, x, y); |
@@ -239,21 +287,29 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
239 | return m_GridService.GetRegionFlags(scopeID, regionID); | 287 | return m_GridService.GetRegionFlags(scopeID, regionID); |
240 | } | 288 | } |
241 | 289 | ||
290 | public Dictionary<string, object> GetExtraFeatures() | ||
291 | { | ||
292 | return m_GridService.GetExtraFeatures(); | ||
293 | } | ||
294 | |||
242 | #endregion | 295 | #endregion |
243 | 296 | ||
244 | public void HandleShowNeighboursCommand(string module, string[] cmdparams) | 297 | public void HandleShowNeighboursCommand(string module, string[] cmdparams) |
245 | { | 298 | { |
246 | System.Text.StringBuilder caps = new System.Text.StringBuilder(); | 299 | System.Text.StringBuilder caps = new System.Text.StringBuilder(); |
247 | 300 | ||
248 | foreach (KeyValuePair<UUID, RegionCache> kvp in m_LocalCache) | 301 | lock (m_LocalCache) |
249 | { | 302 | { |
250 | caps.AppendFormat("*** Neighbours of {0} ({1}) ***\n", kvp.Value.RegionName, kvp.Key); | 303 | foreach (KeyValuePair<UUID, RegionCache> kvp in m_LocalCache) |
251 | List<GridRegion> regions = kvp.Value.GetNeighbours(); | 304 | { |
252 | foreach (GridRegion r in regions) | 305 | caps.AppendFormat("*** Neighbours of {0} ({1}) ***\n", kvp.Value.RegionName, kvp.Key); |
253 | caps.AppendFormat(" {0} @ {1}-{2}\n", r.RegionName, r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize); | 306 | List<GridRegion> regions = kvp.Value.GetNeighbours(); |
307 | foreach (GridRegion r in regions) | ||
308 | caps.AppendFormat(" {0} @ {1}-{2}\n", r.RegionName, Util.WorldToRegionLoc((uint)r.RegionLocX), Util.WorldToRegionLoc((uint)r.RegionLocY)); | ||
309 | } | ||
254 | } | 310 | } |
255 | 311 | ||
256 | MainConsole.Instance.Output(caps.ToString()); | 312 | MainConsole.Instance.Output(caps.ToString()); |
257 | } | 313 | } |
258 | } | 314 | } |
259 | } \ No newline at end of file | 315 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs index 9172536..ae76288 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs | |||
@@ -66,7 +66,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
66 | return; | 66 | return; |
67 | 67 | ||
68 | m_log.DebugFormat("[REGION CACHE]: (on region {0}) Region {1} is up @ {2}-{3}", | 68 | m_log.DebugFormat("[REGION CACHE]: (on region {0}) Region {1} is up @ {2}-{3}", |
69 | m_scene.RegionInfo.RegionName, otherRegion.RegionName, otherRegion.RegionLocX / Constants.RegionSize, otherRegion.RegionLocY / Constants.RegionSize); | 69 | m_scene.RegionInfo.RegionName, otherRegion.RegionName, Util.WorldToRegionLoc((uint)otherRegion.RegionLocX), Util.WorldToRegionLoc((uint)otherRegion.RegionLocY)); |
70 | 70 | ||
71 | m_neighbours[otherRegion.RegionHandle] = otherRegion; | 71 | m_neighbours[otherRegion.RegionHandle] = otherRegion; |
72 | } | 72 | } |
@@ -82,11 +82,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
82 | return new List<GridRegion>(m_neighbours.Values); | 82 | return new List<GridRegion>(m_neighbours.Values); |
83 | } | 83 | } |
84 | 84 | ||
85 | // Get a region given its base coordinates (in meters). | ||
86 | // NOTE: this is NOT 'get a region by some point in the region'. The coordinate MUST | ||
87 | // be the base coordinate of the region. | ||
88 | // The snapping is technically unnecessary but is harmless because regions are always | ||
89 | // multiples of the legacy region size (256). | ||
85 | public GridRegion GetRegionByPosition(int x, int y) | 90 | public GridRegion GetRegionByPosition(int x, int y) |
86 | { | 91 | { |
87 | uint xsnap = (uint)(x / Constants.RegionSize) * Constants.RegionSize; | 92 | uint xsnap = (uint)(x / Constants.RegionSize) * Constants.RegionSize; |
88 | uint ysnap = (uint)(y / Constants.RegionSize) * Constants.RegionSize; | 93 | uint ysnap = (uint)(y / Constants.RegionSize) * Constants.RegionSize; |
89 | ulong handle = Utils.UIntsToLong(xsnap, ysnap); | 94 | ulong handle = Util.RegionWorldLocToHandle(xsnap, ysnap); |
90 | 95 | ||
91 | if (m_neighbours.ContainsKey(handle)) | 96 | if (m_neighbours.ContainsKey(handle)) |
92 | return m_neighbours[handle]; | 97 | return m_neighbours[handle]; |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs index b2646ba..85073fc 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using log4net; | 28 | using log4net; |
29 | using Mono.Addins; | 29 | using Mono.Addins; |
30 | using System; | 30 | using System; |
31 | using System.Collections; | ||
31 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
32 | using System.Reflection; | 33 | using System.Reflection; |
33 | using Nini.Config; | 34 | using Nini.Config; |
@@ -186,18 +187,41 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
186 | return rinfo; | 187 | return rinfo; |
187 | } | 188 | } |
188 | 189 | ||
190 | // Get a region given its base world coordinates (in meters). | ||
191 | // NOTE: this is NOT 'get a region by some point in the region'. The coordinate MUST | ||
192 | // be the base coordinate of the region. | ||
193 | // The coordinates are world coords (meters), NOT region units. | ||
189 | public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) | 194 | public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) |
190 | { | 195 | { |
196 | ulong regionHandle = Util.RegionWorldLocToHandle((uint)x, (uint)y); | ||
197 | uint regionX = Util.WorldToRegionLoc((uint)x); | ||
198 | uint regionY = Util.WorldToRegionLoc((uint)y); | ||
199 | |||
200 | // Sanity check | ||
201 | if ((Util.RegionToWorldLoc(regionX) != (uint)x) || (Util.RegionToWorldLoc(regionY) != (uint)y)) | ||
202 | { | ||
203 | m_log.WarnFormat("[REMOTE GRID CONNECTOR]: GetRegionByPosition. Bad position requested: not the base of the region. Requested Pos=<{0},{1}>, Should Be=<{2},{3}>", | ||
204 | x, y, Util.RegionToWorldLoc(regionX), Util.RegionToWorldLoc(regionY)); | ||
205 | } | ||
206 | |||
191 | bool inCache = false; | 207 | bool inCache = false; |
192 | GridRegion rinfo = m_RegionInfoCache.Get(scopeID, Util.UIntsToLong((uint)x, (uint)y), out inCache); | 208 | GridRegion rinfo = m_RegionInfoCache.Get(scopeID, regionHandle, out inCache); |
193 | if (inCache) | 209 | if (inCache) |
210 | { | ||
211 | //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: GetRegionByPosition. Found region {0} in cache. Pos=<{1},{2}>, RegionHandle={3}", | ||
212 | // (rinfo == null) ? "<missing>" : rinfo.RegionName, regionX, regionY, (rinfo == null) ? regionHandle : rinfo.RegionHandle); | ||
194 | return rinfo; | 213 | return rinfo; |
214 | } | ||
195 | 215 | ||
196 | rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y); | 216 | rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y); |
197 | if (rinfo == null) | 217 | if (rinfo == null) |
198 | rinfo = m_RemoteGridService.GetRegionByPosition(scopeID, x, y); | 218 | rinfo = m_RemoteGridService.GetRegionByPosition(scopeID, x, y); |
199 | 219 | ||
200 | m_RegionInfoCache.Cache(rinfo); | 220 | m_RegionInfoCache.Cache(rinfo); |
221 | |||
222 | //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: GetRegionByPosition. Added region {0} to the cache. Pos=<{1},{2}>, RegionHandle={3}", | ||
223 | // (rinfo == null) ? "<missing>" : rinfo.RegionName, regionX, regionY, (rinfo == null) ? regionHandle : rinfo.RegionHandle); | ||
224 | |||
201 | return rinfo; | 225 | return rinfo; |
202 | } | 226 | } |
203 | 227 | ||
@@ -277,6 +301,26 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
277 | return rinfo; | 301 | return rinfo; |
278 | } | 302 | } |
279 | 303 | ||
304 | public List<GridRegion> GetDefaultHypergridRegions(UUID scopeID) | ||
305 | { | ||
306 | List<GridRegion> rinfo = m_LocalGridService.GetDefaultHypergridRegions(scopeID); | ||
307 | //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Local GetDefaultHypergridRegions {0} found {1} regions", name, rinfo.Count); | ||
308 | List<GridRegion> grinfo = m_RemoteGridService.GetDefaultHypergridRegions(scopeID); | ||
309 | |||
310 | if (grinfo != null) | ||
311 | { | ||
312 | //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Remote GetDefaultHypergridRegions {0} found {1} regions", name, grinfo.Count); | ||
313 | foreach (GridRegion r in grinfo) | ||
314 | { | ||
315 | m_RegionInfoCache.Cache(r); | ||
316 | if (rinfo.Find(delegate(GridRegion gr) { return gr.RegionID == r.RegionID; }) == null) | ||
317 | rinfo.Add(r); | ||
318 | } | ||
319 | } | ||
320 | |||
321 | return rinfo; | ||
322 | } | ||
323 | |||
280 | public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y) | 324 | public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y) |
281 | { | 325 | { |
282 | List<GridRegion> rinfo = m_LocalGridService.GetFallbackRegions(scopeID, x, y); | 326 | List<GridRegion> rinfo = m_LocalGridService.GetFallbackRegions(scopeID, x, y); |
@@ -325,6 +369,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
325 | 369 | ||
326 | return flags; | 370 | return flags; |
327 | } | 371 | } |
372 | |||
373 | public Dictionary<string, object> GetExtraFeatures() | ||
374 | { | ||
375 | Dictionary<string, object> extraFeatures; | ||
376 | extraFeatures = m_LocalGridService.GetExtraFeatures(); | ||
377 | |||
378 | if (extraFeatures.Count == 0) | ||
379 | extraFeatures = m_RemoteGridService.GetExtraFeatures(); | ||
380 | |||
381 | return extraFeatures; | ||
382 | } | ||
328 | #endregion | 383 | #endregion |
329 | } | 384 | } |
330 | } | 385 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs index 4338133..25ae689 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs | |||
@@ -34,6 +34,7 @@ using log4net.Config; | |||
34 | using Nini.Config; | 34 | using Nini.Config; |
35 | using NUnit.Framework; | 35 | using NUnit.Framework; |
36 | using OpenMetaverse; | 36 | using OpenMetaverse; |
37 | |||
37 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
38 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; | 39 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; |
39 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
@@ -141,7 +142,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests | |||
141 | Assert.IsNotNull(result, "Retrieved GetRegionByUUID is null"); | 142 | Assert.IsNotNull(result, "Retrieved GetRegionByUUID is null"); |
142 | Assert.That(result.RegionID, Is.EqualTo(new UUID(1)), "Retrieved region's UUID does not match"); | 143 | Assert.That(result.RegionID, Is.EqualTo(new UUID(1)), "Retrieved region's UUID does not match"); |
143 | 144 | ||
144 | result = m_LocalConnector.GetRegionByPosition(UUID.Zero, 1000 * (int)Constants.RegionSize, 1000 * (int)Constants.RegionSize); | 145 | result = m_LocalConnector.GetRegionByPosition(UUID.Zero, (int)Util.RegionToWorldLoc(1000), (int)Util.RegionToWorldLoc(1000)); |
145 | Assert.IsNotNull(result, "Retrieved GetRegionByPosition is null"); | 146 | Assert.IsNotNull(result, "Retrieved GetRegionByPosition is null"); |
146 | Assert.That(result.RegionLocX, Is.EqualTo(1000 * (int)Constants.RegionSize), "Retrieved region's position does not match"); | 147 | Assert.That(result.RegionLocX, Is.EqualTo(1000 * (int)Constants.RegionSize), "Retrieved region's position does not match"); |
147 | 148 | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs index 221f815..2238c90 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs | |||
@@ -67,10 +67,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser | |||
67 | { | 67 | { |
68 | if (sp.PresenceType != PresenceType.Npc) | 68 | if (sp.PresenceType != PresenceType.Npc) |
69 | { | 69 | { |
70 | string userid = sp.Scene.UserManagementModule.GetUserUUI(sp.UUID); | 70 | string userid; |
71 | //m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected root presence {0} in {1}", userid, sp.Scene.RegionInfo.RegionName); | 71 | //m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected root presence {0} in {1}", userid, sp.Scene.RegionInfo.RegionName); |
72 | m_GridUserService.SetLastPosition( | 72 | if (sp.Scene.UserManagementModule.GetUserUUI(sp.UUID, out userid)) |
73 | userid, UUID.Zero, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); | 73 | { |
74 | /* we only setposition on known agents that have a valid lookup */ | ||
75 | m_GridUserService.SetLastPosition( | ||
76 | userid, UUID.Zero, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); | ||
77 | } | ||
74 | } | 78 | } |
75 | } | 79 | } |
76 | 80 | ||
@@ -81,20 +85,28 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser | |||
81 | 85 | ||
82 | public void OnConnectionClose(IClientAPI client) | 86 | public void OnConnectionClose(IClientAPI client) |
83 | { | 87 | { |
88 | if (client == null) | ||
89 | return; | ||
90 | if (client.SceneAgent == null) | ||
91 | return; | ||
92 | |||
84 | if (client.SceneAgent.IsChildAgent) | 93 | if (client.SceneAgent.IsChildAgent) |
85 | return; | 94 | return; |
86 | 95 | ||
87 | string userId = client.AgentId.ToString(); | 96 | string userId; |
97 | /* without scene we cannot logout correctly at all since we do not know how to send the loggedout message then */ | ||
88 | if (client.Scene is Scene) | 98 | if (client.Scene is Scene) |
89 | { | 99 | { |
90 | Scene s = (Scene)client.Scene; | 100 | Scene s = (Scene)client.Scene; |
91 | userId = s.UserManagementModule.GetUserUUI(client.AgentId); | 101 | userId = s.UserManagementModule.GetUserUUI(client.AgentId); |
102 | if(s.UserManagementModule.GetUserUUI(client.AgentId, out userId)) | ||
103 | { | ||
104 | m_GridUserService.LoggedOut( | ||
105 | userId, client.SessionId, client.Scene.RegionInfo.RegionID, | ||
106 | client.SceneAgent.AbsolutePosition, client.SceneAgent.Lookat); | ||
107 | } | ||
92 | } | 108 | } |
93 | //m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected client logout {0} in {1}", userId, client.Scene.RegionInfo.RegionName); | ||
94 | 109 | ||
95 | m_GridUserService.LoggedOut( | ||
96 | userId, client.SessionId, client.Scene.RegionInfo.RegionID, | ||
97 | client.SceneAgent.AbsolutePosition, client.SceneAgent.Lookat); | ||
98 | } | 110 | } |
99 | } | 111 | } |
100 | } | 112 | } |