aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorDiva Canto2014-02-21 10:05:06 -0800
committerDiva Canto2014-02-21 10:05:06 -0800
commit97c74afca897acf8f000b0560ff041fd51897e5b (patch)
tree71efc4ababc6f428de291a56e289fa158cbf2272 /OpenSim/Region/Framework
parentAdded 2 new behavirors to pCampBot. These are part of a systematic study I'm ... (diff)
parentIf texture decode fails in Warp3D map maker, log uuid of asset that failed to... (diff)
downloadopensim-SC-97c74afca897acf8f000b0560ff041fd51897e5b.zip
opensim-SC-97c74afca897acf8f000b0560ff041fd51897e5b.tar.gz
opensim-SC-97c74afca897acf8f000b0560ff041fd51897e5b.tar.bz2
opensim-SC-97c74afca897acf8f000b0560ff041fd51897e5b.tar.xz
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs5
-rw-r--r--OpenSim/Region/Framework/Interfaces/IRegionCombinerModule.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs24
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs302
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs22
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs9
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs64
7 files changed, 110 insertions, 321 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
index 709d8fc..5d07a5f 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
@@ -92,11 +92,12 @@ namespace OpenSim.Region.Framework.Interfaces
92 92
93 void EnableChildAgent(ScenePresence agent, GridRegion region); 93 void EnableChildAgent(ScenePresence agent, GridRegion region);
94 94
95 GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, out string version, out Vector3 newpos); 95 GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, out string version,
96 out Vector3 newpos, out string reason);
96 97
97 void Cross(SceneObjectGroup sog, Vector3 position, bool silent); 98 void Cross(SceneObjectGroup sog, Vector3 position, bool silent);
98 99
99 ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, bool isFlying, string version); 100 ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, bool isFlying, string version);
100 } 101 }
101 102
102 public interface IUserAgentVerificationModule 103 public interface IUserAgentVerificationModule
diff --git a/OpenSim/Region/Framework/Interfaces/IRegionCombinerModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionCombinerModule.cs
index e03ac5a..c6f531e 100644
--- a/OpenSim/Region/Framework/Interfaces/IRegionCombinerModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IRegionCombinerModule.cs
@@ -55,5 +55,10 @@ namespace OpenSim.Region.Framework.Interfaces
55 /// Currently, will throw an exception if this does not match a root region. 55 /// Currently, will throw an exception if this does not match a root region.
56 /// </param> 56 /// </param>
57 Vector2 GetSizeOfMegaregion(UUID regionId); 57 Vector2 GetSizeOfMegaregion(UUID regionId);
58
59 /// <summary>
60 /// Tests to see of position (relative to the region) is within the megaregion
61 /// </summary>
62 bool PositionIsInMegaregion(UUID currentRegion, int xx, int yy);
58 } 63 }
59} \ No newline at end of file 64} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 37b5776..ba79964 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -430,6 +430,9 @@ namespace OpenSim.Region.Framework.Scenes
430 public delegate void IncomingInstantMessage(GridInstantMessage message); 430 public delegate void IncomingInstantMessage(GridInstantMessage message);
431 public event IncomingInstantMessage OnIncomingInstantMessage; 431 public event IncomingInstantMessage OnIncomingInstantMessage;
432 432
433 public delegate void CrossAgentToNewRegion(ScenePresence sp, bool isFlying, GridRegion newRegion);
434 public event CrossAgentToNewRegion OnCrossAgentToNewRegion;
435
433 public event IncomingInstantMessage OnUnhandledInstantMessage; 436 public event IncomingInstantMessage OnUnhandledInstantMessage;
434 437
435 public delegate void ClientClosed(UUID clientID, Scene scene); 438 public delegate void ClientClosed(UUID clientID, Scene scene);
@@ -1960,6 +1963,27 @@ namespace OpenSim.Region.Framework.Scenes
1960 } 1963 }
1961 } 1964 }
1962 1965
1966 public void TriggerCrossAgentToNewRegion(ScenePresence agent, bool isFlying, GridRegion newRegion)
1967 {
1968 CrossAgentToNewRegion handlerCrossAgentToNewRegion = OnCrossAgentToNewRegion;
1969 if (handlerCrossAgentToNewRegion != null)
1970 {
1971 foreach (CrossAgentToNewRegion d in handlerCrossAgentToNewRegion.GetInvocationList())
1972 {
1973 try
1974 {
1975 d(agent, isFlying, newRegion);
1976 }
1977 catch (Exception e)
1978 {
1979 m_log.ErrorFormat(
1980 "[EVENT MANAGER]: Delegate for TriggerCrossAgentToNewRegion failed - continuing. {0} {1}",
1981 e.Message, e.StackTrace);
1982 }
1983 }
1984 }
1985 }
1986
1963 public void TriggerIncomingInstantMessage(GridInstantMessage message) 1987 public void TriggerIncomingInstantMessage(GridInstantMessage message)
1964 { 1988 {
1965 IncomingInstantMessage handlerIncomingInstantMessage = OnIncomingInstantMessage; 1989 IncomingInstantMessage handlerIncomingInstantMessage = OnIncomingInstantMessage;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 2f666c0..676c000 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -160,11 +160,6 @@ namespace OpenSim.Region.Framework.Scenes
160 /// </summary> 160 /// </summary>
161 public SimStatsReporter StatsReporter { get; private set; } 161 public SimStatsReporter StatsReporter { get; private set; }
162 162
163 public List<Border> NorthBorders = new List<Border>();
164 public List<Border> EastBorders = new List<Border>();
165 public List<Border> SouthBorders = new List<Border>();
166 public List<Border> WestBorders = new List<Border>();
167
168 /// <summary> 163 /// <summary>
169 /// Controls whether physics can be applied to prims. Even if false, prims still have entries in a 164 /// Controls whether physics can be applied to prims. Even if false, prims still have entries in a
170 /// PhysicsScene in order to perform collision detection 165 /// PhysicsScene in order to perform collision detection
@@ -218,7 +213,14 @@ namespace OpenSim.Region.Framework.Scenes
218 protected float m_defaultDrawDistance = 255.0f; 213 protected float m_defaultDrawDistance = 255.0f;
219 public float DefaultDrawDistance 214 public float DefaultDrawDistance
220 { 215 {
221 get { return m_defaultDrawDistance; } 216 // get { return m_defaultDrawDistance; }
217 get {
218 if (RegionInfo != null)
219 {
220 m_defaultDrawDistance = Math.Max(RegionInfo.RegionSizeX, RegionInfo.RegionSizeY);
221 }
222 return m_defaultDrawDistance;
223 }
222 } 224 }
223 225
224 private List<string> m_AllowedViewers = new List<string>(); 226 private List<string> m_AllowedViewers = new List<string>();
@@ -349,7 +351,6 @@ namespace OpenSim.Region.Framework.Scenes
349 351
350 // TODO: Possibly stop other classes being able to manipulate this directly. 352 // TODO: Possibly stop other classes being able to manipulate this directly.
351 private SceneGraph m_sceneGraph; 353 private SceneGraph m_sceneGraph;
352 private volatile int m_bordersLocked;
353 private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing 354 private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing
354 private volatile bool m_backingup; 355 private volatile bool m_backingup;
355 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); 356 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>();
@@ -426,18 +427,6 @@ namespace OpenSim.Region.Framework.Scenes
426 set { m_splitRegionID = value; } 427 set { m_splitRegionID = value; }
427 } 428 }
428 429
429 public bool BordersLocked
430 {
431 get { return m_bordersLocked == 1; }
432 set
433 {
434 if (value == true)
435 m_bordersLocked = 1;
436 else
437 m_bordersLocked = 0;
438 }
439 }
440
441 public new float TimeDilation 430 public new float TimeDilation
442 { 431 {
443 get { return m_sceneGraph.PhysicsScene.TimeDilation; } 432 get { return m_sceneGraph.PhysicsScene.TimeDilation; }
@@ -1031,28 +1020,6 @@ namespace OpenSim.Region.Framework.Scenes
1031 PeriodicBackup = true; 1020 PeriodicBackup = true;
1032 UseBackup = true; 1021 UseBackup = true;
1033 1022
1034 BordersLocked = true;
1035 Border northBorder = new Border();
1036 northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (float)RegionInfo.RegionSizeY); //<---
1037 northBorder.CrossDirection = Cardinals.N;
1038 NorthBorders.Add(northBorder);
1039
1040 Border southBorder = new Border();
1041 southBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue,0); //--->
1042 southBorder.CrossDirection = Cardinals.S;
1043 SouthBorders.Add(southBorder);
1044
1045 Border eastBorder = new Border();
1046 eastBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (float)RegionInfo.RegionSizeY); //<---
1047 eastBorder.CrossDirection = Cardinals.E;
1048 EastBorders.Add(eastBorder);
1049
1050 Border westBorder = new Border();
1051 westBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue,0); //--->
1052 westBorder.CrossDirection = Cardinals.W;
1053 WestBorders.Add(westBorder);
1054 BordersLocked = false;
1055
1056 m_eventManager = new EventManager(); 1023 m_eventManager = new EventManager();
1057 1024
1058 m_permissions = new ScenePermissions(this); 1025 m_permissions = new ScenePermissions(this);
@@ -2445,201 +2412,34 @@ namespace OpenSim.Region.Framework.Scenes
2445 } 2412 }
2446 2413
2447 // Simple test to see if a position is in the current region. 2414 // Simple test to see if a position is in the current region.
2448 // Resuming the position is relative to the region so anything outside its bounds. 2415 // This test is mostly used to see if a region crossing is necessary.
2416 // Assuming the position is relative to the region so anything outside its bounds.
2449 // Return 'true' if position inside region. 2417 // Return 'true' if position inside region.
2450 public bool PositionIsInCurrentRegion(Vector3 pos) 2418 public bool PositionIsInCurrentRegion(Vector3 pos)
2451 { 2419 {
2452 bool ret = true; 2420 bool ret = false;
2453 int xx = (int)Math.Floor(pos.X); 2421 int xx = (int)Math.Floor(pos.X);
2454 int yy = (int)Math.Floor(pos.Y); 2422 int yy = (int)Math.Floor(pos.Y);
2455 if (xx < 0 2423 if (xx < 0 || yy < 0)
2456 || xx >= RegionInfo.RegionSizeX 2424 return false;
2457 || yy < 0
2458 || yy >= RegionInfo.RegionSizeY)
2459 ret = false;
2460 return ret;
2461
2462 }
2463 2425
2464 public Border GetCrossedBorder(Vector3 position, Cardinals gridline) 2426 IRegionCombinerModule regionCombinerModule = RequestModuleInterface<IRegionCombinerModule>();
2465 { 2427 if (regionCombinerModule == null)
2466 if (BordersLocked)
2467 { 2428 {
2468 switch (gridline) 2429 // Regular region. Just check for region size
2469 { 2430 if (xx < RegionInfo.RegionSizeX && yy < RegionInfo.RegionSizeY )
2470 case Cardinals.N: 2431 ret = true;
2471 lock (NorthBorders)
2472 {
2473 foreach (Border b in NorthBorders)
2474 {
2475 if (b.TestCross(position))
2476 return b;
2477 }
2478 }
2479 break;
2480 case Cardinals.S:
2481 lock (SouthBorders)
2482 {
2483 foreach (Border b in SouthBorders)
2484 {
2485 if (b.TestCross(position))
2486 return b;
2487 }
2488 }
2489
2490 break;
2491 case Cardinals.E:
2492 lock (EastBorders)
2493 {
2494 foreach (Border b in EastBorders)
2495 {
2496 if (b.TestCross(position))
2497 return b;
2498 }
2499 }
2500
2501 break;
2502 case Cardinals.W:
2503
2504 lock (WestBorders)
2505 {
2506 foreach (Border b in WestBorders)
2507 {
2508 if (b.TestCross(position))
2509 return b;
2510 }
2511 }
2512 break;
2513
2514 }
2515 } 2432 }
2516 else 2433 else
2517 { 2434 {
2518 switch (gridline) 2435 // We're in a mega-region so see if we are still in that larger region
2519 { 2436 ret = regionCombinerModule.PositionIsInMegaregion(this.RegionInfo.RegionID, xx, yy);
2520 case Cardinals.N:
2521 foreach (Border b in NorthBorders)
2522 {
2523 if (b.TestCross(position))
2524 return b;
2525 }
2526
2527 break;
2528 case Cardinals.S:
2529 foreach (Border b in SouthBorders)
2530 {
2531 if (b.TestCross(position))
2532 return b;
2533 }
2534 break;
2535 case Cardinals.E:
2536 foreach (Border b in EastBorders)
2537 {
2538 if (b.TestCross(position))
2539 return b;
2540 }
2541
2542 break;
2543 case Cardinals.W:
2544 foreach (Border b in WestBorders)
2545 {
2546 if (b.TestCross(position))
2547 return b;
2548 }
2549 break;
2550
2551 }
2552 } 2437 }
2553 2438
2554 return null; 2439 return ret;
2555 }
2556 2440
2557 public bool TestBorderCross(Vector3 position, Cardinals border)
2558 {
2559 if (BordersLocked)
2560 {
2561 switch (border)
2562 {
2563 case Cardinals.N:
2564 lock (NorthBorders)
2565 {
2566 foreach (Border b in NorthBorders)
2567 {
2568 if (b.TestCross(position))
2569 return true;
2570 }
2571 }
2572 break;
2573 case Cardinals.E:
2574 lock (EastBorders)
2575 {
2576 foreach (Border b in EastBorders)
2577 {
2578 if (b.TestCross(position))
2579 return true;
2580 }
2581 }
2582 break;
2583 case Cardinals.S:
2584 lock (SouthBorders)
2585 {
2586 foreach (Border b in SouthBorders)
2587 {
2588 if (b.TestCross(position))
2589 return true;
2590 }
2591 }
2592 break;
2593 case Cardinals.W:
2594 lock (WestBorders)
2595 {
2596 foreach (Border b in WestBorders)
2597 {
2598 if (b.TestCross(position))
2599 return true;
2600 }
2601 }
2602 break;
2603 }
2604 }
2605 else
2606 {
2607 switch (border)
2608 {
2609 case Cardinals.N:
2610 foreach (Border b in NorthBorders)
2611 {
2612 if (b.TestCross(position))
2613 return true;
2614 }
2615 break;
2616 case Cardinals.E:
2617 foreach (Border b in EastBorders)
2618 {
2619 if (b.TestCross(position))
2620 return true;
2621 }
2622 break;
2623 case Cardinals.S:
2624 foreach (Border b in SouthBorders)
2625 {
2626 if (b.TestCross(position))
2627 return true;
2628 }
2629 break;
2630 case Cardinals.W:
2631 foreach (Border b in WestBorders)
2632 {
2633 if (b.TestCross(position))
2634 return true;
2635 }
2636 break;
2637 }
2638 }
2639 return false;
2640 } 2441 }
2641 2442
2642
2643 /// <summary> 2443 /// <summary>
2644 /// Called when objects or attachments cross the border, or teleport, between regions. 2444 /// Called when objects or attachments cross the border, or teleport, between regions.
2645 /// </summary> 2445 /// </summary>
@@ -3874,61 +3674,11 @@ namespace OpenSim.Region.Framework.Scenes
3874 { 3674 {
3875// CleanDroppedAttachments(); 3675// CleanDroppedAttachments();
3876 3676
3877 if (TestBorderCross(acd.startpos, Cardinals.E)) 3677 // Make sure avatar position is in the region (why it wouldn't be is a mystery but do sanity checking)
3878 { 3678 if (acd.startpos.X < 0) acd.startpos.X = 1f;
3879 Border crossedBorder = GetCrossedBorder(acd.startpos, Cardinals.E); 3679 if (acd.startpos.X >= RegionInfo.RegionSizeX) acd.startpos.X = RegionInfo.RegionSizeX - 1f;
3880 acd.startpos.X = crossedBorder.BorderLine.Z - 1; 3680 if (acd.startpos.Y < 0) acd.startpos.Y = 1f;
3881 m_log.DebugFormat("{0} NewUserConnection Adjusted border E. startpos={1}", LogHeader, acd.startpos); 3681 if (acd.startpos.Y >= RegionInfo.RegionSizeY) acd.startpos.Y = RegionInfo.RegionSizeY - 1f;
3882 }
3883
3884 if (TestBorderCross(acd.startpos, Cardinals.N))
3885 {
3886 Border crossedBorder = GetCrossedBorder(acd.startpos, Cardinals.N);
3887 acd.startpos.Y = crossedBorder.BorderLine.Z - 1;
3888 }
3889
3890 //Mitigate http://opensimulator.org/mantis/view.php?id=3522
3891 // Check if start position is outside of region
3892 // If it is, check the Z start position also.. if not, leave it alone.
3893 if (BordersLocked)
3894 {
3895 lock (EastBorders)
3896 {
3897 if (acd.startpos.X > EastBorders[0].BorderLine.Z)
3898 {
3899 m_log.Warn("FIX AGENT POSITION");
3900 acd.startpos.X = EastBorders[0].BorderLine.Z * 0.5f;
3901 if (acd.startpos.Z > 720)
3902 acd.startpos.Z = 720;
3903 }
3904 }
3905 lock (NorthBorders)
3906 {
3907 if (acd.startpos.Y > NorthBorders[0].BorderLine.Z)
3908 {
3909 m_log.Warn("FIX Agent POSITION");
3910 acd.startpos.Y = NorthBorders[0].BorderLine.Z * 0.5f;
3911 if (acd.startpos.Z > 720)
3912 acd.startpos.Z = 720;
3913 }
3914 }
3915 } else
3916 {
3917 if (acd.startpos.X > EastBorders[0].BorderLine.Z)
3918 {
3919 m_log.Warn("FIX AGENT POSITION");
3920 acd.startpos.X = EastBorders[0].BorderLine.Z * 0.5f;
3921 if (acd.startpos.Z > 720)
3922 acd.startpos.Z = 720;
3923 }
3924 if (acd.startpos.Y > NorthBorders[0].BorderLine.Z)
3925 {
3926 m_log.Warn("FIX Agent POSITION");
3927 acd.startpos.Y = NorthBorders[0].BorderLine.Z * 0.5f;
3928 if (acd.startpos.Z > 720)
3929 acd.startpos.Z = 720;
3930 }
3931 }
3932 3682
3933// m_log.DebugFormat( 3683// m_log.DebugFormat(
3934// "[SCENE]: Found telehub object {0} for new user connection {1} to {2}", 3684// "[SCENE]: Found telehub object {0} for new user connection {1} to {2}",
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index c6b98ca..73a30f3 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -429,7 +429,7 @@ namespace OpenSim.Region.Framework.Scenes
429 /// <returns></returns> 429 /// <returns></returns>
430 public bool IsAttachmentCheckFull() 430 public bool IsAttachmentCheckFull()
431 { 431 {
432 return (IsAttachment || (m_rootPart.Shape.PCode == 9 && m_rootPart.Shape.State != 0)); 432 return (IsAttachment || (m_rootPart.Shape.PCode == (byte)PCodeEnum.Primitive && m_rootPart.Shape.State != 0));
433 } 433 }
434 434
435 private struct avtocrossInfo 435 private struct avtocrossInfo
@@ -451,23 +451,15 @@ namespace OpenSim.Region.Framework.Scenes
451 if (Scene != null) 451 if (Scene != null)
452 { 452 {
453 if ( 453 if (
454 // (Scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) 454 !Scene.PositionIsInCurrentRegion(val)
455 // || Scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W) 455 && !IsAttachmentCheckFull()
456 // || Scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) 456 && (!Scene.LoadingPrims)
457 // || Scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S)) 457 )
458 // Experimental change for better border crossings.
459 // The commented out original lines above would, it seems, trigger
460 // a border crossing a little early or late depending on which
461 // direction the object was moving.
462 (Scene.TestBorderCross(val, Cardinals.E)
463 || Scene.TestBorderCross(val, Cardinals.W)
464 || Scene.TestBorderCross(val, Cardinals.N)
465 || Scene.TestBorderCross(val, Cardinals.S))
466 && !IsAttachmentCheckFull() && (!Scene.LoadingPrims))
467 { 458 {
468 IEntityTransferModule entityTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); 459 IEntityTransferModule entityTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
469 string version = String.Empty; 460 string version = String.Empty;
470 Vector3 newpos = Vector3.Zero; 461 Vector3 newpos = Vector3.Zero;
462 string failureReason = String.Empty;
471 OpenSim.Services.Interfaces.GridRegion destination = null; 463 OpenSim.Services.Interfaces.GridRegion destination = null;
472 464
473 if (m_rootPart.KeyframeMotion != null) 465 if (m_rootPart.KeyframeMotion != null)
@@ -485,7 +477,7 @@ namespace OpenSim.Region.Framework.Scenes
485 477
486 // We set the avatar position as being the object 478 // We set the avatar position as being the object
487 // position to get the region to send to 479 // position to get the region to send to
488 if ((destination = entityTransfer.GetDestination(m_scene, av.UUID, val, out version, out newpos)) == null) 480 if ((destination = entityTransfer.GetDestination(m_scene, av.UUID, val, out version, out newpos, out failureReason)) == null)
489 { 481 {
490 canCross = false; 482 canCross = false;
491 break; 483 break;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 1cf7726..db4e285 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -2479,13 +2479,10 @@ namespace OpenSim.Region.Framework.Scenes
2479 2479
2480 if (pa != null) 2480 if (pa != null)
2481 { 2481 {
2482 Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0); 2482 Vector3 newpos = pa.Position;
2483 2483 if (!ParentGroup.Scene.PositionIsInCurrentRegion(newpos))
2484 if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N)
2485 | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S)
2486 | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E)
2487 | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W))
2488 { 2484 {
2485 // Setting position outside current region will start region crossing
2489 ParentGroup.AbsolutePosition = newpos; 2486 ParentGroup.AbsolutePosition = newpos;
2490 return; 2487 return;
2491 } 2488 }
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 715a9b6..d4af9fc 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1057,30 +1057,32 @@ namespace OpenSim.Region.Framework.Scenes
1057 1057
1058 m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); 1058 m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene);
1059 1059
1060 UUID groupUUID = UUID.Zero; 1060 UUID groupUUID = ControllingClient.ActiveGroupId;
1061 string GroupName = string.Empty; 1061 string groupName = string.Empty;
1062 ulong groupPowers = 0; 1062 ulong groupPowers = 0;
1063 1063
1064 // ---------------------------------- 1064 // ----------------------------------
1065 // Previous Agent Difference - AGNI sends an unsolicited AgentDataUpdate upon root agent status 1065 // Previous Agent Difference - AGNI sends an unsolicited AgentDataUpdate upon root agent status
1066 try 1066 try
1067 { 1067 {
1068 if (gm != null) 1068 if (groupUUID != UUID.Zero && gm != null)
1069 { 1069 {
1070 groupUUID = ControllingClient.ActiveGroupId;
1071 GroupRecord record = gm.GetGroupRecord(groupUUID); 1070 GroupRecord record = gm.GetGroupRecord(groupUUID);
1072 if (record != null) 1071 if (record != null)
1073 GroupName = record.GroupName; 1072 groupName = record.GroupName;
1073
1074 GroupMembershipData groupMembershipData = gm.GetMembershipData(groupUUID, m_uuid); 1074 GroupMembershipData groupMembershipData = gm.GetMembershipData(groupUUID, m_uuid);
1075
1075 if (groupMembershipData != null) 1076 if (groupMembershipData != null)
1076 groupPowers = groupMembershipData.GroupPowers; 1077 groupPowers = groupMembershipData.GroupPowers;
1077 } 1078 }
1078 ControllingClient.SendAgentDataUpdate(m_uuid, groupUUID, Firstname, Lastname, groupPowers, GroupName, 1079
1079 Grouptitle); 1080 ControllingClient.SendAgentDataUpdate(
1081 m_uuid, groupUUID, Firstname, Lastname, groupPowers, groupName, Grouptitle);
1080 } 1082 }
1081 catch (Exception e) 1083 catch (Exception e)
1082 { 1084 {
1083 m_log.Debug("[AGENTUPDATE]: " + e.ToString()); 1085 m_log.Error("[AGENTUPDATE]: Error ", e);
1084 } 1086 }
1085 // ------------------------------------ 1087 // ------------------------------------
1086 1088
@@ -3471,8 +3473,6 @@ namespace OpenSim.Region.Framework.Scenes
3471 Vector3 pos2 = AbsolutePosition; 3473 Vector3 pos2 = AbsolutePosition;
3472 Vector3 origPosition = pos2; 3474 Vector3 origPosition = pos2;
3473 Vector3 vel = Velocity; 3475 Vector3 vel = Velocity;
3474 int neighbor = 0;
3475 int[] fix = new int[2];
3476 3476
3477 // Compute the avatar position in the next physics tick. 3477 // Compute the avatar position in the next physics tick.
3478 // If the avatar will be crossing, we force the crossing to happen now 3478 // If the avatar will be crossing, we force the crossing to happen now
@@ -3505,23 +3505,13 @@ namespace OpenSim.Region.Framework.Scenes
3505 if (m_requestedSitTargetUUID == UUID.Zero) 3505 if (m_requestedSitTargetUUID == UUID.Zero)
3506 { 3506 {
3507 m_log.DebugFormat("{0} CheckForBorderCrossing: Crossing failed. Restoring old position.", LogHeader); 3507 m_log.DebugFormat("{0} CheckForBorderCrossing: Crossing failed. Restoring old position.", LogHeader);
3508 const float borderFudge = 0.1f; 3508
3509
3510 if (origPosition.X < 0)
3511 origPosition.X = borderFudge;
3512 else if (origPosition.X > (float)m_scene.RegionInfo.RegionSizeX)
3513 origPosition.X = (float)m_scene.RegionInfo.RegionSizeX - borderFudge;
3514 if (origPosition.Y < 0)
3515 origPosition.Y = borderFudge;
3516 else if (origPosition.Y > (float)m_scene.RegionInfo.RegionSizeY)
3517 origPosition.Y = (float)m_scene.RegionInfo.RegionSizeY - borderFudge;
3518 Velocity = Vector3.Zero; 3509 Velocity = Vector3.Zero;
3519 AbsolutePosition = origPosition; 3510 AbsolutePosition = EnforceSanityOnPosition(origPosition);
3520 3511
3521 AddToPhysicalScene(isFlying); 3512 AddToPhysicalScene(isFlying);
3522 } 3513 }
3523 } 3514 }
3524
3525 } 3515 }
3526 } 3516 }
3527 else 3517 else
@@ -3539,6 +3529,36 @@ namespace OpenSim.Region.Framework.Scenes
3539 } 3529 }
3540 } 3530 }
3541 3531
3532 // Given a position, make sure it is within the current region.
3533 // If just outside some border, the returned position will be just inside the border on that side.
3534 private Vector3 EnforceSanityOnPosition(Vector3 origPosition)
3535 {
3536 const float borderFudge = 0.1f;
3537 Vector3 ret = origPosition;
3538
3539 // Sanity checking on the position to make sure it is in the region we couldn't cross from
3540 float extentX = (float)m_scene.RegionInfo.RegionSizeX;
3541 float extentY = (float)m_scene.RegionInfo.RegionSizeY;
3542 IRegionCombinerModule combiner = m_scene.RequestModuleInterface<IRegionCombinerModule>();
3543 if (combiner != null)
3544 {
3545 // If a mega-region, the size could be much bigger
3546 Vector2 megaExtent = combiner.GetSizeOfMegaregion(m_scene.RegionInfo.RegionID);
3547 extentX = megaExtent.X;
3548 extentY = megaExtent.Y;
3549 }
3550 if (ret.X < 0)
3551 ret.X = borderFudge;
3552 else if (ret.X >= extentX)
3553 ret.X = extentX - borderFudge;
3554 if (ret.Y < 0)
3555 ret.Y = borderFudge;
3556 else if (ret.Y >= extentY)
3557 ret.Y = extentY - borderFudge;
3558
3559 return ret;
3560 }
3561
3542 /// <summary> 3562 /// <summary>
3543 /// Moves the agent outside the region bounds 3563 /// Moves the agent outside the region bounds
3544 /// Tells neighbor region that we're crossing to it 3564 /// Tells neighbor region that we're crossing to it