diff options
author | onefang | 2019-09-11 16:36:50 +1000 |
---|---|---|
committer | onefang | 2019-09-11 16:36:50 +1000 |
commit | 50cd1ffd32f69228e566f2b0b89f86ea0d9fe489 (patch) | |
tree | 52f2ab0c04f1a5d7d6ac5dc872981b4b156447e7 /OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs | |
parent | Renamed branch to SledjChisl. (diff) | |
parent | Bump to release flavour, build 0. (diff) | |
download | opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.zip opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.gz opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.bz2 opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.xz |
Merge branch 'SledjChisl'
Diffstat (limited to 'OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs | 167 |
1 files changed, 87 insertions, 80 deletions
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index d862f18..5876df3 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs | |||
@@ -128,109 +128,116 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
128 | m_Clients.Add(remoteClient.AgentId); | 128 | m_Clients.Add(remoteClient.AgentId); |
129 | } | 129 | } |
130 | 130 | ||
131 | try | 131 | OnMapNameRequest(remoteClient, mapName, flags); |
132 | { | ||
133 | OnMapNameRequest(remoteClient, mapName, flags); | ||
134 | } | ||
135 | finally | ||
136 | { | ||
137 | lock (m_Clients) | ||
138 | m_Clients.Remove(remoteClient.AgentId); | ||
139 | } | ||
140 | } | 132 | } |
141 | 133 | ||
142 | private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags) | 134 | private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags) |
143 | { | 135 | { |
144 | List<MapBlockData> blocks = new List<MapBlockData>(); | 136 | Util.FireAndForget(x => |
145 | if (mapName.Length < 3 || (mapName.EndsWith("#") && mapName.Length < 4)) | ||
146 | { | 137 | { |
147 | // final block, closing the search result | 138 | try |
148 | AddFinalBlock(blocks); | 139 | { |
140 | List<MapBlockData> blocks = new List<MapBlockData>(); | ||
141 | if (mapName.Length < 3 || (mapName.EndsWith("#") && mapName.Length < 4)) | ||
142 | { | ||
143 | // final block, closing the search result | ||
144 | AddFinalBlock(blocks,mapName); | ||
149 | 145 | ||
150 | // flags are agent flags sent from the viewer. | 146 | // flags are agent flags sent from the viewer. |
151 | // they have different values depending on different viewers, apparently | 147 | // they have different values depending on different viewers, apparently |
152 | remoteClient.SendMapBlock(blocks, flags); | 148 | remoteClient.SendMapBlock(blocks, flags); |
153 | remoteClient.SendAlertMessage("Use a search string with at least 3 characters"); | 149 | remoteClient.SendAlertMessage("Use a search string with at least 3 characters"); |
154 | return; | 150 | return; |
155 | } | 151 | } |
156 | 152 | ||
153 | //m_log.DebugFormat("MAP NAME=({0})", mapName); | ||
157 | 154 | ||
158 | List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); | 155 | // Hack to get around the fact that ll V3 now drops the port from the |
159 | 156 | // map name. See https://jira.secondlife.com/browse/VWR-28570 | |
160 | string mapNameOrig = mapName; | 157 | // |
161 | if (regionInfos.Count == 0) | 158 | // Caller, use this magic form instead: |
162 | { | 159 | // secondlife://http|!!mygrid.com|8002|Region+Name/128/128 |
163 | // Hack to get around the fact that ll V3 now drops the port from the | 160 | // or url encode if possible. |
164 | // map name. See https://jira.secondlife.com/browse/VWR-28570 | 161 | // the hacks we do with this viewer... |
165 | // | 162 | // |
166 | // Caller, use this magic form instead: | 163 | bool needOriginalName = false; |
167 | // secondlife://http|!!mygrid.com|8002|Region+Name/128/128 | 164 | string mapNameOrig = mapName; |
168 | // or url encode if possible. | 165 | if (mapName.Contains("|")) |
169 | // the hacks we do with this viewer... | ||
170 | // | ||
171 | if (mapName.Contains("|")) | ||
172 | mapName = mapName.Replace('|', ':'); | ||
173 | if (mapName.Contains("+")) | ||
174 | mapName = mapName.Replace('+', ' '); | ||
175 | if (mapName.Contains("!")) | ||
176 | mapName = mapName.Replace('!', '/'); | ||
177 | |||
178 | if (mapName != mapNameOrig) | ||
179 | regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); | ||
180 | } | ||
181 | |||
182 | m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions. Flags={2}", mapName, regionInfos.Count, flags); | ||
183 | |||
184 | if (regionInfos.Count > 0) | ||
185 | { | ||
186 | foreach (GridRegion info in regionInfos) | ||
187 | { | ||
188 | if ((flags & 2) == 2) // V2 sends this | ||
189 | { | 166 | { |
190 | List<MapBlockData> datas = WorldMap.Map2BlockFromGridRegion(info, flags); | 167 | mapName = mapName.Replace('|', ':'); |
191 | // ugh! V2-3 is very sensitive about the result being | 168 | needOriginalName = true; |
192 | // exactly the same as the requested name | ||
193 | if (regionInfos.Count == 1 && (mapName != mapNameOrig)) | ||
194 | datas.ForEach(d => d.Name = mapNameOrig); | ||
195 | |||
196 | blocks.AddRange(datas); | ||
197 | } | 169 | } |
198 | else | 170 | if (mapName.Contains("+")) |
199 | { | 171 | { |
200 | MapBlockData data = WorldMap.MapBlockFromGridRegion(info, flags); | 172 | mapName = mapName.Replace('+', ' '); |
201 | blocks.Add(data); | 173 | needOriginalName = true; |
202 | } | 174 | } |
203 | } | 175 | if (mapName.Contains("!")) |
204 | } | 176 | { |
177 | mapName = mapName.Replace('!', '/'); | ||
178 | needOriginalName = true; | ||
179 | } | ||
180 | if (mapName.Contains(".")) | ||
181 | needOriginalName = true; | ||
205 | 182 | ||
206 | // final block, closing the search result | 183 | // try to fetch from GridServer |
207 | AddFinalBlock(blocks); | 184 | List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); |
185 | // if (regionInfos.Count == 0) | ||
186 | // remoteClient.SendAlertMessage("Hyperlink could not be established."); | ||
208 | 187 | ||
209 | // flags are agent flags sent from the viewer. | 188 | //m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions", mapName, regionInfos.Count); |
210 | // they have different values depending on different viewers, apparently | ||
211 | remoteClient.SendMapBlock(blocks, flags); | ||
212 | 189 | ||
213 | // send extra user messages for V3 | 190 | MapBlockData data; |
214 | // because the UI is very confusing | 191 | if (regionInfos != null && regionInfos.Count > 0) |
215 | // while we don't fix the hard-coded urls | 192 | { |
216 | if (flags == 2) | 193 | foreach (GridRegion info in regionInfos) |
217 | { | 194 | { |
218 | if (regionInfos.Count == 0) | 195 | data = new MapBlockData(); |
219 | remoteClient.SendAlertMessage("No regions found with that name."); | 196 | data.Agents = 0; |
220 | // this seems unnecessary because found regions will show up in the search results | 197 | data.Access = info.Access; |
221 | //else if (regionInfos.Count == 1) | 198 | MapBlockData block = new MapBlockData(); |
222 | // remoteClient.SendAlertMessage("Region found!"); | 199 | WorldMap.MapBlockFromGridRegion(block, info, flags); |
223 | } | 200 | |
201 | if (flags == 2 && regionInfos.Count == 1 && needOriginalName) | ||
202 | block.Name = mapNameOrig; | ||
203 | blocks.Add(block); | ||
204 | } | ||
205 | } | ||
206 | |||
207 | // final block, closing the search result | ||
208 | AddFinalBlock(blocks,mapNameOrig); | ||
209 | |||
210 | // flags are agent flags sent from the viewer. | ||
211 | // they have different values depending on different viewers, apparently | ||
212 | remoteClient.SendMapBlock(blocks, flags); | ||
213 | |||
214 | // send extra user messages for V3 | ||
215 | // because the UI is very confusing | ||
216 | // while we don't fix the hard-coded urls | ||
217 | if (flags == 2) | ||
218 | { | ||
219 | if (regionInfos == null || regionInfos.Count == 0) | ||
220 | remoteClient.SendAgentAlertMessage("No regions found with that name.", true); | ||
221 | // else if (regionInfos.Count == 1) | ||
222 | // remoteClient.SendAgentAlertMessage("Region found!", false); | ||
223 | } | ||
224 | } | ||
225 | finally | ||
226 | { | ||
227 | lock (m_Clients) | ||
228 | m_Clients.Remove(remoteClient.AgentId); | ||
229 | } | ||
230 | }); | ||
224 | } | 231 | } |
225 | 232 | ||
226 | private void AddFinalBlock(List<MapBlockData> blocks) | 233 | private void AddFinalBlock(List<MapBlockData> blocks,string name) |
227 | { | 234 | { |
228 | // final block, closing the search result | 235 | // final block, closing the search result |
229 | MapBlockData data = new MapBlockData(); | 236 | MapBlockData data = new MapBlockData(); |
230 | data.Agents = 0; | 237 | data.Agents = 0; |
231 | data.Access = (byte)SimAccess.NonExistent; | 238 | data.Access = (byte)SimAccess.NonExistent; |
232 | data.MapImageId = UUID.Zero; | 239 | data.MapImageId = UUID.Zero; |
233 | data.Name = ""; | 240 | data.Name = name; |
234 | data.RegionFlags = 0; | 241 | data.RegionFlags = 0; |
235 | data.WaterHeight = 0; // not used | 242 | data.WaterHeight = 0; // not used |
236 | data.X = 0; | 243 | data.X = 0; |