aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs148
1 files changed, 78 insertions, 70 deletions
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
index 46b190e..0c22279 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
@@ -132,85 +132,93 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
132 132
133 private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags) 133 private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags)
134 { 134 {
135 List<MapBlockData> blocks = new List<MapBlockData>(); 135 Util.FireAndForget(x =>
136 MapBlockData data;
137 if (mapName.Length < 3 || (mapName.EndsWith("#") && mapName.Length < 4))
138 { 136 {
137 if (mapName.Length < 2)
138 {
139 remoteClient.SendAlertMessage("Use a search string with at least 2 characters");
140 return;
141 }
142
143 //m_log.DebugFormat("MAP NAME=({0})", mapName);
144
145 // Hack to get around the fact that ll V3 now drops the port from the
146 // map name. See https://jira.secondlife.com/browse/VWR-28570
147 //
148 // Caller, use this magic form instead:
149 // secondlife://http|!!mygrid.com|8002|Region+Name/128/128
150 // or url encode if possible.
151 // the hacks we do with this viewer...
152 //
153 string mapNameOrig = mapName;
154 if (mapName.Contains("|"))
155 mapName = mapName.Replace('|', ':');
156 if (mapName.Contains("+"))
157 mapName = mapName.Replace('+', ' ');
158 if (mapName.Contains("!"))
159 mapName = mapName.Replace('!', '/');
160
161 // try to fetch from GridServer
162 List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20);
163 // if (regionInfos.Count == 0)
164 // remoteClient.SendAlertMessage("Hyperlink could not be established.");
165
166 //m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions", mapName, regionInfos.Count);
167 List<MapBlockData> blocks = new List<MapBlockData>();
168
169 MapBlockData data;
170 if (regionInfos.Count > 0)
171 {
172 foreach (GridRegion info in regionInfos)
173 {
174 data = new MapBlockData();
175 data.Agents = 0;
176 data.Access = info.Access;
177 if (flags == 2) // V2 sends this
178 data.MapImageId = UUID.Zero;
179 else
180 data.MapImageId = info.TerrainImage;
181 // ugh! V2-3 is very sensitive about the result being
182 // exactly the same as the requested name
183 if (regionInfos.Count == 1 && mapNameOrig.Contains("|") || mapNameOrig.Contains("+"))
184 data.Name = mapNameOrig;
185 else
186 data.Name = info.RegionName;
187 data.RegionFlags = 0; // TODO not used?
188 data.WaterHeight = 0; // not used
189 data.X = (ushort)(info.RegionLocX / Constants.RegionSize);
190 data.Y = (ushort)(info.RegionLocY / Constants.RegionSize);
191 blocks.Add(data);
192 }
193 }
194
139 // final block, closing the search result 195 // final block, closing the search result
140 AddFinalBlock(blocks); 196 data = new MapBlockData();
197 data.Agents = 0;
198 data.Access = 255;
199 data.MapImageId = UUID.Zero;
200 data.Name = mapName;
201 data.RegionFlags = 0;
202 data.WaterHeight = 0; // not used
203 data.X = 0;
204 data.Y = 0;
205 blocks.Add(data);
141 206
142 // flags are agent flags sent from the viewer. 207 // flags are agent flags sent from the viewer.
143 // they have different values depending on different viewers, apparently 208 // they have different values depending on different viewers, apparently
144 remoteClient.SendMapBlock(blocks, flags); 209 remoteClient.SendMapBlock(blocks, flags);
145 remoteClient.SendAlertMessage("Use a search string with at least 3 characters");
146 return;
147 }
148 210
149 211 // send extra user messages for V3
150 //m_log.DebugFormat("MAP NAME=({0})", mapName); 212 // because the UI is very confusing
151 213 // while we don't fix the hard-coded urls
152 // Hack to get around the fact that ll V3 now drops the port from the 214 if (flags == 2)
153 // map name. See https://jira.secondlife.com/browse/VWR-28570
154 //
155 // Caller, use this magic form instead:
156 // secondlife://http|!!mygrid.com|8002|Region+Name/128/128
157 // or url encode if possible.
158 // the hacks we do with this viewer...
159 //
160 string mapNameOrig = mapName;
161 if (mapName.Contains("|"))
162 mapName = mapName.Replace('|', ':');
163 if (mapName.Contains("+"))
164 mapName = mapName.Replace('+', ' ');
165 if (mapName.Contains("!"))
166 mapName = mapName.Replace('!', '/');
167
168 // try to fetch from GridServer
169 List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20);
170
171 m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions. Flags={2}", mapName, regionInfos.Count, flags);
172 if (regionInfos.Count > 0)
173 {
174 foreach (GridRegion info in regionInfos)
175 { 215 {
176 data = new MapBlockData(); 216 if (regionInfos.Count == 0)
177 data.Agents = 0; 217 remoteClient.SendAgentAlertMessage("No regions found with that name.", true);
178 data.Access = info.Access; 218 else if (regionInfos.Count == 1)
179 if (flags == 2) // V2 sends this 219 remoteClient.SendAgentAlertMessage("Region found!", false);
180 data.MapImageId = UUID.Zero;
181 else
182 data.MapImageId = info.TerrainImage;
183 // ugh! V2-3 is very sensitive about the result being
184 // exactly the same as the requested name
185 if (regionInfos.Count == 1 && mapNameOrig.Contains("|") || mapNameOrig.Contains("+"))
186 data.Name = mapNameOrig;
187 else
188 data.Name = info.RegionName;
189 data.RegionFlags = 0; // TODO not used?
190 data.WaterHeight = 0; // not used
191 data.X = (ushort)(info.RegionLocX / Constants.RegionSize);
192 data.Y = (ushort)(info.RegionLocY / Constants.RegionSize);
193 blocks.Add(data);
194 } 220 }
195 } 221 });
196
197 // final block, closing the search result
198 AddFinalBlock(blocks);
199
200 // flags are agent flags sent from the viewer.
201 // they have different values depending on different viewers, apparently
202 remoteClient.SendMapBlock(blocks, flags);
203
204 // send extra user messages for V3
205 // because the UI is very confusing
206 // while we don't fix the hard-coded urls
207 if (flags == 2)
208 {
209 if (regionInfos.Count == 0)
210 remoteClient.SendAlertMessage("No regions found with that name.");
211 else if (regionInfos.Count == 1)
212 remoteClient.SendAlertMessage("Region found!");
213 }
214 } 222 }
215 223
216 private void AddFinalBlock(List<MapBlockData> blocks) 224 private void AddFinalBlock(List<MapBlockData> blocks)