diff options
author | UbitUmarov | 2018-06-16 14:11:44 +0100 |
---|---|---|
committer | UbitUmarov | 2018-06-16 14:11:44 +0100 |
commit | ba193fc60653ebf5031d679bf8617c335078bf97 (patch) | |
tree | 8d8723d9d44c7e91d87f65764e95c83d5bcf48a8 /OpenSim | |
parent | improve llOverMyLand() handling of potencial null refs. ty mrieker (diff) | |
download | opensim-SC-ba193fc60653ebf5031d679bf8617c335078bf97.zip opensim-SC-ba193fc60653ebf5031d679bf8617c335078bf97.tar.gz opensim-SC-ba193fc60653ebf5031d679bf8617c335078bf97.tar.bz2 opensim-SC-ba193fc60653ebf5031d679bf8617c335078bf97.tar.xz |
minor cleanup
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 48 |
1 files changed, 12 insertions, 36 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 2334e0b..e1145a1 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -1479,9 +1479,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1479 | 1479 | ||
1480 | 1480 | ||
1481 | // Given a position relative to the current region and outside of it | 1481 | // Given a position relative to the current region and outside of it |
1482 | // find the new region that the point is actually in. | 1482 | // find the new region that the point is actually in |
1483 | // returns 'null' if new region not found or if information | 1483 | // returns 'null' if new region not found or if agent as no access |
1484 | // and new position relative to it | 1484 | // else also returns new target position in the new region local coords |
1485 | // now only works for crossings | 1485 | // now only works for crossings |
1486 | 1486 | ||
1487 | public GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, | 1487 | public GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, |
@@ -1500,8 +1500,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1500 | // Call the grid service to lookup the region containing the new position. | 1500 | // Call the grid service to lookup the region containing the new position. |
1501 | GridRegion neighbourRegion = GetRegionContainingWorldLocation( | 1501 | GridRegion neighbourRegion = GetRegionContainingWorldLocation( |
1502 | scene.GridService, scene.RegionInfo.ScopeID, | 1502 | scene.GridService, scene.RegionInfo.ScopeID, |
1503 | presenceWorldX, presenceWorldY, | 1503 | presenceWorldX, presenceWorldY); |
1504 | Math.Max(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY)); | ||
1505 | 1504 | ||
1506 | if (neighbourRegion == null) | 1505 | if (neighbourRegion == null) |
1507 | return null; | 1506 | return null; |
@@ -2277,68 +2276,46 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2277 | 2276 | ||
2278 | protected GridRegion GetRegionContainingWorldLocation(IGridService pGridService, UUID pScopeID, double px, double py) | 2277 | protected GridRegion GetRegionContainingWorldLocation(IGridService pGridService, UUID pScopeID, double px, double py) |
2279 | { | 2278 | { |
2280 | // Since we don't know how big the regions could be, we have to search a very large area | 2279 | // Given a world position, get the GridRegion info for |
2281 | // to find possible regions. | 2280 | // the region containing that point. |
2282 | return GetRegionContainingWorldLocation(pGridService, pScopeID, px, py, Constants.MaximumRegionSize); | 2281 | // for compatibility with old grids it does a scan to find large regions |
2283 | } | 2282 | // 0.9 grids to that |
2284 | |||
2285 | // Given a world position, get the GridRegion info for | ||
2286 | // the region containing that point. | ||
2287 | // for compatibility with old grids it does a scan to find large regions | ||
2288 | // 0.9 grids to that | ||
2289 | |||
2290 | protected GridRegion GetRegionContainingWorldLocation(IGridService pGridService, UUID pScopeID, | ||
2291 | double px, double py, uint pSizeHint) | ||
2292 | { | ||
2293 | // m_log.DebugFormat("{0} GetRegionContainingWorldLocation: call, XY=<{1},{2}>", LogHeader, px, py); | 2283 | // m_log.DebugFormat("{0} GetRegionContainingWorldLocation: call, XY=<{1},{2}>", LogHeader, px, py); |
2294 | GridRegion ret = null; | 2284 | GridRegion ret = null; |
2295 | 2285 | ||
2286 | // check if we already found it does not exist | ||
2296 | if (m_notFoundLocationCache.Contains(px, py)) | 2287 | if (m_notFoundLocationCache.Contains(px, py)) |
2297 | { | ||
2298 | // m_log.DebugFormat("{0} GetRegionContainingWorldLocation: Not found via cache. loc=<{1},{2}>", LogHeader, px, py); | ||
2299 | return null; | 2288 | return null; |
2300 | } | ||
2301 | 2289 | ||
2302 | // As an optimization, since most regions will be legacy sized regions (256x256), first try to get | 2290 | // reduce to next grid corner |
2303 | // the region at the appropriate legacy region location. | ||
2304 | // this is all that is needed on 0.9 grids | 2291 | // this is all that is needed on 0.9 grids |
2305 | uint possibleX = (uint)px & 0xffffff00u; | 2292 | uint possibleX = (uint)px & 0xffffff00u; |
2306 | uint possibleY = (uint)py & 0xffffff00u; | 2293 | uint possibleY = (uint)py & 0xffffff00u; |
2307 | ret = pGridService.GetRegionByPosition(pScopeID, (int)possibleX, (int)possibleY); | 2294 | ret = pGridService.GetRegionByPosition(pScopeID, (int)possibleX, (int)possibleY); |
2308 | if (ret != null) | 2295 | if (ret != null) |
2309 | { | ||
2310 | // m_log.DebugFormat("{0} GetRegionContainingWorldLocation: Found region using legacy size. rloc=<{1},{2}>. Rname={3}", | ||
2311 | // LogHeader, possibleX, possibleY, ret.RegionName); | ||
2312 | return ret; | 2296 | return ret; |
2313 | } | 2297 | |
2314 | |||
2315 | // for 0.8 regions just make a BIG area request. old code whould do it plus 4 more smaller on region open edges | 2298 | // for 0.8 regions just make a BIG area request. old code whould do it plus 4 more smaller on region open edges |
2316 | // this is what 0.9 grids now do internally | 2299 | // this is what 0.9 grids now do internally |
2317 | List<GridRegion> possibleRegions = pGridService.GetRegionRange(pScopeID, | 2300 | List<GridRegion> possibleRegions = pGridService.GetRegionRange(pScopeID, |
2318 | (int)(px - Constants.MaximumRegionSize), (int)(px + 1), // +1 bc left mb not part of range | 2301 | (int)(px - Constants.MaximumRegionSize), (int)(px + 1), // +1 bc left mb not part of range |
2319 | (int)(py - Constants.MaximumRegionSize), (int)(py + 1)); | 2302 | (int)(py - Constants.MaximumRegionSize), (int)(py + 1)); |
2320 | // m_log.DebugFormat("{0} GetRegionContainingWorldLocation: possibleRegions cnt={1}, range={2}", | ||
2321 | // LogHeader, possibleRegions.Count, range); | ||
2322 | if (possibleRegions != null && possibleRegions.Count > 0) | 2303 | if (possibleRegions != null && possibleRegions.Count > 0) |
2323 | { | 2304 | { |
2324 | // If we found some regions, check to see if the point is within | 2305 | // If we found some regions, check to see if the point is within |
2325 | foreach (GridRegion gr in possibleRegions) | 2306 | foreach (GridRegion gr in possibleRegions) |
2326 | { | 2307 | { |
2327 | // m_log.DebugFormat("{0} GetRegionContainingWorldLocation: possibleRegion nm={1}, regionLoc=<{2},{3}>, regionSize=<{4},{5}>", | ||
2328 | // LogHeader, gr.RegionName, gr.RegionLocX, gr.RegionLocY, gr.RegionSizeX, gr.RegionSizeY); | ||
2329 | if (px >= (double)gr.RegionLocX && px < (double)(gr.RegionLocX + gr.RegionSizeX) | 2308 | if (px >= (double)gr.RegionLocX && px < (double)(gr.RegionLocX + gr.RegionSizeX) |
2330 | && py >= (double)gr.RegionLocY && py < (double)(gr.RegionLocY + gr.RegionSizeY)) | 2309 | && py >= (double)gr.RegionLocY && py < (double)(gr.RegionLocY + gr.RegionSizeY)) |
2331 | { | 2310 | { |
2332 | // Found a region that contains the point | 2311 | // Found a region that contains the point |
2333 | return gr; | 2312 | return gr; |
2334 | // m_log.DebugFormat("{0} GetRegionContainingWorldLocation: found. RegionName={1}", LogHeader, ret.RegionName); | ||
2335 | } | 2313 | } |
2336 | } | 2314 | } |
2337 | } | 2315 | } |
2338 | 2316 | ||
2339 | // remember this location was not found so we can quickly not find it next time | 2317 | // remember this location was not found so we can quickly not find it next time |
2340 | m_notFoundLocationCache.Add(px, py); | 2318 | m_notFoundLocationCache.Add(px, py); |
2341 | // m_log.DebugFormat("{0} GetRegionContainingWorldLocation: Not found. Remembering loc=<{1},{2}>", LogHeader, px, py); | ||
2342 | return null; | 2319 | return null; |
2343 | } | 2320 | } |
2344 | 2321 | ||
@@ -2362,7 +2339,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2362 | private void InformClientOfNeighbourAsync(ScenePresence sp, AgentCircuitData agentCircData, GridRegion reg, | 2339 | private void InformClientOfNeighbourAsync(ScenePresence sp, AgentCircuitData agentCircData, GridRegion reg, |
2363 | IPEndPoint endPoint, bool newAgent) | 2340 | IPEndPoint endPoint, bool newAgent) |
2364 | { | 2341 | { |
2365 | |||
2366 | if (newAgent) | 2342 | if (newAgent) |
2367 | { | 2343 | { |
2368 | // we may already had lost this sp | 2344 | // we may already had lost this sp |
@@ -2435,7 +2411,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2435 | 2411 | ||
2436 | uint dd = (uint)avatar.RegionViewDistance; | 2412 | uint dd = (uint)avatar.RegionViewDistance; |
2437 | 2413 | ||
2438 | // until avatar movement updates client connections, we need to seend at least this current region imediate neighbors | 2414 | // until avatar movement updates client connections, we need to send at least this current region immediate neighbors |
2439 | uint ddX = Math.Max(dd, Constants.RegionSize); | 2415 | uint ddX = Math.Max(dd, Constants.RegionSize); |
2440 | uint ddY = Math.Max(dd, Constants.RegionSize); | 2416 | uint ddY = Math.Max(dd, Constants.RegionSize); |
2441 | 2417 | ||