diff options
author | UbitUmarov | 2016-11-28 06:02:47 +0000 |
---|---|---|
committer | UbitUmarov | 2016-11-28 06:02:47 +0000 |
commit | ebbb9184041239cdd3a5de7d3b4094359c4bf02a (patch) | |
tree | 952856755cb2895761d6aa672287e0f89f233f71 | |
parent | update httpserver dll fixing a memory leak (diff) | |
parent | change last patch a bit (diff) | |
download | opensim-SC-ebbb9184041239cdd3a5de7d3b4094359c4bf02a.zip opensim-SC-ebbb9184041239cdd3a5de7d3b4094359c4bf02a.tar.gz opensim-SC-ebbb9184041239cdd3a5de7d3b4094359c4bf02a.tar.bz2 opensim-SC-ebbb9184041239cdd3a5de7d3b4094359c4bf02a.tar.xz |
Merge branch 'master' into httptests
Diffstat (limited to '')
5 files changed, 314 insertions, 136 deletions
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index 7370156..b1234fe 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs | |||
@@ -128,104 +128,104 @@ 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 | Util.FireAndForget(x => | 136 | Util.FireAndForget(x => |
145 | { | 137 | { |
146 | List<MapBlockData> blocks = new List<MapBlockData>(); | 138 | try |
147 | if (mapName.Length < 3 || (mapName.EndsWith("#") && mapName.Length < 4)) | ||
148 | { | 139 | { |
149 | // final block, closing the search result | 140 | List<MapBlockData> blocks = new List<MapBlockData>(); |
150 | AddFinalBlock(blocks,mapName); | 141 | if (mapName.Length < 3 || (mapName.EndsWith("#") && mapName.Length < 4)) |
142 | { | ||
143 | // final block, closing the search result | ||
144 | AddFinalBlock(blocks,mapName); | ||
151 | 145 | ||
152 | // flags are agent flags sent from the viewer. | 146 | // flags are agent flags sent from the viewer. |
153 | // they have different values depending on different viewers, apparently | 147 | // they have different values depending on different viewers, apparently |
154 | remoteClient.SendMapBlock(blocks, flags); | 148 | remoteClient.SendMapBlock(blocks, flags); |
155 | remoteClient.SendAlertMessage("Use a search string with at least 3 characters"); | 149 | remoteClient.SendAlertMessage("Use a search string with at least 3 characters"); |
156 | return; | 150 | return; |
157 | } | 151 | } |
158 | 152 | ||
159 | //m_log.DebugFormat("MAP NAME=({0})", mapName); | 153 | //m_log.DebugFormat("MAP NAME=({0})", mapName); |
160 | 154 | ||
161 | // Hack to get around the fact that ll V3 now drops the port from the | 155 | // Hack to get around the fact that ll V3 now drops the port from the |
162 | // map name. See https://jira.secondlife.com/browse/VWR-28570 | 156 | // map name. See https://jira.secondlife.com/browse/VWR-28570 |
163 | // | 157 | // |
164 | // Caller, use this magic form instead: | 158 | // Caller, use this magic form instead: |
165 | // secondlife://http|!!mygrid.com|8002|Region+Name/128/128 | 159 | // secondlife://http|!!mygrid.com|8002|Region+Name/128/128 |
166 | // or url encode if possible. | 160 | // or url encode if possible. |
167 | // the hacks we do with this viewer... | 161 | // the hacks we do with this viewer... |
168 | // | 162 | // |
169 | bool needOriginalName = false; | 163 | bool needOriginalName = false; |
170 | string mapNameOrig = mapName; | 164 | string mapNameOrig = mapName; |
171 | if (mapName.Contains("|")) | 165 | if (mapName.Contains("|")) |
172 | { | 166 | { |
173 | mapName = mapName.Replace('|', ':'); | 167 | mapName = mapName.Replace('|', ':'); |
174 | needOriginalName = true; | 168 | needOriginalName = true; |
175 | } | 169 | } |
176 | if (mapName.Contains("+")) | 170 | if (mapName.Contains("+")) |
177 | { | 171 | { |
178 | mapName = mapName.Replace('+', ' '); | 172 | mapName = mapName.Replace('+', ' '); |
179 | needOriginalName = true; | 173 | needOriginalName = true; |
180 | } | 174 | } |
181 | if (mapName.Contains("!")) | 175 | if (mapName.Contains("!")) |
182 | { | 176 | { |
183 | mapName = mapName.Replace('!', '/'); | 177 | mapName = mapName.Replace('!', '/'); |
184 | needOriginalName = true; | 178 | needOriginalName = true; |
185 | } | 179 | } |
186 | if (mapName.Contains(".")) | 180 | if (mapName.Contains(".")) |
187 | needOriginalName = true; | 181 | needOriginalName = true; |
188 | 182 | ||
189 | // try to fetch from GridServer | 183 | // try to fetch from GridServer |
190 | List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); | 184 | List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); |
191 | // if (regionInfos.Count == 0) | 185 | // if (regionInfos.Count == 0) |
192 | // remoteClient.SendAlertMessage("Hyperlink could not be established."); | 186 | // remoteClient.SendAlertMessage("Hyperlink could not be established."); |
193 | 187 | ||
194 | //m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions", mapName, regionInfos.Count); | 188 | //m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions", mapName, regionInfos.Count); |
195 | 189 | ||
196 | MapBlockData data; | 190 | MapBlockData data; |
197 | if (regionInfos.Count > 0) | 191 | if (regionInfos.Count > 0) |
198 | { | ||
199 | foreach (GridRegion info in regionInfos) | ||
200 | { | 192 | { |
201 | data = new MapBlockData(); | 193 | foreach (GridRegion info in regionInfos) |
202 | data.Agents = 0; | 194 | { |
203 | data.Access = info.Access; | 195 | data = new MapBlockData(); |
204 | MapBlockData block = new MapBlockData(); | 196 | data.Agents = 0; |
205 | WorldMap.MapBlockFromGridRegion(block, info, flags); | 197 | data.Access = info.Access; |
198 | MapBlockData block = new MapBlockData(); | ||
199 | WorldMap.MapBlockFromGridRegion(block, info, flags); | ||
206 | 200 | ||
207 | if (flags == 2 && regionInfos.Count == 1 && needOriginalName) | 201 | if (flags == 2 && regionInfos.Count == 1 && needOriginalName) |
208 | block.Name = mapNameOrig; | 202 | block.Name = mapNameOrig; |
209 | blocks.Add(block); | 203 | blocks.Add(block); |
204 | } | ||
210 | } | 205 | } |
211 | } | ||
212 | 206 | ||
213 | // final block, closing the search result | 207 | // final block, closing the search result |
214 | AddFinalBlock(blocks,mapNameOrig); | 208 | AddFinalBlock(blocks,mapNameOrig); |
215 | 209 | ||
216 | // flags are agent flags sent from the viewer. | 210 | // flags are agent flags sent from the viewer. |
217 | // they have different values depending on different viewers, apparently | 211 | // they have different values depending on different viewers, apparently |
218 | remoteClient.SendMapBlock(blocks, flags); | 212 | remoteClient.SendMapBlock(blocks, flags); |
219 | 213 | ||
220 | // send extra user messages for V3 | 214 | // send extra user messages for V3 |
221 | // because the UI is very confusing | 215 | // because the UI is very confusing |
222 | // while we don't fix the hard-coded urls | 216 | // while we don't fix the hard-coded urls |
223 | if (flags == 2) | 217 | if (flags == 2) |
218 | { | ||
219 | if (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 | ||
224 | { | 226 | { |
225 | if (regionInfos.Count == 0) | 227 | lock (m_Clients) |
226 | remoteClient.SendAgentAlertMessage("No regions found with that name.", true); | 228 | m_Clients.Remove(remoteClient.AgentId); |
227 | // else if (regionInfos.Count == 1) | ||
228 | // remoteClient.SendAgentAlertMessage("Region found!", false); | ||
229 | } | 229 | } |
230 | }); | 230 | }); |
231 | } | 231 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 849d02d..80bb461 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -13758,6 +13758,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
13758 | case ScriptBaseClass.OBJECT_LAST_OWNER_ID: | 13758 | case ScriptBaseClass.OBJECT_LAST_OWNER_ID: |
13759 | ret.Add(new LSL_Key(ScriptBaseClass.NULL_KEY)); | 13759 | ret.Add(new LSL_Key(ScriptBaseClass.NULL_KEY)); |
13760 | break; | 13760 | break; |
13761 | case ScriptBaseClass.OBJECT_CLICK_ACTION: | ||
13762 | ret.Add(new LSL_Integer(0)); | ||
13763 | break; | ||
13764 | case ScriptBaseClass.OBJECT_OMEGA: | ||
13765 | ret.Add(new LSL_Vector(Vector3.Zero)); | ||
13766 | break; | ||
13767 | case ScriptBaseClass.OBJECT_PRIM_COUNT: | ||
13768 | List<SceneObjectGroup> Attachments = av.GetAttachments(); | ||
13769 | int count = 0; | ||
13770 | try | ||
13771 | { | ||
13772 | foreach (SceneObjectGroup Attachment in Attachments) | ||
13773 | count += Attachment.PrimCount; | ||
13774 | } catch { }; | ||
13775 | ret.Add(new LSL_Integer(count)); | ||
13776 | break; | ||
13777 | case ScriptBaseClass.OBJECT_TOTAL_INVENTORY_COUNT: | ||
13778 | List<SceneObjectGroup> invAttachments = av.GetAttachments(); | ||
13779 | int invcount = 0; | ||
13780 | try | ||
13781 | { | ||
13782 | foreach (SceneObjectGroup Attachment in invAttachments) | ||
13783 | { | ||
13784 | SceneObjectPart[] parts = Attachment.Parts; | ||
13785 | int nparts = parts.Count(); | ||
13786 | for(int i = 0; i < nparts; i++) | ||
13787 | invcount += parts[i].Inventory.Count; | ||
13788 | } | ||
13789 | } catch { }; | ||
13790 | ret.Add(new LSL_Integer(invcount)); | ||
13791 | break; | ||
13792 | case ScriptBaseClass.OBJECT_GROUP_TAG: | ||
13793 | ret.Add(new LSL_String(av.Grouptitle)); | ||
13794 | break; | ||
13761 | default: | 13795 | default: |
13762 | // Invalid or unhandled constant. | 13796 | // Invalid or unhandled constant. |
13763 | ret.Add(new LSL_Integer(ScriptBaseClass.OBJECT_UNKNOWN_DETAIL)); | 13797 | ret.Add(new LSL_Integer(ScriptBaseClass.OBJECT_UNKNOWN_DETAIL)); |
@@ -13930,6 +13964,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
13930 | case ScriptBaseClass.OBJECT_LAST_OWNER_ID: | 13964 | case ScriptBaseClass.OBJECT_LAST_OWNER_ID: |
13931 | ret.Add(new LSL_Key(obj.ParentGroup.LastOwnerID.ToString())); | 13965 | ret.Add(new LSL_Key(obj.ParentGroup.LastOwnerID.ToString())); |
13932 | break; | 13966 | break; |
13967 | case ScriptBaseClass.OBJECT_CLICK_ACTION: | ||
13968 | ret.Add(new LSL_Integer(obj.ClickAction)); | ||
13969 | break; | ||
13970 | case ScriptBaseClass.OBJECT_OMEGA: | ||
13971 | ret.Add(new LSL_Vector(obj.AngularVelocity)); | ||
13972 | break; | ||
13973 | case ScriptBaseClass.OBJECT_PRIM_COUNT: | ||
13974 | ret.Add(new LSL_Integer(obj.ParentGroup.PrimCount)); | ||
13975 | break; | ||
13976 | case ScriptBaseClass.OBJECT_TOTAL_INVENTORY_COUNT: | ||
13977 | SceneObjectPart[] parts = obj.ParentGroup.Parts; | ||
13978 | int nparts = parts.Count(); | ||
13979 | int count = 0; | ||
13980 | for(int i = 0; i < nparts; i++) | ||
13981 | count += parts[i].Inventory.Count; | ||
13982 | ret.Add(new LSL_Integer(count)); | ||
13983 | break; | ||
13984 | case ScriptBaseClass.OBJECT_GROUP_TAG: | ||
13985 | ret.Add(new LSL_String(String.Empty)); | ||
13986 | break; | ||
13933 | default: | 13987 | default: |
13934 | // Invalid or unhandled constant. | 13988 | // Invalid or unhandled constant. |
13935 | ret.Add(new LSL_Integer(ScriptBaseClass.OBJECT_UNKNOWN_DETAIL)); | 13989 | ret.Add(new LSL_Integer(ScriptBaseClass.OBJECT_UNKNOWN_DETAIL)); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index cee66b2..17173a2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | |||
@@ -636,6 +636,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
636 | public const int OBJECT_HOVER_HEIGHT = 25; | 636 | public const int OBJECT_HOVER_HEIGHT = 25; |
637 | public const int OBJECT_BODY_SHAPE_TYPE = 26; | 637 | public const int OBJECT_BODY_SHAPE_TYPE = 26; |
638 | public const int OBJECT_LAST_OWNER_ID = 27; | 638 | public const int OBJECT_LAST_OWNER_ID = 27; |
639 | public const int OBJECT_CLICK_ACTION = 28; | ||
640 | public const int OBJECT_OMEGA = 29; | ||
641 | public const int OBJECT_PRIM_COUNT = 30; | ||
642 | public const int OBJECT_TOTAL_INVENTORY_COUNT = 31; | ||
643 | public const int OBJECT_GROUP_TAG = 33; | ||
639 | 644 | ||
640 | // Pathfinding types | 645 | // Pathfinding types |
641 | public const int OPT_OTHER = -1; | 646 | public const int OPT_OTHER = -1; |
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index a11cae1..66c918f 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs | |||
@@ -579,7 +579,70 @@ namespace OpenSim.Services.GridService | |||
579 | int count = 0; | 579 | int count = 0; |
580 | List<GridRegion> rinfos = new List<GridRegion>(); | 580 | List<GridRegion> rinfos = new List<GridRegion>(); |
581 | 581 | ||
582 | if (rdatas != null) | 582 | if (count < maxNumber && m_AllowHypergridMapSearch && name.Contains(".")) |
583 | { | ||
584 | string regionURI = ""; | ||
585 | string regionName = ""; | ||
586 | if(!m_HypergridLinker.buildHGRegionURI(name, out regionURI, out regionName)) | ||
587 | return null; | ||
588 | |||
589 | string mapname = regionURI + regionName; | ||
590 | bool haveMatch = false; | ||
591 | |||
592 | if (rdatas != null && (rdatas.Count > 0)) | ||
593 | { | ||
594 | // m_log.DebugFormat("[GRID SERVICE]: Found {0} regions", rdatas.Count); | ||
595 | foreach (RegionData rdata in rdatas) | ||
596 | { | ||
597 | if (count++ < maxNumber) | ||
598 | rinfos.Add(RegionData2RegionInfo(rdata)); | ||
599 | if(rdata.RegionName == mapname) | ||
600 | { | ||
601 | haveMatch = true; | ||
602 | if(count == maxNumber) | ||
603 | { | ||
604 | rinfos.RemoveAt(count - 1); | ||
605 | rinfos.Add(RegionData2RegionInfo(rdata)); | ||
606 | } | ||
607 | } | ||
608 | } | ||
609 | if(haveMatch) | ||
610 | return rinfos; | ||
611 | } | ||
612 | |||
613 | rdatas = m_Database.Get(Util.EscapeForLike(mapname)+ "%", scopeID); | ||
614 | if (rdatas != null && (rdatas.Count > 0)) | ||
615 | { | ||
616 | // m_log.DebugFormat("[GRID SERVICE]: Found {0} regions", rdatas.Count); | ||
617 | foreach (RegionData rdata in rdatas) | ||
618 | { | ||
619 | if (count++ < maxNumber) | ||
620 | rinfos.Add(RegionData2RegionInfo(rdata)); | ||
621 | if(rdata.RegionName == mapname) | ||
622 | { | ||
623 | haveMatch = true; | ||
624 | if(count == maxNumber) | ||
625 | { | ||
626 | rinfos.RemoveAt(count - 1); | ||
627 | rinfos.Add(RegionData2RegionInfo(rdata)); | ||
628 | break; | ||
629 | } | ||
630 | } | ||
631 | } | ||
632 | if(haveMatch) | ||
633 | return rinfos; | ||
634 | } | ||
635 | |||
636 | string HGname = regionURI +" "+ regionName; | ||
637 | GridRegion r = m_HypergridLinker.LinkRegion(scopeID, HGname); | ||
638 | if (r != null) | ||
639 | { | ||
640 | if( count == maxNumber) | ||
641 | rinfos.RemoveAt(count - 1); | ||
642 | rinfos.Add(r); | ||
643 | } | ||
644 | } | ||
645 | else if (rdatas != null && (rdatas.Count > 0)) | ||
583 | { | 646 | { |
584 | // m_log.DebugFormat("[GRID SERVICE]: Found {0} regions", rdatas.Count); | 647 | // m_log.DebugFormat("[GRID SERVICE]: Found {0} regions", rdatas.Count); |
585 | foreach (RegionData rdata in rdatas) | 648 | foreach (RegionData rdata in rdatas) |
@@ -589,13 +652,6 @@ namespace OpenSim.Services.GridService | |||
589 | } | 652 | } |
590 | } | 653 | } |
591 | 654 | ||
592 | if (m_AllowHypergridMapSearch && (rdatas == null || (rdatas != null && rdatas.Count == 0))) | ||
593 | { | ||
594 | GridRegion r = GetHypergridRegionByName(scopeID, name); | ||
595 | if (r != null) | ||
596 | rinfos.Add(r); | ||
597 | } | ||
598 | |||
599 | return rinfos; | 655 | return rinfos; |
600 | } | 656 | } |
601 | 657 | ||
@@ -608,7 +664,20 @@ namespace OpenSim.Services.GridService | |||
608 | protected GridRegion GetHypergridRegionByName(UUID scopeID, string name) | 664 | protected GridRegion GetHypergridRegionByName(UUID scopeID, string name) |
609 | { | 665 | { |
610 | if (name.Contains(".")) | 666 | if (name.Contains(".")) |
611 | return m_HypergridLinker.LinkRegion(scopeID, name); | 667 | { |
668 | string regionURI = ""; | ||
669 | string regionName = ""; | ||
670 | if(!m_HypergridLinker.buildHGRegionURI(name, out regionURI, out regionName)) | ||
671 | return null; | ||
672 | |||
673 | string mapname = regionURI + regionName; | ||
674 | List<RegionData> rdatas = m_Database.Get(Util.EscapeForLike(mapname), scopeID); | ||
675 | if ((rdatas != null) && (rdatas.Count > 0)) | ||
676 | return RegionData2RegionInfo(rdatas[0]); // get the first | ||
677 | |||
678 | string HGname = regionURI +" "+ regionName; | ||
679 | return m_HypergridLinker.LinkRegion(scopeID, HGname); | ||
680 | } | ||
612 | else | 681 | else |
613 | return null; | 682 | return null; |
614 | } | 683 | } |
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index 2869349..e00025b 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs | |||
@@ -191,14 +191,14 @@ namespace OpenSim.Services.GridService | |||
191 | return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason); | 191 | return TryLinkRegionToCoords(scopeID, mapName, xloc, yloc, UUID.Zero, out reason); |
192 | } | 192 | } |
193 | 193 | ||
194 | public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, UUID ownerID, out string reason) | 194 | public bool buildHGRegionURI(string inputName, out string serverURI, out string regionName) |
195 | { | 195 | { |
196 | reason = string.Empty; | 196 | serverURI = string.Empty; |
197 | GridRegion regInfo = null; | 197 | regionName = string.Empty; |
198 | 198 | ||
199 | mapName = mapName.Trim(); | 199 | inputName = inputName.Trim(); |
200 | 200 | ||
201 | if (!mapName.StartsWith("http") && !mapName.StartsWith("https")) | 201 | if (!inputName.StartsWith("http") && !inputName.StartsWith("https")) |
202 | { | 202 | { |
203 | // Formats: grid.example.com:8002:region name | 203 | // Formats: grid.example.com:8002:region name |
204 | // grid.example.com:region name | 204 | // grid.example.com:region name |
@@ -207,38 +207,59 @@ namespace OpenSim.Services.GridService | |||
207 | 207 | ||
208 | string host; | 208 | string host; |
209 | uint port = 80; | 209 | uint port = 80; |
210 | string regionName = ""; | ||
211 | |||
212 | string[] parts = mapName.Split(new char[] { ':' }); | ||
213 | |||
214 | if (parts.Length == 0) | ||
215 | { | ||
216 | reason = "Wrong format for link-region"; | ||
217 | return null; | ||
218 | } | ||
219 | 210 | ||
220 | host = parts[0]; | 211 | string[] parts = inputName.Split(new char[] { ':' }); |
221 | 212 | int indx; | |
222 | if (parts.Length >= 2) | 213 | if(parts.Length == 0) |
214 | return false; | ||
215 | if (parts.Length == 1) | ||
223 | { | 216 | { |
224 | // If it's a number then assume it's a port. Otherwise, it's a region name. | 217 | indx = inputName.IndexOf('/'); |
225 | if (!UInt32.TryParse(parts[1], out port)) | 218 | if (indx < 0) |
226 | regionName = parts[1]; | 219 | serverURI = "http://"+ inputName + "/"; |
220 | else | ||
221 | { | ||
222 | serverURI = "http://"+ inputName.Substring(0,indx + 1); | ||
223 | if(indx + 2 < inputName.Length) | ||
224 | regionName = inputName.Substring(indx + 1); | ||
225 | } | ||
227 | } | 226 | } |
228 | 227 | else | |
229 | // always take the last one | ||
230 | if (parts.Length >= 3) | ||
231 | { | 228 | { |
232 | regionName = parts[2]; | 229 | host = parts[0]; |
233 | } | 230 | |
231 | if (parts.Length >= 2) | ||
232 | { | ||
233 | indx = parts[1].IndexOf('/'); | ||
234 | if(indx < 0) | ||
235 | { | ||
236 | // If it's a number then assume it's a port. Otherwise, it's a region name. | ||
237 | if (!UInt32.TryParse(parts[1], out port)) | ||
238 | { | ||
239 | port = 80; | ||
240 | regionName = parts[1]; | ||
241 | } | ||
242 | } | ||
243 | else | ||
244 | { | ||
245 | string portstr = parts[1].Substring(0, indx); | ||
246 | if(indx + 2 < parts[1].Length) | ||
247 | regionName = parts[1].Substring(indx + 1); | ||
248 | if (!UInt32.TryParse(portstr, out port)) | ||
249 | port = 80; | ||
250 | } | ||
251 | } | ||
252 | // always take the last one | ||
253 | if (parts.Length >= 3) | ||
254 | { | ||
255 | regionName = parts[2]; | ||
256 | } | ||
234 | 257 | ||
235 | string serverURI = "http://"+ host +":"+ port.ToString() + "/"; | 258 | if(port == 80) |
236 | // bool success = TryCreateLink(scopeID, xloc, yloc, regionName, port, host, ownerID, out regInfo, out reason); | 259 | serverURI = "http://"+ host + "/"; |
237 | if(TryCreateLink(scopeID, xloc, yloc, regionName, 0, null, serverURI, ownerID, out regInfo, out reason)) | 260 | else |
238 | { | 261 | serverURI = "http://"+ host +":"+ port.ToString() + "/"; |
239 | regInfo.RegionName = mapName; | 262 | } |
240 | return regInfo; | ||
241 | } | ||
242 | } | 263 | } |
243 | else | 264 | else |
244 | { | 265 | { |
@@ -246,34 +267,63 @@ namespace OpenSim.Services.GridService | |||
246 | // http://grid.example.com "region name" | 267 | // http://grid.example.com "region name" |
247 | // http://grid.example.com | 268 | // http://grid.example.com |
248 | 269 | ||
249 | string serverURI; | 270 | string[] parts = inputName.Split(new char[] { ' ' }); |
250 | string regionName = ""; | ||
251 | |||
252 | string[] parts = mapName.Split(new char[] { ' ' }); | ||
253 | 271 | ||
254 | if (parts.Length == 0) | 272 | if (parts.Length == 0) |
255 | { | 273 | return false; |
256 | reason = "Wrong format for link-region"; | ||
257 | return null; | ||
258 | } | ||
259 | 274 | ||
260 | serverURI = parts[0]; | 275 | serverURI = parts[0]; |
261 | if (!serverURI.EndsWith("/")) | ||
262 | serverURI = serverURI + "/"; | ||
263 | 276 | ||
264 | if (parts.Length >= 2) | 277 | int indx = serverURI.LastIndexOf('/'); |
278 | if(indx > 10) | ||
265 | { | 279 | { |
266 | regionName = mapName.Substring(serverURI.Length); | 280 | if(indx + 2 < inputName.Length) |
267 | regionName = regionName.Trim(new char[] { '"', ' ' }); | 281 | regionName = inputName.Substring(indx + 1); |
282 | serverURI = inputName.Substring(0, indx + 1); | ||
268 | } | 283 | } |
269 | 284 | else if (parts.Length >= 2) | |
270 | if (TryCreateLink(scopeID, xloc, yloc, regionName, 0, null, serverURI, ownerID, out regInfo, out reason)) | ||
271 | { | 285 | { |
272 | regInfo.RegionName = mapName; | 286 | regionName = inputName.Substring(serverURI.Length); |
273 | return regInfo; | ||
274 | } | 287 | } |
275 | } | 288 | } |
276 | 289 | ||
290 | // use better code for sanity check | ||
291 | Uri uri; | ||
292 | try | ||
293 | { | ||
294 | uri = new Uri(serverURI); | ||
295 | } | ||
296 | catch | ||
297 | { | ||
298 | return false; | ||
299 | } | ||
300 | |||
301 | if(!string.IsNullOrEmpty(regionName)) | ||
302 | regionName = regionName.Trim(new char[] { '"', ' ' }); | ||
303 | serverURI = uri.AbsoluteUri; | ||
304 | return true; | ||
305 | } | ||
306 | |||
307 | public GridRegion TryLinkRegionToCoords(UUID scopeID, string mapName, int xloc, int yloc, UUID ownerID, out string reason) | ||
308 | { | ||
309 | reason = string.Empty; | ||
310 | GridRegion regInfo = null; | ||
311 | |||
312 | string serverURI = string.Empty; | ||
313 | string regionName = string.Empty; | ||
314 | |||
315 | if(!buildHGRegionURI(mapName, out serverURI, out regionName)) | ||
316 | { | ||
317 | reason = "Wrong URI format for link-region"; | ||
318 | return null; | ||
319 | } | ||
320 | |||
321 | if (TryCreateLink(scopeID, xloc, yloc, regionName, 0, null, serverURI, ownerID, out regInfo, out reason)) | ||
322 | { | ||
323 | regInfo.RegionName = serverURI + regionName; | ||
324 | return regInfo; | ||
325 | } | ||
326 | |||
277 | return null; | 327 | return null; |
278 | } | 328 | } |
279 | 329 | ||