diff options
author | UbitUmarov | 2015-09-12 15:27:36 +0100 |
---|---|---|
committer | UbitUmarov | 2015-09-12 15:27:36 +0100 |
commit | 280780d3bc6bb81540043cf804d9e3294151e290 (patch) | |
tree | d9d92f8662e06a497aa219c30f1952ef1b21fc68 /OpenSim/Region | |
parent | try to be more friendly to HG (diff) | |
download | opensim-SC-280780d3bc6bb81540043cf804d9e3294151e290.zip opensim-SC-280780d3bc6bb81540043cf804d9e3294151e290.tar.gz opensim-SC-280780d3bc6bb81540043cf804d9e3294151e290.tar.bz2 opensim-SC-280780d3bc6bb81540043cf804d9e3294151e290.tar.xz |
let regionCache really find a varregion by a position
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs index ae76288..7ae4771 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs | |||
@@ -82,21 +82,34 @@ 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). | 85 | |
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). | ||
90 | public GridRegion GetRegionByPosition(int x, int y) | 86 | public GridRegion GetRegionByPosition(int x, int y) |
91 | { | 87 | { |
92 | uint xsnap = (uint)(x / Constants.RegionSize) * Constants.RegionSize; | 88 | /* |
93 | uint ysnap = (uint)(y / Constants.RegionSize) * Constants.RegionSize; | 89 | uint xsnap = (uint)(x / Constants.RegionSize) * Constants.RegionSize; |
94 | ulong handle = Util.RegionWorldLocToHandle(xsnap, ysnap); | 90 | uint ysnap = (uint)(y / Constants.RegionSize) * Constants.RegionSize; |
95 | 91 | ulong handle = Util.RegionWorldLocToHandle(xsnap, ysnap); | |
96 | if (m_neighbours.ContainsKey(handle)) | 92 | |
97 | return m_neighbours[handle]; | 93 | if (m_neighbours.ContainsKey(handle)) |
98 | 94 | return m_neighbours[handle]; | |
99 | return null; | 95 | |
96 | return null; | ||
97 | */ | ||
98 | |||
99 | // do actual search by position | ||
100 | // not the best, but this will not hold that many regions | ||
101 | GridRegion foundRegion = null; | ||
102 | foreach(GridRegion r in m_neighbours.Values) | ||
103 | { | ||
104 | if (x >= r.RegionLocX && x < r.RegionLocX + r.RegionSizeX | ||
105 | && y >= r.RegionLocY && y < r.RegionLocY + r.RegionSizeY) | ||
106 | { | ||
107 | foundRegion = r; | ||
108 | break; | ||
109 | } | ||
110 | } | ||
111 | |||
112 | return foundRegion; | ||
100 | } | 113 | } |
101 | } | 114 | } |
102 | } | 115 | } |