aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Agent
diff options
context:
space:
mode:
authorDiva Canto2010-01-15 15:11:58 -0800
committerDiva Canto2010-01-15 15:11:58 -0800
commitf1c30784ac767bf5f62e81748984b76d85d71f6a (patch)
tree5aa635eadb534f30cd8aa2b9a1803f637e9b95a6 /OpenSim/Region/CoreModules/Agent
parentAdded a UserAccountCache to the UserAccountServiceConnectors. Uses a CenomeCa... (diff)
downloadopensim-SC_OLD-f1c30784ac767bf5f62e81748984b76d85d71f6a.zip
opensim-SC_OLD-f1c30784ac767bf5f62e81748984b76d85d71f6a.tar.gz
opensim-SC_OLD-f1c30784ac767bf5f62e81748984b76d85d71f6a.tar.bz2
opensim-SC_OLD-f1c30784ac767bf5f62e81748984b76d85d71f6a.tar.xz
* General cleanup of Teleports, Crossings and Child agents. They are now in the new AgentTransferModule, in line with what MW started implementing back in May -- ITeleportModule. This has been renamed IAgentTransferModule, to be more generic.
* HGSceneCommunicationService has been deleted * SceneCommunicationService will likely be deleted soon too
Diffstat (limited to 'OpenSim/Region/CoreModules/Agent')
-rw-r--r--OpenSim/Region/CoreModules/Agent/AgentTransfer/AgentTransferModule.cs1188
1 files changed, 1188 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/AgentTransfer/AgentTransferModule.cs b/OpenSim/Region/CoreModules/Agent/AgentTransfer/AgentTransferModule.cs
new file mode 100644
index 0000000..8e3d041
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Agent/AgentTransfer/AgentTransferModule.cs
@@ -0,0 +1,1188 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Net;
31using System.Reflection;
32using System.Threading;
33
34using OpenSim.Framework;
35using OpenSim.Framework.Capabilities;
36using OpenSim.Framework.Client;
37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Services.Interfaces;
40
41using GridRegion = OpenSim.Services.Interfaces.GridRegion;
42
43using OpenMetaverse;
44using log4net;
45using Nini.Config;
46
47namespace OpenSim.Region.CoreModules.Agent.AgentTransfer
48{
49 public class AgentTransferModule : ISharedRegionModule, IAgentTransferModule
50 {
51 #region ISharedRegionModule
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53
54 private bool m_Enabled = false;
55 protected Scene m_aScene;
56 protected List<UUID> m_agentsInTransit;
57
58 public Type ReplaceableInterface
59 {
60 get { return null; }
61 }
62
63 public string Name
64 {
65 get { return "AgentTransferModule"; }
66 }
67
68 public virtual void Initialise(IConfigSource source)
69 {
70 IConfig moduleConfig = source.Configs["Modules"];
71 if (moduleConfig != null)
72 {
73 string name = moduleConfig.GetString("AgentTransferModule", "");
74 if (name == Name)
75 {
76 m_agentsInTransit = new List<UUID>();
77 m_Enabled = true;
78 m_log.Info("[AGENT TRANSFER MODULE]: Enabled.");
79 }
80 }
81 }
82
83 public virtual void PostInitialise()
84 {
85 }
86
87 public virtual void AddRegion(Scene scene)
88 {
89 if (!m_Enabled)
90 return;
91
92 if (m_aScene == null)
93 m_aScene = scene;
94
95 scene.RegisterModuleInterface<IAgentTransferModule>(this);
96 }
97
98 public virtual void Close()
99 {
100 if (!m_Enabled)
101 return;
102 }
103
104
105 public virtual void RemoveRegion(Scene scene)
106 {
107 if (!m_Enabled)
108 return;
109 if (scene == m_aScene)
110 m_aScene = null;
111 }
112
113 public virtual void RegionLoaded(Scene scene)
114 {
115 if (!m_Enabled)
116 return;
117
118 }
119
120
121 #endregion
122
123 #region Teleports
124
125 public void Teleport(ScenePresence sp, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags)
126 {
127 if (!sp.Scene.Permissions.CanTeleport(sp.UUID))
128 return;
129
130 bool destRegionUp = true;
131
132 IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>();
133
134 // Reset animations; the viewer does that in teleports.
135 sp.Animator.ResetAnimations();
136
137 if (regionHandle == sp.Scene.RegionInfo.RegionHandle)
138 {
139 m_log.DebugFormat(
140 "[AGENT TRANSFER MODULE]: RequestTeleportToLocation {0} within {1}",
141 position, sp.Scene.RegionInfo.RegionName);
142
143 // Teleport within the same region
144 if (IsOutsideRegion(sp.Scene, position) || position.Z < 0)
145 {
146 Vector3 emergencyPos = new Vector3(128, 128, 128);
147
148 m_log.WarnFormat(
149 "[AGENT TRANSFER MODULE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}",
150 position, sp.Name, sp.UUID, emergencyPos);
151 position = emergencyPos;
152 }
153
154 // TODO: Get proper AVG Height
155 float localAVHeight = 1.56f;
156 float posZLimit = 22;
157
158 // TODO: Check other Scene HeightField
159 if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <= (int)Constants.RegionSize)
160 {
161 posZLimit = (float)sp.Scene.Heightmap[(int)position.X, (int)position.Y];
162 }
163
164 float newPosZ = posZLimit + localAVHeight;
165 if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
166 {
167 position.Z = newPosZ;
168 }
169
170 // Only send this if the event queue is null
171 if (eq == null)
172 sp.ControllingClient.SendTeleportLocationStart();
173
174 sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
175 sp.Teleport(position);
176 }
177 else
178 {
179 uint x = 0, y = 0;
180 Utils.LongToUInts(regionHandle, out x, out y);
181 GridRegion reg = m_aScene.GridService.GetRegionByPosition(sp.Scene.RegionInfo.ScopeID, (int)x, (int)y);
182
183 if (reg != null)
184 {
185 m_log.DebugFormat(
186 "[AGENT TRANSFER MODULE]: RequestTeleportToLocation to {0} in {1}",
187 position, reg.RegionName);
188
189 uint newRegionX = (uint)(reg.RegionHandle >> 40);
190 uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
191 uint oldRegionX = (uint)(sp.Scene.RegionInfo.RegionHandle >> 40);
192 uint oldRegionY = (((uint)(sp.Scene.RegionInfo.RegionHandle)) >> 8);
193
194 ulong destinationHandle = GetRegionHandle(reg);
195
196 if (eq == null)
197 sp.ControllingClient.SendTeleportLocationStart();
198
199 // Let's do DNS resolution only once in this process, please!
200 // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
201 // it's actually doing a lot of work.
202 IPEndPoint endPoint = reg.ExternalEndPoint;
203 if (endPoint.Address == null)
204 {
205 // Couldn't resolve the name. Can't TP, because the viewer wants IP addresses.
206 destRegionUp = false;
207 }
208
209 if (destRegionUp)
210 {
211 // Fixing a bug where teleporting while sitting results in the avatar ending up removed from
212 // both regions
213 if (sp.ParentID != (uint)0)
214 sp.StandUp();
215
216 if (!sp.ValidateAttachments())
217 {
218 sp.ControllingClient.SendTeleportFailed("Inconsistent attachment state");
219 return;
220 }
221
222 // the avatar.Close below will clear the child region list. We need this below for (possibly)
223 // closing the child agents, so save it here (we need a copy as it is Clear()-ed).
224 //List<ulong> childRegions = new List<ulong>(avatar.GetKnownRegionList());
225 // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport
226 // failure at this point (unlike a border crossing failure). So perhaps this can never fail
227 // once we reach here...
228 //avatar.Scene.RemoveCapsHandler(avatar.UUID);
229
230 string capsPath = String.Empty;
231 AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo();
232 agentCircuit.BaseFolder = UUID.Zero;
233 agentCircuit.InventoryFolder = UUID.Zero;
234 agentCircuit.startpos = position;
235 agentCircuit.child = true;
236 agentCircuit.Appearance = sp.Appearance;
237
238 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
239 {
240 // brand new agent, let's create a new caps seed
241 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
242 }
243
244 string reason = String.Empty;
245
246 // Let's create an agent there if one doesn't exist yet.
247 //if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit))
248 if (!m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason))
249 {
250 sp.ControllingClient.SendTeleportFailed(String.Format("Destination is not accepting teleports: {0}",
251 reason));
252 return;
253 }
254
255 // OK, it got this agent. Let's close some child agents
256 sp.CloseChildAgents(newRegionX, newRegionY);
257
258 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
259 {
260 #region IP Translation for NAT
261 IClientIPEndpoint ipepClient;
262 if (sp.ClientView.TryGet(out ipepClient))
263 {
264 capsPath
265 = "http://"
266 + NetworkUtil.GetHostFor(ipepClient.EndPoint, reg.ExternalHostName)
267 + ":"
268 + reg.HttpPort
269 + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
270 }
271 else
272 {
273 capsPath
274 = "http://"
275 + reg.ExternalHostName
276 + ":"
277 + reg.HttpPort
278 + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
279 }
280 #endregion
281
282 if (eq != null)
283 {
284 #region IP Translation for NAT
285 // Uses ipepClient above
286 if (sp.ClientView.TryGet(out ipepClient))
287 {
288 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
289 }
290 #endregion
291
292 eq.EnableSimulator(destinationHandle, endPoint, sp.UUID);
293
294 // ES makes the client send a UseCircuitCode message to the destination,
295 // which triggers a bunch of things there.
296 // So let's wait
297 Thread.Sleep(2000);
298
299 eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath);
300
301 }
302 else
303 {
304 sp.ControllingClient.InformClientOfNeighbour(destinationHandle, endPoint);
305 }
306 }
307 else
308 {
309 agentCircuit.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, reg.RegionHandle);
310 capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
311 + "/CAPS/" + agentCircuit.CapsPath + "0000/";
312 }
313
314 // Expect avatar crossing is a heavy-duty function at the destination.
315 // That is where MakeRoot is called, which fetches appearance and inventory.
316 // Plus triggers OnMakeRoot, which spawns a series of asynchronous updates.
317 //m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId,
318 // position, false);
319
320 //{
321 // avatar.ControllingClient.SendTeleportFailed("Problem with destination.");
322 // // We should close that agent we just created over at destination...
323 // List<ulong> lst = new List<ulong>();
324 // lst.Add(reg.RegionHandle);
325 // SendCloseChildAgentAsync(avatar.UUID, lst);
326 // return;
327 //}
328
329 SetInTransit(sp.UUID);
330
331 // Let's send a full update of the agent. This is a synchronous call.
332 AgentData agent = new AgentData();
333 sp.CopyTo(agent);
334 agent.Position = position;
335 agent.CallbackURI = "http://" + sp.Scene.RegionInfo.ExternalHostName + ":" + sp.Scene.RegionInfo.HttpPort +
336 "/agent/" + sp.UUID.ToString() + "/" + sp.Scene.RegionInfo.RegionID.ToString() + "/release/";
337
338 m_aScene.SimulationService.UpdateAgent(reg, agent);
339
340 m_log.DebugFormat(
341 "[AGENT TRANSFER MODULE]: Sending new AGENT TRANSFER MODULE seed url {0} to client {1}", capsPath, sp.UUID);
342
343
344 if (eq != null)
345 {
346 eq.TeleportFinishEvent(destinationHandle, 13, endPoint,
347 0, teleportFlags, capsPath, sp.UUID);
348 }
349 else
350 {
351 sp.ControllingClient.SendRegionTeleport(destinationHandle, 13, endPoint, 4,
352 teleportFlags, capsPath);
353 }
354
355 // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which
356 // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation
357 // that the client contacted the destination before we send the attachments and close things here.
358 if (!WaitForCallback(sp.UUID))
359 {
360 // Client never contacted destination. Let's restore everything back
361 sp.ControllingClient.SendTeleportFailed("Problems connecting to destination.");
362
363 ResetFromTransit(sp.UUID);
364
365 // Yikes! We should just have a ref to scene here.
366 //sp.Scene.InformClientOfNeighbours(sp);
367 EnableChildAgents(sp);
368
369 // Finally, kill the agent we just created at the destination.
370 m_aScene.SimulationService.CloseAgent(reg, sp.UUID);
371
372 return;
373 }
374
375 KillEntity(sp.Scene, sp.LocalId);
376
377 sp.MakeChildAgent();
378
379 // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it
380 sp.CrossAttachmentsIntoNewRegion(reg, true);
381
382 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
383
384 if (NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg))
385 {
386 Thread.Sleep(5000);
387 sp.Close();
388 sp.Scene.IncomingCloseAgent(sp.UUID);
389 }
390 else
391 // now we have a child agent in this region.
392 sp.Reset();
393
394
395 // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE!
396 if (sp.Scene.NeedSceneCacheClear(sp.UUID))
397 {
398 m_log.DebugFormat(
399 "[AGENT TRANSFER MODULE]: User {0} is going to another region, profile cache removed",
400 sp.UUID);
401 }
402 }
403 else
404 {
405 sp.ControllingClient.SendTeleportFailed("Remote Region appears to be down");
406 }
407 }
408 else
409 {
410 // TP to a place that doesn't exist (anymore)
411 // Inform the viewer about that
412 sp.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore");
413
414 // and set the map-tile to '(Offline)'
415 uint regX, regY;
416 Utils.LongToUInts(regionHandle, out regX, out regY);
417
418 MapBlockData block = new MapBlockData();
419 block.X = (ushort)(regX / Constants.RegionSize);
420 block.Y = (ushort)(regY / Constants.RegionSize);
421 block.Access = 254; // == not there
422
423 List<MapBlockData> blocks = new List<MapBlockData>();
424 blocks.Add(block);
425 sp.ControllingClient.SendMapBlock(blocks, 0);
426 }
427 }
428 }
429
430 #endregion
431
432 #region Enable Child Agent
433 /// <summary>
434 /// This informs a single neighboring region about agent "avatar".
435 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
436 /// </summary>
437 public void EnableChildAgent(ScenePresence sp, GridRegion region)
438 {
439 AgentCircuitData agent = sp.ControllingClient.RequestClientInfo();
440 agent.BaseFolder = UUID.Zero;
441 agent.InventoryFolder = UUID.Zero;
442 agent.startpos = new Vector3(128, 128, 70);
443 agent.child = true;
444 agent.Appearance = sp.Appearance;
445
446 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
447 d.BeginInvoke(sp, agent, region, region.ExternalEndPoint, true,
448 InformClientOfNeighbourCompleted,
449 d);
450 }
451 #endregion
452
453 #region Crossings
454
455 public void Cross(ScenePresence agent, bool isFlying)
456 {
457 Scene scene = agent.Scene;
458 Vector3 pos = agent.AbsolutePosition;
459 Vector3 newpos = new Vector3(pos.X, pos.Y, pos.Z);
460 uint neighbourx = scene.RegionInfo.RegionLocX;
461 uint neighboury = scene.RegionInfo.RegionLocY;
462 const float boundaryDistance = 1.7f;
463 Vector3 northCross = new Vector3(0, boundaryDistance, 0);
464 Vector3 southCross = new Vector3(0, -1 * boundaryDistance, 0);
465 Vector3 eastCross = new Vector3(boundaryDistance, 0, 0);
466 Vector3 westCross = new Vector3(-1 * boundaryDistance, 0, 0);
467
468 // distance to edge that will trigger crossing
469
470
471 // distance into new region to place avatar
472 const float enterDistance = 0.5f;
473
474 if (scene.TestBorderCross(pos + westCross, Cardinals.W))
475 {
476 if (scene.TestBorderCross(pos + northCross, Cardinals.N))
477 {
478 Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
479 neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
480 }
481 else if (scene.TestBorderCross(pos + southCross, Cardinals.S))
482 {
483 Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S);
484 if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0)
485 {
486 neighboury--;
487 newpos.Y = Constants.RegionSize - enterDistance;
488 }
489 else
490 {
491 neighboury = b.TriggerRegionY;
492 neighbourx = b.TriggerRegionX;
493
494 Vector3 newposition = pos;
495 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
496 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
497 agent.ControllingClient.SendAgentAlertMessage(
498 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
499 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
500 return;
501 }
502 }
503
504 Border ba = scene.GetCrossedBorder(pos + westCross, Cardinals.W);
505 if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0)
506 {
507 neighbourx--;
508 newpos.X = Constants.RegionSize - enterDistance;
509 }
510 else
511 {
512 neighboury = ba.TriggerRegionY;
513 neighbourx = ba.TriggerRegionX;
514
515
516 Vector3 newposition = pos;
517 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
518 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
519 agent.ControllingClient.SendAgentAlertMessage(
520 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
521 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
522
523
524 return;
525 }
526
527 }
528 else if (scene.TestBorderCross(pos + eastCross, Cardinals.E))
529 {
530 Border b = scene.GetCrossedBorder(pos + eastCross, Cardinals.E);
531 neighbourx += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
532 newpos.X = enterDistance;
533
534 if (scene.TestBorderCross(pos + southCross, Cardinals.S))
535 {
536 Border ba = scene.GetCrossedBorder(pos + southCross, Cardinals.S);
537 if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0)
538 {
539 neighboury--;
540 newpos.Y = Constants.RegionSize - enterDistance;
541 }
542 else
543 {
544 neighboury = ba.TriggerRegionY;
545 neighbourx = ba.TriggerRegionX;
546 Vector3 newposition = pos;
547 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
548 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
549 agent.ControllingClient.SendAgentAlertMessage(
550 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
551 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
552 return;
553 }
554 }
555 else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
556 {
557 Border c = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
558 neighboury += (uint)(int)(c.BorderLine.Z / (int)Constants.RegionSize);
559 newpos.Y = enterDistance;
560 }
561
562
563 }
564 else if (scene.TestBorderCross(pos + southCross, Cardinals.S))
565 {
566 Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S);
567 if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0)
568 {
569 neighboury--;
570 newpos.Y = Constants.RegionSize - enterDistance;
571 }
572 else
573 {
574 neighboury = b.TriggerRegionY;
575 neighbourx = b.TriggerRegionX;
576 Vector3 newposition = pos;
577 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
578 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
579 agent.ControllingClient.SendAgentAlertMessage(
580 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
581 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
582 return;
583 }
584 }
585 else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
586 {
587
588 Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
589 neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
590 newpos.Y = enterDistance;
591 }
592
593 /*
594
595 if (pos.X < boundaryDistance) //West
596 {
597 neighbourx--;
598 newpos.X = Constants.RegionSize - enterDistance;
599 }
600 else if (pos.X > Constants.RegionSize - boundaryDistance) // East
601 {
602 neighbourx++;
603 newpos.X = enterDistance;
604 }
605
606 if (pos.Y < boundaryDistance) // South
607 {
608 neighboury--;
609 newpos.Y = Constants.RegionSize - enterDistance;
610 }
611 else if (pos.Y > Constants.RegionSize - boundaryDistance) // North
612 {
613 neighboury++;
614 newpos.Y = enterDistance;
615 }
616 */
617
618 CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync;
619 d.BeginInvoke(agent, newpos, neighbourx, neighboury, isFlying, CrossAgentToNewRegionCompleted, d);
620
621 }
622
623
624 public delegate void InformClientToInitateTeleportToLocationDelegate(ScenePresence agent, uint regionX, uint regionY,
625 Vector3 position,
626 Scene initiatingScene);
627
628 private void InformClientToInitateTeleportToLocation(ScenePresence agent, uint regionX, uint regionY, Vector3 position, Scene initiatingScene)
629 {
630
631 // This assumes that we know what our neighbors are.
632
633 InformClientToInitateTeleportToLocationDelegate d = InformClientToInitiateTeleportToLocationAsync;
634 d.BeginInvoke(agent, regionX, regionY, position, initiatingScene,
635 InformClientToInitiateTeleportToLocationCompleted,
636 d);
637 }
638
639 public void InformClientToInitiateTeleportToLocationAsync(ScenePresence agent, uint regionX, uint regionY, Vector3 position,
640 Scene initiatingScene)
641 {
642 Thread.Sleep(10000);
643 IMessageTransferModule im = initiatingScene.RequestModuleInterface<IMessageTransferModule>();
644 if (im != null)
645 {
646 UUID gotoLocation = Util.BuildFakeParcelID(
647 Util.UIntsToLong(
648 (regionX *
649 (uint)Constants.RegionSize),
650 (regionY *
651 (uint)Constants.RegionSize)),
652 (uint)(int)position.X,
653 (uint)(int)position.Y,
654 (uint)(int)position.Z);
655 GridInstantMessage m = new GridInstantMessage(initiatingScene, UUID.Zero,
656 "Region", agent.UUID,
657 (byte)InstantMessageDialog.GodLikeRequestTeleport, false,
658 "", gotoLocation, false, new Vector3(127, 0, 0),
659 new Byte[0]);
660 im.SendInstantMessage(m, delegate(bool success)
661 {
662 m_log.DebugFormat("[AGENT TRANSFER MODULE]: Client Initiating Teleport sending IM success = {0}", success);
663 });
664
665 }
666 }
667
668 private void InformClientToInitiateTeleportToLocationCompleted(IAsyncResult iar)
669 {
670 InformClientToInitateTeleportToLocationDelegate icon =
671 (InformClientToInitateTeleportToLocationDelegate)iar.AsyncState;
672 icon.EndInvoke(iar);
673 }
674
675 public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying);
676
677 /// <summary>
678 /// This Closes child agents on neighboring regions
679 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
680 /// </summary>
681 protected ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying)
682 {
683 m_log.DebugFormat("[AGENT TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury);
684
685 Scene m_scene = agent.Scene;
686 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
687
688 int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize);
689 GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
690
691 if (neighbourRegion != null && agent.ValidateAttachments())
692 {
693 pos = pos + (agent.Velocity);
694
695 SetInTransit(agent.UUID);
696 AgentData cAgent = new AgentData();
697 agent.CopyTo(cAgent);
698 cAgent.Position = pos;
699 if (isFlying)
700 cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
701 cAgent.CallbackURI = "http://" + m_scene.RegionInfo.ExternalHostName + ":" + m_scene.RegionInfo.HttpPort +
702 "/agent/" + agent.UUID.ToString() + "/" + m_scene.RegionInfo.RegionID.ToString() + "/release/";
703
704 m_scene.SimulationService.UpdateAgent(neighbourRegion, cAgent);
705
706 // Next, let's close the child agent connections that are too far away.
707 agent.CloseChildAgents(neighbourx, neighboury);
708
709 //AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo();
710 agent.ControllingClient.RequestClientInfo();
711
712 //m_log.Debug("BEFORE CROSS");
713 //Scene.DumpChildrenSeeds(UUID);
714 //DumpKnownRegions();
715 string agentcaps;
716 if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps))
717 {
718 m_log.ErrorFormat("[AGENT TRANSFER MODULE]: No AGENT TRANSFER MODULE information for region handle {0}, exiting CrossToNewRegion.",
719 neighbourRegion.RegionHandle);
720 return agent;
721 }
722 // TODO Should construct this behind a method
723 string capsPath =
724 "http://" + neighbourRegion.ExternalHostName + ":" + neighbourRegion.HttpPort
725 + "/CAPS/" + agentcaps /*circuitdata.CapsPath*/ + "0000/";
726
727 m_log.DebugFormat("[AGENT TRANSFER MODULE]: Sending new AGENT TRANSFER MODULE seed url {0} to client {1}", capsPath, agent.UUID);
728
729 IEventQueue eq = agent.Scene.RequestModuleInterface<IEventQueue>();
730 if (eq != null)
731 {
732 eq.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint,
733 capsPath, agent.UUID, agent.ControllingClient.SessionId);
734 }
735 else
736 {
737 agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint,
738 capsPath);
739 }
740
741 if (!WaitForCallback(agent.UUID))
742 {
743 m_log.Debug("[AGENT TRANSFER MODULE]: Callback never came in crossing agent");
744 ResetFromTransit(agent.UUID);
745
746 // Yikes! We should just have a ref to scene here.
747 //agent.Scene.InformClientOfNeighbours(agent);
748 EnableChildAgents(agent);
749
750 return agent;
751 }
752
753 agent.MakeChildAgent();
754 // now we have a child agent in this region. Request all interesting data about other (root) agents
755 agent.SendInitialFullUpdateToAllClients();
756
757 agent.CrossAttachmentsIntoNewRegion(neighbourRegion, true);
758
759 // m_scene.SendKillObject(m_localId);
760
761 agent.Scene.NotifyMyCoarseLocationChange();
762 // the user may change their profile information in other region,
763 // so the userinfo in UserProfileCache is not reliable any more, delete it
764 // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE!
765 if (agent.Scene.NeedSceneCacheClear(agent.UUID))
766 {
767 m_log.DebugFormat(
768 "[AGENT TRANSFER MODULE]: User {0} is going to another region", agent.UUID);
769 }
770 }
771
772 //m_log.Debug("AFTER CROSS");
773 //Scene.DumpChildrenSeeds(UUID);
774 //DumpKnownRegions();
775 return agent;
776 }
777
778 private void CrossAgentToNewRegionCompleted(IAsyncResult iar)
779 {
780 CrossAgentToNewRegionDelegate icon = (CrossAgentToNewRegionDelegate)iar.AsyncState;
781 ScenePresence agent = icon.EndInvoke(iar);
782
783 // If the cross was successful, this agent is a child agent
784 if (agent.IsChildAgent)
785 agent.Reset();
786 else // Not successful
787 agent.RestoreInCurrentScene();
788
789 // In any case
790 agent.NotInTransit();
791
792 //m_log.DebugFormat("[AGENT TRANSFER MODULE]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname);
793 }
794
795 #endregion
796
797
798 #region Enable Child Agents
799
800 private delegate void InformClientOfNeighbourDelegate(
801 ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent);
802
803 /// <summary>
804 /// This informs all neighboring regions about agent "avatar".
805 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
806 /// </summary>
807 public void EnableChildAgents(ScenePresence sp)
808 {
809 List<GridRegion> neighbours = new List<GridRegion>();
810 RegionInfo m_regionInfo = sp.Scene.RegionInfo;
811
812 if (m_regionInfo != null)
813 {
814 neighbours = RequestNeighbours(sp.Scene, m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
815 }
816 else
817 {
818 m_log.Debug("[AGENT TRANSFER MODULE]: m_regionInfo was null in EnableChildAgents, is this a NPC?");
819 }
820
821 /// We need to find the difference between the new regions where there are no child agents
822 /// and the regions where there are already child agents. We only send notification to the former.
823 List<ulong> neighbourHandles = NeighbourHandles(neighbours); // on this region
824 neighbourHandles.Add(sp.Scene.RegionInfo.RegionHandle); // add this region too
825 List<ulong> previousRegionNeighbourHandles;
826
827 if (sp.Scene.CapsModule != null)
828 {
829 previousRegionNeighbourHandles =
830 new List<ulong>(sp.Scene.CapsModule.GetChildrenSeeds(sp.UUID).Keys);
831 }
832 else
833 {
834 previousRegionNeighbourHandles = new List<ulong>();
835 }
836
837 List<ulong> newRegions = NewNeighbours(neighbourHandles, previousRegionNeighbourHandles);
838 List<ulong> oldRegions = OldNeighbours(neighbourHandles, previousRegionNeighbourHandles);
839
840 //Dump("Current Neighbors", neighbourHandles);
841 //Dump("Previous Neighbours", previousRegionNeighbourHandles);
842 //Dump("New Neighbours", newRegions);
843 //Dump("Old Neighbours", oldRegions);
844
845 /// Update the scene presence's known regions here on this region
846 sp.DropOldNeighbours(oldRegions);
847
848 /// Collect as many seeds as possible
849 Dictionary<ulong, string> seeds;
850 if (sp.Scene.CapsModule != null)
851 seeds
852 = new Dictionary<ulong, string>(sp.Scene.CapsModule.GetChildrenSeeds(sp.UUID));
853 else
854 seeds = new Dictionary<ulong, string>();
855
856 //m_log.Debug(" !!! No. of seeds: " + seeds.Count);
857 if (!seeds.ContainsKey(sp.Scene.RegionInfo.RegionHandle))
858 seeds.Add(sp.Scene.RegionInfo.RegionHandle, sp.ControllingClient.RequestClientInfo().CapsPath);
859
860 /// Create the necessary child agents
861 List<AgentCircuitData> cagents = new List<AgentCircuitData>();
862 foreach (GridRegion neighbour in neighbours)
863 {
864 if (neighbour.RegionHandle != sp.Scene.RegionInfo.RegionHandle)
865 {
866
867 AgentCircuitData agent = sp.ControllingClient.RequestClientInfo();
868 agent.BaseFolder = UUID.Zero;
869 agent.InventoryFolder = UUID.Zero;
870 agent.startpos = new Vector3(128, 128, 70);
871 agent.child = true;
872 agent.Appearance = sp.Appearance;
873
874 if (newRegions.Contains(neighbour.RegionHandle))
875 {
876 agent.CapsPath = CapsUtil.GetRandomCapsObjectPath();
877 sp.AddNeighbourRegion(neighbour.RegionHandle, agent.CapsPath);
878 seeds.Add(neighbour.RegionHandle, agent.CapsPath);
879 }
880 else
881 agent.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, neighbour.RegionHandle);
882
883 cagents.Add(agent);
884 }
885 }
886
887 /// Update all child agent with everyone's seeds
888 foreach (AgentCircuitData a in cagents)
889 {
890 a.ChildrenCapSeeds = new Dictionary<ulong, string>(seeds);
891 }
892
893 if (sp.Scene.CapsModule != null)
894 {
895 sp.Scene.CapsModule.SetChildrenSeed(sp.UUID, seeds);
896 }
897 sp.KnownRegions = seeds;
898 //avatar.Scene.DumpChildrenSeeds(avatar.UUID);
899 //avatar.DumpKnownRegions();
900
901 bool newAgent = false;
902 int count = 0;
903 foreach (GridRegion neighbour in neighbours)
904 {
905 //m_log.WarnFormat("--> Going to send child agent to {0}", neighbour.RegionName);
906 // Don't do it if there's already an agent in that region
907 if (newRegions.Contains(neighbour.RegionHandle))
908 newAgent = true;
909 else
910 newAgent = false;
911
912 if (neighbour.RegionHandle != sp.Scene.RegionInfo.RegionHandle)
913 {
914 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
915 try
916 {
917 d.BeginInvoke(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent,
918 InformClientOfNeighbourCompleted,
919 d);
920 }
921
922 catch (ArgumentOutOfRangeException)
923 {
924 m_log.ErrorFormat(
925 "[AGENT TRANSFER MODULE]: Neighbour Regions response included the current region in the neighbor list. The following region will not display to the client: {0} for region {1} ({2}, {3}).",
926 neighbour.ExternalHostName,
927 neighbour.RegionHandle,
928 neighbour.RegionLocX,
929 neighbour.RegionLocY);
930 }
931 catch (Exception e)
932 {
933 m_log.ErrorFormat(
934 "[AGENT TRANSFER MODULE]: Could not resolve external hostname {0} for region {1} ({2}, {3}). {4}",
935 neighbour.ExternalHostName,
936 neighbour.RegionHandle,
937 neighbour.RegionLocX,
938 neighbour.RegionLocY,
939 e);
940
941 // FIXME: Okay, even though we've failed, we're still going to throw the exception on,
942 // since I don't know what will happen if we just let the client continue
943
944 // XXX: Well, decided to swallow the exception instead for now. Let us see how that goes.
945 // throw e;
946
947 }
948 }
949 count++;
950 }
951 }
952
953 private void InformClientOfNeighbourCompleted(IAsyncResult iar)
954 {
955 InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate)iar.AsyncState;
956 icon.EndInvoke(iar);
957 //m_log.WarnFormat(" --> InformClientOfNeighbourCompleted");
958 }
959
960 /// <summary>
961 /// Async component for informing client of which neighbours exist
962 /// </summary>
963 /// <remarks>
964 /// This needs to run asynchronously, as a network timeout may block the thread for a long while
965 /// </remarks>
966 /// <param name="remoteClient"></param>
967 /// <param name="a"></param>
968 /// <param name="regionHandle"></param>
969 /// <param name="endPoint"></param>
970 private void InformClientOfNeighbourAsync(ScenePresence sp, AgentCircuitData a, GridRegion reg,
971 IPEndPoint endPoint, bool newAgent)
972 {
973 // Let's wait just a little to give time to originating regions to catch up with closing child agents
974 // after a cross here
975 Thread.Sleep(500);
976
977 Scene m_scene = sp.Scene;
978
979 uint x, y;
980 Utils.LongToUInts(reg.RegionHandle, out x, out y);
981 x = x / Constants.RegionSize;
982 y = y / Constants.RegionSize;
983 m_log.Info("[AGENT TRANSFER MODULE]: Starting to inform client about neighbour " + x + ", " + y + "(" + endPoint.ToString() + ")");
984
985 string capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
986 + "/CAPS/" + a.CapsPath + "0000/";
987
988 string reason = String.Empty;
989
990
991 bool regionAccepted = m_scene.SimulationService.CreateAgent(reg, a, 0, out reason); // m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, 0, out reason);
992
993 if (regionAccepted && newAgent)
994 {
995 IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>();
996 if (eq != null)
997 {
998 #region IP Translation for NAT
999 IClientIPEndpoint ipepClient;
1000 if (sp.ClientView.TryGet(out ipepClient))
1001 {
1002 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
1003 }
1004 #endregion
1005
1006 eq.EnableSimulator(reg.RegionHandle, endPoint, sp.UUID);
1007 eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath);
1008 m_log.DebugFormat("[AGENT TRANSFER MODULE]: Sending new AGENT TRANSFER MODULE seed url {0} to client {1} in region {2}",
1009 capsPath, sp.UUID, sp.Scene.RegionInfo.RegionName);
1010 }
1011 else
1012 {
1013 sp.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint);
1014 // TODO: make Event Queue disablable!
1015 }
1016
1017 m_log.Info("[AGENT TRANSFER MODULE]: Completed inform client about neighbour " + endPoint.ToString());
1018
1019 }
1020
1021 }
1022
1023 protected List<GridRegion> RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY)
1024 {
1025 RegionInfo m_regionInfo = pScene.RegionInfo;
1026
1027 Border[] northBorders = pScene.NorthBorders.ToArray();
1028 Border[] southBorders = pScene.SouthBorders.ToArray();
1029 Border[] eastBorders = pScene.EastBorders.ToArray();
1030 Border[] westBorders = pScene.WestBorders.ToArray();
1031
1032 // Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement.
1033 if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1)
1034 {
1035 return pScene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID);
1036 }
1037 else
1038 {
1039 Vector2 extent = Vector2.Zero;
1040 for (int i = 0; i < eastBorders.Length; i++)
1041 {
1042 extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X;
1043 }
1044 for (int i = 0; i < northBorders.Length; i++)
1045 {
1046 extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y;
1047 }
1048
1049 // Loss of fraction on purpose
1050 extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1;
1051 extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1;
1052
1053 int startX = (int)(pRegionLocX - 1) * (int)Constants.RegionSize;
1054 int startY = (int)(pRegionLocY - 1) * (int)Constants.RegionSize;
1055
1056 int endX = ((int)pRegionLocX + (int)extent.X) * (int)Constants.RegionSize;
1057 int endY = ((int)pRegionLocY + (int)extent.Y) * (int)Constants.RegionSize;
1058
1059 List<GridRegion> neighbours = pScene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY);
1060 neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; });
1061
1062 return neighbours;
1063 }
1064 }
1065
1066 private List<ulong> NewNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
1067 {
1068 return currentNeighbours.FindAll(delegate(ulong handle) { return !previousNeighbours.Contains(handle); });
1069 }
1070
1071 // private List<ulong> CommonNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
1072 // {
1073 // return currentNeighbours.FindAll(delegate(ulong handle) { return previousNeighbours.Contains(handle); });
1074 // }
1075
1076 private List<ulong> OldNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
1077 {
1078 return previousNeighbours.FindAll(delegate(ulong handle) { return !currentNeighbours.Contains(handle); });
1079 }
1080
1081 private List<ulong> NeighbourHandles(List<GridRegion> neighbours)
1082 {
1083 List<ulong> handles = new List<ulong>();
1084 foreach (GridRegion reg in neighbours)
1085 {
1086 handles.Add(reg.RegionHandle);
1087 }
1088 return handles;
1089 }
1090
1091 private void Dump(string msg, List<ulong> handles)
1092 {
1093 m_log.InfoFormat("-------------- HANDLE DUMP ({0}) ---------", msg);
1094 foreach (ulong handle in handles)
1095 {
1096 uint x, y;
1097 Utils.LongToUInts(handle, out x, out y);
1098 x = x / Constants.RegionSize;
1099 y = y / Constants.RegionSize;
1100 m_log.InfoFormat("({0}, {1})", x, y);
1101 }
1102 }
1103
1104 #endregion
1105
1106
1107 #region Agent Arrived
1108 public void AgentArrivedAtDestination(UUID id)
1109 {
1110 //m_log.Debug(" >>> ReleaseAgent called <<< ");
1111 ResetFromTransit(id);
1112 }
1113
1114 #endregion
1115
1116
1117 #region Misc
1118 protected bool IsOutsideRegion(Scene s, Vector3 pos)
1119 {
1120
1121 if (s.TestBorderCross(pos, Cardinals.N))
1122 return true;
1123 if (s.TestBorderCross(pos, Cardinals.S))
1124 return true;
1125 if (s.TestBorderCross(pos, Cardinals.E))
1126 return true;
1127 if (s.TestBorderCross(pos, Cardinals.W))
1128 return true;
1129
1130 return false;
1131 }
1132
1133 protected bool WaitForCallback(UUID id)
1134 {
1135 int count = 200;
1136 while (m_agentsInTransit.Contains(id) && count-- > 0)
1137 {
1138 //m_log.Debug(" >>> Waiting... " + count);
1139 Thread.Sleep(100);
1140 }
1141
1142 if (count > 0)
1143 return true;
1144 else
1145 return false;
1146 }
1147
1148 protected void SetInTransit(UUID id)
1149 {
1150 lock (m_agentsInTransit)
1151 {
1152 if (!m_agentsInTransit.Contains(id))
1153 m_agentsInTransit.Add(id);
1154 }
1155 }
1156
1157 protected bool ResetFromTransit(UUID id)
1158 {
1159 lock (m_agentsInTransit)
1160 {
1161 if (m_agentsInTransit.Contains(id))
1162 {
1163 m_agentsInTransit.Remove(id);
1164 return true;
1165 }
1166 }
1167 return false;
1168 }
1169
1170 protected void KillEntity(Scene scene, uint localID)
1171 {
1172 scene.SendKillObject(localID);
1173 }
1174
1175 protected virtual ulong GetRegionHandle(GridRegion region)
1176 {
1177 return region.RegionHandle;
1178 }
1179
1180 protected virtual bool NeedsClosing(uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg)
1181 {
1182 return Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY);
1183 }
1184
1185 #endregion
1186
1187 }
1188}