aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorTeravus Ovares (Dan Olivares)2009-09-13 07:20:18 -0400
committerTeravus Ovares (Dan Olivares)2009-09-13 07:20:18 -0400
commit4241cdc9291eb5beeaa3120bf3079541b6452410 (patch)
tree5268835b9ee3649a0fd17c6b051f42f42ddb61ac /OpenSim
parentGuarding the unpacking of the email field introduced by Robsmart. Most profil... (diff)
downloadopensim-SC_OLD-4241cdc9291eb5beeaa3120bf3079541b6452410.zip
opensim-SC_OLD-4241cdc9291eb5beeaa3120bf3079541b6452410.tar.gz
opensim-SC_OLD-4241cdc9291eb5beeaa3120bf3079541b6452410.tar.bz2
opensim-SC_OLD-4241cdc9291eb5beeaa3120bf3079541b6452410.tar.xz
* More comments in the RegionCombinerModule
* Changed the Destination ID to 0 in the TeleportFinish Event (why did we have it as 3?) * Added border based trigger teleports * Fix MakeRootAgent border cross tests for ensuring that the position is inside the region to use the borders to figure out if it's outside the Region
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs130
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs124
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs26
3 files changed, 251 insertions, 29 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs b/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs
index 45e09a3..df2975b 100644
--- a/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs
@@ -80,9 +80,15 @@ namespace OpenSim.Region.CoreModules.World.Land
80 if (!enabledYN) 80 if (!enabledYN)
81 return; 81 return;
82 82
83 /* For testing on a single instance
84 if (scene.RegionInfo.RegionLocX == 1004 && scene.RegionInfo.RegionLocY == 1000)
85 return;
86 */
87
83 lock (m_startingScenes) 88 lock (m_startingScenes)
84 m_startingScenes.Add(scene.RegionInfo.originRegionID, scene); 89 m_startingScenes.Add(scene.RegionInfo.originRegionID, scene);
85 90
91 // Give each region a standard set of non-infinite borders
86 Border northBorder = new Border(); 92 Border northBorder = new Border();
87 northBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, (int)Constants.RegionSize); //<--- 93 northBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, (int)Constants.RegionSize); //<---
88 northBorder.CrossDirection = Cardinals.N; 94 northBorder.CrossDirection = Cardinals.N;
@@ -103,6 +109,8 @@ namespace OpenSim.Region.CoreModules.World.Land
103 westBorder.CrossDirection = Cardinals.W; 109 westBorder.CrossDirection = Cardinals.W;
104 scene.WestBorders[0] = westBorder; 110 scene.WestBorders[0] = westBorder;
105 111
112
113
106 RegionConnections regionConnections = new RegionConnections(); 114 RegionConnections regionConnections = new RegionConnections();
107 regionConnections.ConnectedRegions = new List<RegionData>(); 115 regionConnections.ConnectedRegions = new List<RegionData>();
108 regionConnections.RegionScene = scene; 116 regionConnections.RegionScene = scene;
@@ -112,6 +120,8 @@ namespace OpenSim.Region.CoreModules.World.Land
112 regionConnections.Y = scene.RegionInfo.RegionLocY; 120 regionConnections.Y = scene.RegionInfo.RegionLocY;
113 regionConnections.XEnd = (int)Constants.RegionSize; 121 regionConnections.XEnd = (int)Constants.RegionSize;
114 regionConnections.YEnd = (int)Constants.RegionSize; 122 regionConnections.YEnd = (int)Constants.RegionSize;
123
124
115 lock (m_regions) 125 lock (m_regions)
116 { 126 {
117 bool connectedYN = false; 127 bool connectedYN = false;
@@ -280,6 +290,7 @@ namespace OpenSim.Region.CoreModules.World.Land
280 //xxx 290 //xxx
281 //xxy 291 //xxy
282 //xxx 292 //xxx
293
283 if ((((int)conn.X * (int)Constants.RegionSize) + conn.XEnd 294 if ((((int)conn.X * (int)Constants.RegionSize) + conn.XEnd
284 >= (regionConnections.X * (int)Constants.RegionSize)) 295 >= (regionConnections.X * (int)Constants.RegionSize))
285 && (((int)conn.Y * (int)Constants.RegionSize) 296 && (((int)conn.Y * (int)Constants.RegionSize)
@@ -310,9 +321,13 @@ namespace OpenSim.Region.CoreModules.World.Land
310 ConnectedRegion.RegionScene = scene; 321 ConnectedRegion.RegionScene = scene;
311 conn.ConnectedRegions.Add(ConnectedRegion); 322 conn.ConnectedRegions.Add(ConnectedRegion);
312 323
324 // Inform root region Physics about the extents of this region
313 conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); 325 conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents);
326
327 // Inform Child region that it needs to forward it's terrain to the root region
314 scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); 328 scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero);
315 329
330 // Extend the borders as appropriate
316 lock (conn.RegionScene.EastBorders) 331 lock (conn.RegionScene.EastBorders)
317 conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; 332 conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize;
318 333
@@ -323,15 +338,24 @@ namespace OpenSim.Region.CoreModules.World.Land
323 conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; 338 conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize;
324 339
325 lock (scene.WestBorders) 340 lock (scene.WestBorders)
326 scene.WestBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport West 341 {
342 scene.WestBorders[0].BorderLine.Z += (int) Constants.RegionSize; //auto teleport West
327 343
328 // Reset Terrain.. since terrain normally loads first. 344 // Trigger auto teleport to root region
329 // 345 scene.WestBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX;
330 scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); 346 scene.WestBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY;
331 //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); 347 }
332 348
349 // Reset Terrain.. since terrain loads before we get here, we need to load
350 // it again so it loads in the root region
351
352 scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised());
353
354 // Unlock borders
333 conn.RegionScene.BordersLocked = false; 355 conn.RegionScene.BordersLocked = false;
334 scene.BordersLocked = false; 356 scene.BordersLocked = false;
357
358 // Create a client event forwarder and add this region's events to the root region.
335 if (conn.ClientEventForwarder != null) 359 if (conn.ClientEventForwarder != null)
336 conn.ClientEventForwarder.AddSceneToEventForwarding(scene); 360 conn.ClientEventForwarder.AddSceneToEventForwarding(scene);
337 connectedYN = true; 361 connectedYN = true;
@@ -381,7 +405,11 @@ namespace OpenSim.Region.CoreModules.World.Land
381 lock (conn.RegionScene.WestBorders) 405 lock (conn.RegionScene.WestBorders)
382 conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; 406 conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize;
383 lock (scene.SouthBorders) 407 lock (scene.SouthBorders)
384 scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south 408 {
409 scene.SouthBorders[0].BorderLine.Z += (int) Constants.RegionSize; //auto teleport south
410 scene.SouthBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX;
411 scene.SouthBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY;
412 }
385 413
386 // Reset Terrain.. since terrain normally loads first. 414 // Reset Terrain.. since terrain normally loads first.
387 //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); 415 //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised());
@@ -446,8 +474,13 @@ namespace OpenSim.Region.CoreModules.World.Land
446 conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; 474 conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize;
447 } 475 }
448 } 476 }
477
449 lock (scene.SouthBorders) 478 lock (scene.SouthBorders)
450 scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south 479 {
480 scene.SouthBorders[0].BorderLine.Z += (int) Constants.RegionSize; //auto teleport south
481 scene.SouthBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX;
482 scene.SouthBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY;
483 }
451 484
452 lock (conn.RegionScene.EastBorders) 485 lock (conn.RegionScene.EastBorders)
453 { 486 {
@@ -463,9 +496,14 @@ namespace OpenSim.Region.CoreModules.World.Land
463 496
464 } 497 }
465 } 498 }
466 499
467 lock (scene.WestBorders) 500 lock (scene.WestBorders)
468 scene.WestBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport West 501 {
502 scene.WestBorders[0].BorderLine.Z += (int) Constants.RegionSize; //auto teleport West
503 scene.WestBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX;
504 scene.WestBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY;
505 }
506
469 /* 507 /*
470 else 508 else
471 { 509 {
@@ -495,17 +533,21 @@ namespace OpenSim.Region.CoreModules.World.Land
495 } 533 }
496 } 534 }
497 535
536 // If !connectYN means that this region is a root region
498 if (!connectedYN) 537 if (!connectedYN)
499 { 538 {
500 RegionData rdata = new RegionData(); 539 RegionData rdata = new RegionData();
501 rdata.Offset = Vector3.Zero; 540 rdata.Offset = Vector3.Zero;
502 rdata.RegionId = scene.RegionInfo.originRegionID; 541 rdata.RegionId = scene.RegionInfo.originRegionID;
503 rdata.RegionScene = scene; 542 rdata.RegionScene = scene;
543 // save it's land channel
504 regionConnections.RegionLandChannel = scene.LandChannel; 544 regionConnections.RegionLandChannel = scene.LandChannel;
505 545
546 // Substitue our landchannel
506 RegionCombinerLargeLandChannel lnd = new RegionCombinerLargeLandChannel(rdata, scene.LandChannel, 547 RegionCombinerLargeLandChannel lnd = new RegionCombinerLargeLandChannel(rdata, scene.LandChannel,
507 regionConnections.ConnectedRegions); 548 regionConnections.ConnectedRegions);
508 scene.LandChannel = lnd; 549 scene.LandChannel = lnd;
550 // Forward the permissions modules of each of the connected regions to the root region
509 lock (m_regions) 551 lock (m_regions)
510 { 552 {
511 foreach (RegionData r in regionConnections.ConnectedRegions) 553 foreach (RegionData r in regionConnections.ConnectedRegions)
@@ -513,12 +555,17 @@ namespace OpenSim.Region.CoreModules.World.Land
513 ForwardPermissionRequests(regionConnections, r.RegionScene); 555 ForwardPermissionRequests(regionConnections, r.RegionScene);
514 } 556 }
515 } 557 }
516 558 // Create the root region's Client Event Forwarder
517 regionConnections.ClientEventForwarder = new RegionCombinerClientEventForwarder(regionConnections); 559 regionConnections.ClientEventForwarder = new RegionCombinerClientEventForwarder(regionConnections);
560
561 // Sets up the CoarseLocationUpdate forwarder for this root region
518 scene.EventManager.OnNewPresence += SetCourseLocationDelegate; 562 scene.EventManager.OnNewPresence += SetCourseLocationDelegate;
563
564 // Adds this root region to a dictionary of regions that are connectable
519 m_regions.Add(scene.RegionInfo.originRegionID, regionConnections); 565 m_regions.Add(scene.RegionInfo.originRegionID, regionConnections);
520 } 566 }
521 } 567 }
568 // Set up infinite borders around the entire AABB of the combined ConnectedRegions
522 AdjustLargeRegionBounds(); 569 AdjustLargeRegionBounds();
523 } 570 }
524 571
@@ -646,6 +693,13 @@ namespace OpenSim.Region.CoreModules.World.Land
646 } 693 }
647 } 694 }
648 695
696 /// <summary>
697 /// Locates a the Client of a particular region in an Array of RegionData based on offset
698 /// </summary>
699 /// <param name="offset"></param>
700 /// <param name="uUID"></param>
701 /// <param name="rdata"></param>
702 /// <returns>IClientAPI or null</returns>
649 private IClientAPI LocateUsersChildAgentIClientAPI(Vector2 offset, UUID uUID, RegionData[] rdata) 703 private IClientAPI LocateUsersChildAgentIClientAPI(Vector2 offset, UUID uUID, RegionData[] rdata)
650 { 704 {
651 IClientAPI returnclient = null; 705 IClientAPI returnclient = null;
@@ -664,6 +718,10 @@ namespace OpenSim.Region.CoreModules.World.Land
664 { 718 {
665 } 719 }
666 720
721 /// <summary>
722 /// TODO:
723 /// </summary>
724 /// <param name="rdata"></param>
667 public void UnCombineRegion(RegionData rdata) 725 public void UnCombineRegion(RegionData rdata)
668 { 726 {
669 lock (m_regions) 727 lock (m_regions)
@@ -706,7 +764,7 @@ namespace OpenSim.Region.CoreModules.World.Land
706 lock (rconn.RegionScene.NorthBorders) 764 lock (rconn.RegionScene.NorthBorders)
707 { 765 {
708 Border northBorder = null; 766 Border northBorder = null;
709 767 // If we don't already have an infinite border, create one.
710 if (!TryGetInfiniteBorder(rconn.RegionScene.NorthBorders, out northBorder)) 768 if (!TryGetInfiniteBorder(rconn.RegionScene.NorthBorders, out northBorder))
711 { 769 {
712 northBorder = new Border(); 770 northBorder = new Border();
@@ -721,6 +779,7 @@ namespace OpenSim.Region.CoreModules.World.Land
721 lock (rconn.RegionScene.SouthBorders) 779 lock (rconn.RegionScene.SouthBorders)
722 { 780 {
723 Border southBorder = null; 781 Border southBorder = null;
782 // If we don't already have an infinite border, create one.
724 if (!TryGetInfiniteBorder(rconn.RegionScene.SouthBorders, out southBorder)) 783 if (!TryGetInfiniteBorder(rconn.RegionScene.SouthBorders, out southBorder))
725 { 784 {
726 southBorder = new Border(); 785 southBorder = new Border();
@@ -733,6 +792,7 @@ namespace OpenSim.Region.CoreModules.World.Land
733 lock (rconn.RegionScene.EastBorders) 792 lock (rconn.RegionScene.EastBorders)
734 { 793 {
735 Border eastBorder = null; 794 Border eastBorder = null;
795 // If we don't already have an infinite border, create one.
736 if (!TryGetInfiniteBorder(rconn.RegionScene.EastBorders, out eastBorder)) 796 if (!TryGetInfiniteBorder(rconn.RegionScene.EastBorders, out eastBorder))
737 { 797 {
738 eastBorder = new Border(); 798 eastBorder = new Border();
@@ -746,6 +806,7 @@ namespace OpenSim.Region.CoreModules.World.Land
746 lock (rconn.RegionScene.WestBorders) 806 lock (rconn.RegionScene.WestBorders)
747 { 807 {
748 Border westBorder = null; 808 Border westBorder = null;
809 // If we don't already have an infinite border, create one.
749 if (!TryGetInfiniteBorder(rconn.RegionScene.WestBorders, out westBorder)) 810 if (!TryGetInfiniteBorder(rconn.RegionScene.WestBorders, out westBorder))
750 { 811 {
751 westBorder = new Border(); 812 westBorder = new Border();
@@ -761,6 +822,12 @@ namespace OpenSim.Region.CoreModules.World.Land
761 } 822 }
762 } 823 }
763 824
825 /// <summary>
826 /// Try and get an Infinite border out of a listT of borders
827 /// </summary>
828 /// <param name="borders"></param>
829 /// <param name="oborder"></param>
830 /// <returns></returns>
764 public static bool TryGetInfiniteBorder(List<Border> borders, out Border oborder) 831 public static bool TryGetInfiniteBorder(List<Border> borders, out Border oborder)
765 { 832 {
766 // Warning! Should be locked before getting here! 833 // Warning! Should be locked before getting here!
@@ -847,8 +914,19 @@ namespace OpenSim.Region.CoreModules.World.Land
847 914
848 public class RegionConnections 915 public class RegionConnections
849 { 916 {
917 /// <summary>
918 /// Root Region ID
919 /// </summary>
850 public UUID RegionId; 920 public UUID RegionId;
921
922 /// <summary>
923 /// Root Region Scene
924 /// </summary>
851 public Scene RegionScene; 925 public Scene RegionScene;
926
927 /// <summary>
928 /// LargeLandChannel for combined region
929 /// </summary>
852 public ILandChannel RegionLandChannel; 930 public ILandChannel RegionLandChannel;
853 public uint X; 931 public uint X;
854 public uint Y; 932 public uint Y;
@@ -1323,7 +1401,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1323 m_virtScene.UnSubscribeToClientPrimRezEvents(client); 1401 m_virtScene.UnSubscribeToClientPrimRezEvents(client);
1324 m_virtScene.UnSubscribeToClientInventoryEvents(client); 1402 m_virtScene.UnSubscribeToClientInventoryEvents(client);
1325 m_virtScene.UnSubscribeToClientAttachmentEvents(client); 1403 m_virtScene.UnSubscribeToClientAttachmentEvents(client);
1326 m_virtScene.UnSubscribeToClientTeleportEvents(client); 1404 //m_virtScene.UnSubscribeToClientTeleportEvents(client);
1327 m_virtScene.UnSubscribeToClientScriptEvents(client); 1405 m_virtScene.UnSubscribeToClientScriptEvents(client);
1328 m_virtScene.UnSubscribeToClientGodEvents(client); 1406 m_virtScene.UnSubscribeToClientGodEvents(client);
1329 m_virtScene.UnSubscribeToClientNetworkEvents(client); 1407 m_virtScene.UnSubscribeToClientNetworkEvents(client);
@@ -1333,7 +1411,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1333 client.OnRezObject += LocalRezObject; 1411 client.OnRezObject += LocalRezObject;
1334 m_rootScene.SubscribeToClientInventoryEvents(client); 1412 m_rootScene.SubscribeToClientInventoryEvents(client);
1335 m_rootScene.SubscribeToClientAttachmentEvents(client); 1413 m_rootScene.SubscribeToClientAttachmentEvents(client);
1336 m_rootScene.SubscribeToClientTeleportEvents(client); 1414 //m_rootScene.SubscribeToClientTeleportEvents(client);
1337 m_rootScene.SubscribeToClientScriptEvents(client); 1415 m_rootScene.SubscribeToClientScriptEvents(client);
1338 m_rootScene.SubscribeToClientGodEvents(client); 1416 m_rootScene.SubscribeToClientGodEvents(client);
1339 m_rootScene.SubscribeToClientNetworkEvents(client); 1417 m_rootScene.SubscribeToClientNetworkEvents(client);
@@ -1343,6 +1421,19 @@ namespace OpenSim.Region.CoreModules.World.Land
1343 { 1421 {
1344 } 1422 }
1345 1423
1424 /// <summary>
1425 /// Fixes position based on the region the Rez event came in on
1426 /// </summary>
1427 /// <param name="remoteclient"></param>
1428 /// <param name="itemid"></param>
1429 /// <param name="rayend"></param>
1430 /// <param name="raystart"></param>
1431 /// <param name="raytargetid"></param>
1432 /// <param name="bypassraycast"></param>
1433 /// <param name="rayendisintersection"></param>
1434 /// <param name="rezselected"></param>
1435 /// <param name="removeitem"></param>
1436 /// <param name="fromtaskid"></param>
1346 private void LocalRezObject(IClientAPI remoteclient, UUID itemid, Vector3 rayend, Vector3 raystart, 1437 private void LocalRezObject(IClientAPI remoteclient, UUID itemid, Vector3 rayend, Vector3 raystart,
1347 UUID raytargetid, byte bypassraycast, bool rayendisintersection, bool rezselected, bool removeitem, 1438 UUID raytargetid, byte bypassraycast, bool rayendisintersection, bool rezselected, bool removeitem,
1348 UUID fromtaskid) 1439 UUID fromtaskid)
@@ -1357,7 +1448,18 @@ namespace OpenSim.Region.CoreModules.World.Land
1357 m_rootScene.RezObject(remoteclient, itemid, rayend, raystart, raytargetid, bypassraycast, 1448 m_rootScene.RezObject(remoteclient, itemid, rayend, raystart, raytargetid, bypassraycast,
1358 rayendisintersection, rezselected, removeitem, fromtaskid); 1449 rayendisintersection, rezselected, removeitem, fromtaskid);
1359 } 1450 }
1360 1451 /// <summary>
1452 /// Fixes position based on the region the AddPrimShape event came in on
1453 /// </summary>
1454 /// <param name="ownerid"></param>
1455 /// <param name="groupid"></param>
1456 /// <param name="rayend"></param>
1457 /// <param name="rot"></param>
1458 /// <param name="shape"></param>
1459 /// <param name="bypassraycast"></param>
1460 /// <param name="raystart"></param>
1461 /// <param name="raytargetid"></param>
1462 /// <param name="rayendisintersection"></param>
1361 private void LocalAddNewPrim(UUID ownerid, UUID groupid, Vector3 rayend, Quaternion rot, 1463 private void LocalAddNewPrim(UUID ownerid, UUID groupid, Vector3 rayend, Quaternion rot,
1362 PrimitiveBaseShape shape, byte bypassraycast, Vector3 raystart, UUID raytargetid, 1464 PrimitiveBaseShape shape, byte bypassraycast, Vector3 raystart, UUID raytargetid,
1363 byte rayendisintersection) 1465 byte rayendisintersection)
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index 1c71a99..b38148b 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -1074,7 +1074,7 @@ namespace OpenSim.Region.Framework.Scenes
1074 if (eq != null) 1074 if (eq != null)
1075 { 1075 {
1076 eq.TeleportFinishEvent(reg.RegionHandle, 13, endPoint, 1076 eq.TeleportFinishEvent(reg.RegionHandle, 13, endPoint,
1077 4, teleportFlags, capsPath, avatar.UUID); 1077 0, teleportFlags, capsPath, avatar.UUID);
1078 } 1078 }
1079 else 1079 else
1080 { 1080 {
@@ -1269,16 +1269,53 @@ namespace OpenSim.Region.Framework.Scenes
1269 if (scene.TestBorderCross(pos + northCross, Cardinals.N)) 1269 if (scene.TestBorderCross(pos + northCross, Cardinals.N))
1270 { 1270 {
1271 Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N); 1271 Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
1272 neighboury += (uint)(int)(b.BorderLine.Z/(int)Constants.RegionSize); 1272 neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
1273 } 1273 }
1274 else if (scene.TestBorderCross(pos + southCross, Cardinals.S)) 1274 else if (scene.TestBorderCross(pos + southCross, Cardinals.S))
1275 { 1275 {
1276 neighboury--; 1276 Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S);
1277 newpos.Y = Constants.RegionSize - enterDistance; 1277 if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0)
1278 {
1279 neighboury--;
1280 newpos.Y = Constants.RegionSize - enterDistance;
1281 }
1282 else
1283 {
1284 neighboury = b.TriggerRegionY;
1285 neighbourx = b.TriggerRegionX;
1286
1287 Vector3 newposition = pos;
1288 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1289 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1290 agent.ControllingClient.SendAgentAlertMessage(
1291 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1292 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1293 return;
1294 }
1278 } 1295 }
1279 1296
1280 neighbourx--; 1297 Border ba = scene.GetCrossedBorder(pos + westCross, Cardinals.W);
1281 newpos.X = Constants.RegionSize - enterDistance; 1298 if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0)
1299 {
1300 neighbourx--;
1301 newpos.X = Constants.RegionSize - enterDistance;
1302 }
1303 else
1304 {
1305 neighboury = ba.TriggerRegionY;
1306 neighbourx = ba.TriggerRegionX;
1307
1308
1309 Vector3 newposition = pos;
1310 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1311 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1312 agent.ControllingClient.SendAgentAlertMessage(
1313 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1314 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1315
1316
1317 return;
1318 }
1282 1319
1283 } 1320 }
1284 else if (scene.TestBorderCross(pos + eastCross, Cardinals.E)) 1321 else if (scene.TestBorderCross(pos + eastCross, Cardinals.E))
@@ -1289,8 +1326,24 @@ namespace OpenSim.Region.Framework.Scenes
1289 1326
1290 if (scene.TestBorderCross(pos + southCross, Cardinals.S)) 1327 if (scene.TestBorderCross(pos + southCross, Cardinals.S))
1291 { 1328 {
1292 neighboury--; 1329 Border ba = scene.GetCrossedBorder(pos + southCross, Cardinals.S);
1293 newpos.Y = Constants.RegionSize - enterDistance; 1330 if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0)
1331 {
1332 neighboury--;
1333 newpos.Y = Constants.RegionSize - enterDistance;
1334 }
1335 else
1336 {
1337 neighboury = ba.TriggerRegionY;
1338 neighbourx = ba.TriggerRegionX;
1339 Vector3 newposition = pos;
1340 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1341 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1342 agent.ControllingClient.SendAgentAlertMessage(
1343 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1344 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1345 return;
1346 }
1294 } 1347 }
1295 else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) 1348 else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
1296 { 1349 {
@@ -1298,16 +1351,33 @@ namespace OpenSim.Region.Framework.Scenes
1298 neighboury += (uint)(int)(c.BorderLine.Z / (int)Constants.RegionSize); 1351 neighboury += (uint)(int)(c.BorderLine.Z / (int)Constants.RegionSize);
1299 newpos.Y = enterDistance; 1352 newpos.Y = enterDistance;
1300 } 1353 }
1301 1354
1302 1355
1303 } 1356 }
1304 else if (scene.TestBorderCross(pos + southCross, Cardinals.S)) 1357 else if (scene.TestBorderCross(pos + southCross, Cardinals.S))
1305 { 1358 {
1306 neighboury--; 1359 Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S);
1307 newpos.Y = Constants.RegionSize - enterDistance; 1360 if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0)
1361 {
1362 neighboury--;
1363 newpos.Y = Constants.RegionSize - enterDistance;
1364 }
1365 else
1366 {
1367 neighboury = b.TriggerRegionY;
1368 neighbourx = b.TriggerRegionX;
1369 Vector3 newposition = pos;
1370 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1371 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1372 agent.ControllingClient.SendAgentAlertMessage(
1373 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1374 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1375 return;
1376 }
1308 } 1377 }
1309 else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) 1378 else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
1310 { 1379 {
1380
1311 Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N); 1381 Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
1312 neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize); 1382 neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
1313 newpos.Y = enterDistance; 1383 newpos.Y = enterDistance;
@@ -1342,6 +1412,38 @@ namespace OpenSim.Region.Framework.Scenes
1342 d.BeginInvoke(agent, newpos, neighbourx, neighboury, isFlying, CrossAgentToNewRegionCompleted, d); 1412 d.BeginInvoke(agent, newpos, neighbourx, neighboury, isFlying, CrossAgentToNewRegionCompleted, d);
1343 } 1413 }
1344 1414
1415 public void InformClientToInitateTeleportToLocation(ScenePresence agent, uint regionX, uint regionY, Vector3 position, Scene initiatingScene)
1416 {
1417 Util.FireAndForget(delegate
1418 {
1419 Thread.Sleep(10000);
1420 IMessageTransferModule im = initiatingScene.RequestModuleInterface<IMessageTransferModule>();
1421 if (im != null)
1422 {
1423 UUID gotoLocation = Util.BuildFakeParcelID(
1424 Util.UIntsToLong(
1425 (regionX *
1426 (uint)Constants.RegionSize),
1427 (regionY *
1428 (uint)Constants.RegionSize)),
1429 (uint)(int)position.X,
1430 (uint)(int)position.Y,
1431 (uint)(int)position.Z);
1432 GridInstantMessage m = new GridInstantMessage(initiatingScene, UUID.Zero,
1433 "Region", agent.UUID,
1434 (byte)InstantMessageDialog.GodLikeRequestTeleport, false,
1435 "", gotoLocation, false, new Vector3(127, 0, 0),
1436 new Byte[0]);
1437 im.SendInstantMessage(m, delegate(bool success)
1438 {
1439 m_log.DebugFormat("[CLIENT]: Client Initiating Teleport sending IM success = {0}", success);
1440 });
1441
1442 }
1443
1444 });
1445 }
1446
1345 public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying); 1447 public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying);
1346 1448
1347 /// <summary> 1449 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 1024857..23fe2d3 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -776,8 +776,20 @@ namespace OpenSim.Region.Framework.Scenes
776 // before the inventory is processed in MakeRootAgent. This fixes a race condition 776 // before the inventory is processed in MakeRootAgent. This fixes a race condition
777 // related to the handling of attachments 777 // related to the handling of attachments
778 //m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); 778 //m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance);
779 if (m_scene.TestBorderCross(pos, Cardinals.E))
780 {
781 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E);
782 pos.X = crossedBorder.BorderLine.Z - 1;
783 }
784
785 if (m_scene.TestBorderCross(pos, Cardinals.N))
786 {
787 Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N);
788 pos.Y = crossedBorder.BorderLine.Z - 1;
789 }
790
779 791
780 if (pos.X < 0 || pos.X >= (int)Constants.RegionSize || pos.Y < 0 || pos.Y >= (int)Constants.RegionSize || pos.Z < 0) 792 if (pos.X < 0 || pos.Y < 0 || pos.Z < 0)
781 { 793 {
782 Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128); 794 Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128);
783 795
@@ -795,7 +807,11 @@ namespace OpenSim.Region.Framework.Scenes
795 localAVHeight = m_avHeight; 807 localAVHeight = m_avHeight;
796 } 808 }
797 809
798 float posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; 810 float posZLimit = 0;
811
812 if (pos.X <Constants.RegionSize && pos.Y < Constants.RegionSize)
813 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y];
814
799 float newPosZ = posZLimit + localAVHeight / 2; 815 float newPosZ = posZLimit + localAVHeight / 2;
800 if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) 816 if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
801 { 817 {
@@ -877,6 +893,7 @@ namespace OpenSim.Region.Framework.Scenes
877 m_isChildAgent = true; 893 m_isChildAgent = true;
878 m_scene.SwapRootAgentCount(true); 894 m_scene.SwapRootAgentCount(true);
879 RemoveFromPhysicalScene(); 895 RemoveFromPhysicalScene();
896
880 m_scene.EventManager.TriggerOnMakeChildAgent(this); 897 m_scene.EventManager.TriggerOnMakeChildAgent(this);
881 } 898 }
882 899
@@ -904,7 +921,7 @@ namespace OpenSim.Region.Framework.Scenes
904 bool isFlying = false; 921 bool isFlying = false;
905 if (m_physicsActor != null) 922 if (m_physicsActor != null)
906 isFlying = m_physicsActor.Flying; 923 isFlying = m_physicsActor.Flying;
907 924
908 RemoveFromPhysicalScene(); 925 RemoveFromPhysicalScene();
909 Velocity = new Vector3(0, 0, 0); 926 Velocity = new Vector3(0, 0, 0);
910 AbsolutePosition = pos; 927 AbsolutePosition = pos;
@@ -2412,7 +2429,8 @@ namespace OpenSim.Region.Framework.Scenes
2412 } 2429 }
2413 2430
2414 // followed suggestion from mic bowman. reversed the two lines below. 2431 // followed suggestion from mic bowman. reversed the two lines below.
2415 CheckForBorderCrossing(); 2432 if (m_parentID == 0 && m_physicsActor != null || m_parentID != 0) // Check that we have a physics actor or we're sitting on something
2433 CheckForBorderCrossing();
2416 CheckForSignificantMovement(); // sends update to the modules. 2434 CheckForSignificantMovement(); // sends update to the modules.
2417 } 2435 }
2418 } 2436 }