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