diff options
author | lbsa71 | 2009-03-10 12:11:19 +0000 |
---|---|---|
committer | lbsa71 | 2009-03-10 12:11:19 +0000 |
commit | 0df0258087e18757a77514ac4cba8a50e01b27d5 (patch) | |
tree | 7896a546e9782c105f7bcbfa07cd7df0d5407929 /OpenSim/Client/Linden | |
parent | * Re-aligned CustomiseResponse function for imminent up-pulling (diff) | |
download | opensim-SC_OLD-0df0258087e18757a77514ac4cba8a50e01b27d5.zip opensim-SC_OLD-0df0258087e18757a77514ac4cba8a50e01b27d5.tar.gz opensim-SC_OLD-0df0258087e18757a77514ac4cba8a50e01b27d5.tar.bz2 opensim-SC_OLD-0df0258087e18757a77514ac4cba8a50e01b27d5.tar.xz |
*** POTENTIAL BREAKAGE ***
* Finally got to the point where I could pull up the CustomiseResponse function. Major de-duplication.
* Introduced FromRegionInfo on RegionProfileData
* This revision needs both grid and standalone testing galore.
Work in progress!
Diffstat (limited to 'OpenSim/Client/Linden')
-rw-r--r-- | OpenSim/Client/Linden/LLStandaloneLoginService.cs | 143 |
1 files changed, 5 insertions, 138 deletions
diff --git a/OpenSim/Client/Linden/LLStandaloneLoginService.cs b/OpenSim/Client/Linden/LLStandaloneLoginService.cs index 8fe7172..b596e14 100644 --- a/OpenSim/Client/Linden/LLStandaloneLoginService.cs +++ b/OpenSim/Client/Linden/LLStandaloneLoginService.cs | |||
@@ -126,150 +126,17 @@ namespace OpenSim.Client.Linden | |||
126 | } | 126 | } |
127 | } | 127 | } |
128 | 128 | ||
129 | /// <summary> | 129 | protected override RegionInfo RequestClosestRegion(string region) |
130 | /// Customises the login response and fills in missing values. | ||
131 | /// </summary> | ||
132 | /// <param name="response">The existing response</param> | ||
133 | /// <param name="theUser">The user profile</param> | ||
134 | /// <param name="startLocationRequest">The requested start location</param> | ||
135 | public override bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest) | ||
136 | { | ||
137 | // add active gestures to login-response | ||
138 | AddActiveGestures(response, theUser); | ||
139 | |||
140 | // HomeLocation | ||
141 | RegionInfo homeInfo = null; | ||
142 | |||
143 | // use the homeRegionID if it is stored already. If not, use the regionHandle as before | ||
144 | UUID homeRegionId = theUser.HomeRegionID; | ||
145 | ulong homeRegionHandle = theUser.HomeRegion; | ||
146 | if (homeRegionId != UUID.Zero) | ||
147 | { | ||
148 | homeInfo = GetRegionInfo(homeRegionId); | ||
149 | } | ||
150 | else | ||
151 | { | ||
152 | homeInfo = GetRegionInfo(homeRegionHandle); | ||
153 | } | ||
154 | |||
155 | if (homeInfo != null) | ||
156 | { | ||
157 | response.Home = | ||
158 | string.Format( | ||
159 | "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", | ||
160 | (homeInfo.RegionLocX * Constants.RegionSize), | ||
161 | (homeInfo.RegionLocY * Constants.RegionSize), | ||
162 | theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, | ||
163 | theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); | ||
164 | } | ||
165 | else | ||
166 | { | ||
167 | m_log.InfoFormat("not found the region at {0} {1}", theUser.HomeRegionX, theUser.HomeRegionY); | ||
168 | // Emergency mode: Home-region isn't available, so we can't request the region info. | ||
169 | // Use the stored home regionHandle instead. | ||
170 | // NOTE: If the home-region moves, this will be wrong until the users update their user-profile again | ||
171 | ulong regionX = homeRegionHandle >> 32; | ||
172 | ulong regionY = homeRegionHandle & 0xffffffff; | ||
173 | response.Home = | ||
174 | string.Format( | ||
175 | "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", | ||
176 | regionX, regionY, | ||
177 | theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, | ||
178 | theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); | ||
179 | |||
180 | m_log.InfoFormat("[LOGIN] Home region of user {0} {1} is not available; using computed region position {2} {3}", | ||
181 | theUser.FirstName, theUser.SurName, | ||
182 | regionX, regionY); | ||
183 | } | ||
184 | |||
185 | // StartLocation | ||
186 | RegionInfo regionInfo = null; | ||
187 | if (startLocationRequest == "home") | ||
188 | { | ||
189 | regionInfo = homeInfo; | ||
190 | theUser.CurrentAgent.Position = theUser.HomeLocation; | ||
191 | response.LookAt = "[r" + theUser.HomeLookAt.X.ToString() + ",r" + theUser.HomeLookAt.Y.ToString() + ",r" + theUser.HomeLookAt.Z.ToString() + "]"; | ||
192 | } | ||
193 | else if (startLocationRequest == "last") | ||
194 | { | ||
195 | UUID lastRegion = theUser.CurrentAgent.Region; | ||
196 | regionInfo = GetRegionInfo(lastRegion); | ||
197 | response.LookAt = "[r" + theUser.CurrentAgent.LookAt.X.ToString() + ",r" + theUser.CurrentAgent.LookAt.Y.ToString() + ",r" + theUser.CurrentAgent.LookAt.Z.ToString() + "]"; | ||
198 | } | ||
199 | else | ||
200 | { | ||
201 | Regex reURI = new Regex(@"^uri:(?<region>[^&]+)&(?<x>\d+)&(?<y>\d+)&(?<z>\d+)$"); | ||
202 | Match uriMatch = reURI.Match(startLocationRequest); | ||
203 | if (uriMatch == null) | ||
204 | { | ||
205 | m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, but can't process it", startLocationRequest); | ||
206 | } | ||
207 | else | ||
208 | { | ||
209 | string region = uriMatch.Groups["region"].ToString(); | ||
210 | regionInfo = RequestClosestRegion(region); | ||
211 | if (regionInfo == null) | ||
212 | { | ||
213 | m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, can't locate region {1}", startLocationRequest, region); | ||
214 | } | ||
215 | else | ||
216 | { | ||
217 | theUser.CurrentAgent.Position = new Vector3(float.Parse(uriMatch.Groups["x"].Value), | ||
218 | float.Parse(uriMatch.Groups["y"].Value), float.Parse(uriMatch.Groups["z"].Value)); | ||
219 | } | ||
220 | } | ||
221 | response.LookAt = "[r0,r1,r0]"; | ||
222 | // can be: last, home, safe, url | ||
223 | response.StartLocation = "url"; | ||
224 | } | ||
225 | |||
226 | if ((regionInfo != null) && (PrepareLoginToRegion(regionInfo, theUser, response))) | ||
227 | { | ||
228 | return true; | ||
229 | } | ||
230 | |||
231 | // StartLocation not available, send him to a nearby region instead | ||
232 | // regionInfo = m_gridService.RequestClosestRegion(""); | ||
233 | //m_log.InfoFormat("[LOGIN]: StartLocation not available sending to region {0}", regionInfo.regionName); | ||
234 | |||
235 | // Send him to default region instead | ||
236 | ulong defaultHandle = (((ulong)m_defaultHomeX * Constants.RegionSize) << 32) | | ||
237 | ((ulong)m_defaultHomeY * Constants.RegionSize); | ||
238 | |||
239 | if ((regionInfo != null) && (defaultHandle == regionInfo.RegionHandle)) | ||
240 | { | ||
241 | m_log.ErrorFormat("[LOGIN]: Not trying the default region since this is the same as the selected region"); | ||
242 | return false; | ||
243 | } | ||
244 | |||
245 | m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead"); | ||
246 | regionInfo = GetRegionInfo(defaultHandle); | ||
247 | |||
248 | // Customise the response | ||
249 | //response.Home = | ||
250 | // string.Format( | ||
251 | // "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", | ||
252 | // (SimInfo.regionLocX * Constants.RegionSize), | ||
253 | // (SimInfo.regionLocY*Constants.RegionSize), | ||
254 | // theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, | ||
255 | // theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); | ||
256 | theUser.CurrentAgent.Position = new Vector3(128, 128, 0); | ||
257 | response.StartLocation = "safe"; | ||
258 | |||
259 | return PrepareLoginToRegion(regionInfo, theUser, response); | ||
260 | } | ||
261 | |||
262 | protected RegionInfo RequestClosestRegion(string region) | ||
263 | { | 130 | { |
264 | return m_regionsConnector.RequestClosestRegion(region); | 131 | return m_regionsConnector.RequestClosestRegion(region); |
265 | } | 132 | } |
266 | 133 | ||
267 | protected RegionInfo GetRegionInfo(ulong homeRegionHandle) | 134 | protected override RegionInfo GetRegionInfo(ulong homeRegionHandle) |
268 | { | 135 | { |
269 | return m_regionsConnector.RequestNeighbourInfo(homeRegionHandle); | 136 | return m_regionsConnector.RequestNeighbourInfo(homeRegionHandle); |
270 | } | 137 | } |
271 | 138 | ||
272 | protected RegionInfo GetRegionInfo(UUID homeRegionId) | 139 | protected override RegionInfo GetRegionInfo(UUID homeRegionId) |
273 | { | 140 | { |
274 | return m_regionsConnector.RequestNeighbourInfo(homeRegionId); | 141 | return m_regionsConnector.RequestNeighbourInfo(homeRegionId); |
275 | } | 142 | } |
@@ -283,7 +150,7 @@ namespace OpenSim.Client.Linden | |||
283 | /// <param name="theUser"> | 150 | /// <param name="theUser"> |
284 | /// A <see cref="UserProfileData"/> | 151 | /// A <see cref="UserProfileData"/> |
285 | /// </param> | 152 | /// </param> |
286 | private void AddActiveGestures(LoginResponse response, UserProfileData theUser) | 153 | protected override void AddActiveGestures(LoginResponse response, UserProfileData theUser) |
287 | { | 154 | { |
288 | List<InventoryItemBase> gestures = m_interServiceInventoryService.GetActiveGestures(theUser.ID); | 155 | List<InventoryItemBase> gestures = m_interServiceInventoryService.GetActiveGestures(theUser.ID); |
289 | //m_log.DebugFormat("[LOGIN]: AddActiveGestures, found {0}", gestures == null ? 0 : gestures.Count); | 156 | //m_log.DebugFormat("[LOGIN]: AddActiveGestures, found {0}", gestures == null ? 0 : gestures.Count); |
@@ -309,7 +176,7 @@ namespace OpenSim.Client.Linden | |||
309 | /// <param name="user"></param> | 176 | /// <param name="user"></param> |
310 | /// <param name="response"></param> | 177 | /// <param name="response"></param> |
311 | /// <returns>true if the region was successfully contacted, false otherwise</returns> | 178 | /// <returns>true if the region was successfully contacted, false otherwise</returns> |
312 | protected bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response) | 179 | protected override bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response) |
313 | { | 180 | { |
314 | IPEndPoint endPoint = regionInfo.ExternalEndPoint; | 181 | IPEndPoint endPoint = regionInfo.ExternalEndPoint; |
315 | response.SimAddress = endPoint.Address.ToString(); | 182 | response.SimAddress = endPoint.Address.ToString(); |