diff options
Diffstat (limited to '')
-rw-r--r-- | OpenGridServices.GridServer/GridManager.cs | 74 |
1 files changed, 61 insertions, 13 deletions
diff --git a/OpenGridServices.GridServer/GridManager.cs b/OpenGridServices.GridServer/GridManager.cs index cfccd02..77c22e5 100644 --- a/OpenGridServices.GridServer/GridManager.cs +++ b/OpenGridServices.GridServer/GridManager.cs | |||
@@ -90,6 +90,31 @@ namespace OpenGridServices.GridServer | |||
90 | return null; | 90 | return null; |
91 | } | 91 | } |
92 | 92 | ||
93 | public Dictionary<ulong, SimProfileData> getRegions(uint xmin, uint ymin, uint xmax, uint ymax) | ||
94 | { | ||
95 | Dictionary<ulong, SimProfileData> regions = new Dictionary<ulong, SimProfileData>(); | ||
96 | |||
97 | SimProfileData[] neighbours; | ||
98 | |||
99 | foreach (KeyValuePair<string, IGridData> kvp in _plugins) | ||
100 | { | ||
101 | try | ||
102 | { | ||
103 | neighbours = kvp.Value.GetProfilesInRange(xmin, ymin, xmax, ymax); | ||
104 | foreach (SimProfileData neighbour in neighbours) | ||
105 | { | ||
106 | regions[neighbour.regionHandle] = neighbour; | ||
107 | } | ||
108 | } | ||
109 | catch (Exception e) | ||
110 | { | ||
111 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.NORMAL, "Storage: Unable to query regionblock via " + kvp.Key); | ||
112 | } | ||
113 | } | ||
114 | |||
115 | return regions; | ||
116 | } | ||
117 | |||
93 | /// <summary> | 118 | /// <summary> |
94 | /// Returns a XML String containing a list of the neighbouring regions | 119 | /// Returns a XML String containing a list of the neighbouring regions |
95 | /// </summary> | 120 | /// </summary> |
@@ -152,22 +177,45 @@ namespace OpenGridServices.GridServer | |||
152 | 177 | ||
153 | SimProfileData neighbour; | 178 | SimProfileData neighbour; |
154 | Hashtable NeighbourBlock; | 179 | Hashtable NeighbourBlock; |
155 | for (int x = -1; x < 2; x++) for (int y = -1; y < 2; y++) | ||
156 | { | ||
157 | if (getRegion(Helpers.UIntsToLong((uint)((TheSim.regionLocX + x) * 256), (uint)(TheSim.regionLocY + y) * 256)) != null) | ||
158 | { | ||
159 | neighbour = getRegion(Helpers.UIntsToLong((uint)((TheSim.regionLocX + x) * 256), (uint)(TheSim.regionLocY + y) * 256)); | ||
160 | 180 | ||
161 | NeighbourBlock = new Hashtable(); | 181 | bool fastMode = false; // Only compatible with MySQL right now |
162 | NeighbourBlock["sim_ip"] = neighbour.serverIP; | ||
163 | NeighbourBlock["sim_port"] = neighbour.serverPort.ToString(); | ||
164 | NeighbourBlock["region_locx"] = neighbour.regionLocX.ToString(); | ||
165 | NeighbourBlock["region_locy"] = neighbour.regionLocY.ToString(); | ||
166 | NeighbourBlock["UUID"] = neighbour.UUID.ToString(); | ||
167 | 182 | ||
168 | if (neighbour.UUID != TheSim.UUID) SimNeighboursData.Add(NeighbourBlock); | 183 | if (fastMode) |
169 | } | 184 | { |
185 | Dictionary<ulong, SimProfileData> neighbours = getRegions(TheSim.regionLocX - 256, TheSim.regionLocY - 256, TheSim.regionLocX + 256, TheSim.regionLocY + 256); | ||
186 | |||
187 | foreach (KeyValuePair<ulong, SimProfileData> aSim in neighbours) | ||
188 | { | ||
189 | NeighbourBlock = new Hashtable(); | ||
190 | NeighbourBlock["sim_ip"] = aSim.Value.serverIP.ToString(); | ||
191 | NeighbourBlock["sim_port"] = aSim.Value.serverPort.ToString(); | ||
192 | NeighbourBlock["region_locx"] = aSim.Value.regionLocX.ToString(); | ||
193 | NeighbourBlock["region_locy"] = aSim.Value.regionLocY.ToString(); | ||
194 | NeighbourBlock["UUID"] = aSim.Value.UUID.ToString(); | ||
195 | |||
196 | if (aSim.Value.UUID != TheSim.UUID) | ||
197 | SimNeighboursData.Add(NeighbourBlock); | ||
170 | } | 198 | } |
199 | } | ||
200 | else | ||
201 | { | ||
202 | for (int x = -1; x < 2; x++) for (int y = -1; y < 2; y++) | ||
203 | { | ||
204 | if (getRegion(Helpers.UIntsToLong((uint)((TheSim.regionLocX + x) * 256), (uint)(TheSim.regionLocY + y) * 256)) != null) | ||
205 | { | ||
206 | neighbour = getRegion(Helpers.UIntsToLong((uint)((TheSim.regionLocX + x) * 256), (uint)(TheSim.regionLocY + y) * 256)); | ||
207 | |||
208 | NeighbourBlock = new Hashtable(); | ||
209 | NeighbourBlock["sim_ip"] = neighbour.serverIP; | ||
210 | NeighbourBlock["sim_port"] = neighbour.serverPort.ToString(); | ||
211 | NeighbourBlock["region_locx"] = neighbour.regionLocX.ToString(); | ||
212 | NeighbourBlock["region_locy"] = neighbour.regionLocY.ToString(); | ||
213 | NeighbourBlock["UUID"] = neighbour.UUID.ToString(); | ||
214 | |||
215 | if (neighbour.UUID != TheSim.UUID) SimNeighboursData.Add(NeighbourBlock); | ||
216 | } | ||
217 | } | ||
218 | } | ||
171 | 219 | ||
172 | responseData["UUID"] = TheSim.UUID.ToString(); | 220 | responseData["UUID"] = TheSim.UUID.ToString(); |
173 | responseData["region_locx"] = TheSim.regionLocX.ToString(); | 221 | responseData["region_locx"] = TheSim.regionLocX.ToString(); |