aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Hypergrid
diff options
context:
space:
mode:
authorSean Dague2009-02-09 20:06:06 +0000
committerSean Dague2009-02-09 20:06:06 +0000
commit66dc421be7974c6aafb12f318a7649dca99f0989 (patch)
tree5415c8ef9ad05f38d1f4d0673be39e29d9e5ac44 /OpenSim/Region/Framework/Scenes/Hypergrid
parentadd a script for fixing line endings (at least from linux) (diff)
downloadopensim-SC_OLD-66dc421be7974c6aafb12f318a7649dca99f0989.zip
opensim-SC_OLD-66dc421be7974c6aafb12f318a7649dca99f0989.tar.gz
opensim-SC_OLD-66dc421be7974c6aafb12f318a7649dca99f0989.tar.bz2
opensim-SC_OLD-66dc421be7974c6aafb12f318a7649dca99f0989.tar.xz
a last set of files that seem to have embedded ^M in them
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Hypergrid')
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs384
1 files changed, 192 insertions, 192 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs
index 35969c7..7249029 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs
@@ -1,192 +1,192 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Reflection; 29using System.Reflection;
30using System.Net; 30using System.Net;
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Framework.Communications; 32using OpenSim.Framework.Communications;
33using OpenMetaverse; 33using OpenMetaverse;
34using log4net; 34using log4net;
35using Nini.Config; 35using Nini.Config;
36 36
37namespace OpenSim.Region.Framework.Scenes.Hypergrid 37namespace OpenSim.Region.Framework.Scenes.Hypergrid
38{ 38{
39 public class HGHyperlink 39 public class HGHyperlink
40 { 40 {
41 private static readonly ILog m_log = 41 private static readonly ILog m_log =
42 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 private static Random random = new Random(); 43 private static Random random = new Random();
44 44
45 public static RegionInfo TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, uint xloc, uint yloc) 45 public static RegionInfo TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, uint xloc, uint yloc)
46 { 46 {
47 string host = "127.0.0.1"; 47 string host = "127.0.0.1";
48 string portstr; 48 string portstr;
49 string regionName = ""; 49 string regionName = "";
50 uint port = 9000; 50 uint port = 9000;
51 string[] parts = mapName.Split(new char[] { ':' }); 51 string[] parts = mapName.Split(new char[] { ':' });
52 if (parts.Length >= 1) 52 if (parts.Length >= 1)
53 { 53 {
54 host = parts[0]; 54 host = parts[0];
55 } 55 }
56 if (parts.Length >= 2) 56 if (parts.Length >= 2)
57 { 57 {
58 portstr = parts[1]; 58 portstr = parts[1];
59 if (!UInt32.TryParse(portstr, out port)) 59 if (!UInt32.TryParse(portstr, out port))
60 regionName = parts[1]; 60 regionName = parts[1];
61 } 61 }
62 // always take the last one 62 // always take the last one
63 if (parts.Length >= 3) 63 if (parts.Length >= 3)
64 { 64 {
65 regionName = parts[2]; 65 regionName = parts[2];
66 } 66 }
67 67
68 // Sanity check. Don't ever link to this sim. 68 // Sanity check. Don't ever link to this sim.
69 IPAddress ipaddr = null; 69 IPAddress ipaddr = null;
70 try 70 try
71 { 71 {
72 ipaddr = Util.GetHostFromDNS(host); 72 ipaddr = Util.GetHostFromDNS(host);
73 } 73 }
74 catch { } 74 catch { }
75 75
76 if ((ipaddr != null) && 76 if ((ipaddr != null) &&
77 !((m_scene.RegionInfo.ExternalEndPoint.Address.Equals(ipaddr)) && (m_scene.RegionInfo.HttpPort == port))) 77 !((m_scene.RegionInfo.ExternalEndPoint.Address.Equals(ipaddr)) && (m_scene.RegionInfo.HttpPort == port)))
78 { 78 {
79 RegionInfo regInfo; 79 RegionInfo regInfo;
80 bool success = TryCreateLink(m_scene, client, xloc, yloc, regionName, port, host, out regInfo); 80 bool success = TryCreateLink(m_scene, client, xloc, yloc, regionName, port, host, out regInfo);
81 if (success) 81 if (success)
82 { 82 {
83 regInfo.RegionName = mapName; 83 regInfo.RegionName = mapName;
84 return regInfo; 84 return regInfo;
85 } 85 }
86 } 86 }
87 87
88 return null; 88 return null;
89 } 89 }
90 90
91 public static RegionInfo TryLinkRegion(Scene m_scene, IClientAPI client, string mapName) 91 public static RegionInfo TryLinkRegion(Scene m_scene, IClientAPI client, string mapName)
92 { 92 {
93 uint xloc = (uint)(random.Next(0, Int16.MaxValue)); 93 uint xloc = (uint)(random.Next(0, Int16.MaxValue));
94 return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0); 94 return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0);
95 } 95 }
96 96
97 public static bool TryCreateLink(Scene m_scene, IClientAPI client, uint xloc, uint yloc, 97 public static bool TryCreateLink(Scene m_scene, IClientAPI client, uint xloc, uint yloc,
98 string externalRegionName, uint externalPort, string externalHostName, out RegionInfo regInfo) 98 string externalRegionName, uint externalPort, string externalHostName, out RegionInfo regInfo)
99 { 99 {
100 m_log.DebugFormat("[HGrid]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc); 100 m_log.DebugFormat("[HGrid]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc);
101 101
102 regInfo = new RegionInfo(); 102 regInfo = new RegionInfo();
103 regInfo.RegionName = externalRegionName; 103 regInfo.RegionName = externalRegionName;
104 regInfo.HttpPort = externalPort; 104 regInfo.HttpPort = externalPort;
105 regInfo.ExternalHostName = externalHostName; 105 regInfo.ExternalHostName = externalHostName;
106 regInfo.RegionLocX = xloc; 106 regInfo.RegionLocX = xloc;
107 regInfo.RegionLocY = yloc; 107 regInfo.RegionLocY = yloc;
108 108
109 try 109 try
110 { 110 {
111 regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0); 111 regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0);
112 } 112 }
113 catch (Exception e) 113 catch (Exception e)
114 { 114 {
115 m_log.Warn("[HGrid]: Wrong format for link-region: " + e.Message); 115 m_log.Warn("[HGrid]: Wrong format for link-region: " + e.Message);
116 return false; 116 return false;
117 } 117 }
118 regInfo.RemotingAddress = regInfo.ExternalEndPoint.Address.ToString(); 118 regInfo.RemotingAddress = regInfo.ExternalEndPoint.Address.ToString();
119 119
120 // Finally, link it 120 // Finally, link it
121 try 121 try
122 { 122 {
123 m_scene.CommsManager.GridService.RegisterRegion(regInfo); 123 m_scene.CommsManager.GridService.RegisterRegion(regInfo);
124 } 124 }
125 catch (Exception e) 125 catch (Exception e)
126 { 126 {
127 m_log.Warn("[HGrid]: Unable to link region: " + e.Message); 127 m_log.Warn("[HGrid]: Unable to link region: " + e.Message);
128 return false; 128 return false;
129 } 129 }
130 130
131 uint x, y; 131 uint x, y;
132 if (!Check4096(m_scene, regInfo, out x, out y)) 132 if (!Check4096(m_scene, regInfo, out x, out y))
133 { 133 {
134 m_scene.CommsManager.GridService.DeregisterRegion(regInfo); 134 m_scene.CommsManager.GridService.DeregisterRegion(regInfo);
135 if (client != null) 135 if (client != null)
136 client.SendAlertMessage("Region is too far (" + x + ", " + y + ")"); 136 client.SendAlertMessage("Region is too far (" + x + ", " + y + ")");
137 m_log.Info("[HGrid]: Unable to link, region is too far (" + x + ", " + y + ")"); 137 m_log.Info("[HGrid]: Unable to link, region is too far (" + x + ", " + y + ")");
138 return false; 138 return false;
139 } 139 }
140 140
141 if (!CheckCoords(m_scene.RegionInfo.RegionLocX, m_scene.RegionInfo.RegionLocY, x, y)) 141 if (!CheckCoords(m_scene.RegionInfo.RegionLocX, m_scene.RegionInfo.RegionLocY, x, y))
142 { 142 {
143 m_scene.CommsManager.GridService.DeregisterRegion(regInfo); 143 m_scene.CommsManager.GridService.DeregisterRegion(regInfo);
144 if (client != null) 144 if (client != null)
145 client.SendAlertMessage("Region has incompatible coordinates (" + x + ", " + y + ")"); 145 client.SendAlertMessage("Region has incompatible coordinates (" + x + ", " + y + ")");
146 m_log.Info("[HGrid]: Unable to link, region has incompatible coordinates (" + x + ", " + y + ")"); 146 m_log.Info("[HGrid]: Unable to link, region has incompatible coordinates (" + x + ", " + y + ")");
147 return false; 147 return false;
148 } 148 }
149 149
150 m_log.Debug("[HGrid]: link region succeeded"); 150 m_log.Debug("[HGrid]: link region succeeded");
151 return true; 151 return true;
152 } 152 }
153 153
154 /// <summary> 154 /// <summary>
155 /// Cope with this viewer limitation. 155 /// Cope with this viewer limitation.
156 /// </summary> 156 /// </summary>
157 /// <param name="regInfo"></param> 157 /// <param name="regInfo"></param>
158 /// <returns></returns> 158 /// <returns></returns>
159 public static bool Check4096(Scene m_scene, RegionInfo regInfo, out uint x, out uint y) 159 public static bool Check4096(Scene m_scene, RegionInfo regInfo, out uint x, out uint y)
160 { 160 {
161 ulong realHandle; 161 ulong realHandle;
162 if (UInt64.TryParse(regInfo.regionSecret, out realHandle)) 162 if (UInt64.TryParse(regInfo.regionSecret, out realHandle))
163 { 163 {
164 Utils.LongToUInts(realHandle, out x, out y); 164 Utils.LongToUInts(realHandle, out x, out y);
165 x = x / Constants.RegionSize; 165 x = x / Constants.RegionSize;
166 y = y / Constants.RegionSize; 166 y = y / Constants.RegionSize;
167 167
168 if ((Math.Abs((int)m_scene.RegionInfo.RegionLocX - (int)x) >= 4096) || 168 if ((Math.Abs((int)m_scene.RegionInfo.RegionLocX - (int)x) >= 4096) ||
169 (Math.Abs((int)m_scene.RegionInfo.RegionLocY - (int)y) >= 4096)) 169 (Math.Abs((int)m_scene.RegionInfo.RegionLocY - (int)y) >= 4096))
170 { 170 {
171 return false; 171 return false;
172 } 172 }
173 return true; 173 return true;
174 } 174 }
175 else 175 else
176 { 176 {
177 m_scene.CommsManager.GridService.RegisterRegion(regInfo); 177 m_scene.CommsManager.GridService.RegisterRegion(regInfo);
178 m_log.Debug("[HGrid]: Gnomes. Region deregistered."); 178 m_log.Debug("[HGrid]: Gnomes. Region deregistered.");
179 x = y = 0; 179 x = y = 0;
180 return false; 180 return false;
181 } 181 }
182 } 182 }
183 183
184 public static bool CheckCoords(uint thisx, uint thisy, uint x, uint y) 184 public static bool CheckCoords(uint thisx, uint thisy, uint x, uint y)
185 { 185 {
186 if ((thisx == x) && (thisy == y)) 186 if ((thisx == x) && (thisy == y))
187 return false; 187 return false;
188 return true; 188 return true;
189 } 189 }
190 190
191 } 191 }
192} 192}