aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorMelanie2011-01-28 01:37:37 +0100
committerMelanie2011-01-28 02:38:14 +0000
commitd90b0c53ec747c512b1efccf6f25596dac9c3e41 (patch)
tree26fac666b5879f1727177eb75eaeb2d03d8a0d2d /OpenSim/Region
parentMerge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff)
downloadopensim-SC_OLD-d90b0c53ec747c512b1efccf6f25596dac9c3e41.zip
opensim-SC_OLD-d90b0c53ec747c512b1efccf6f25596dac9c3e41.tar.gz
opensim-SC_OLD-d90b0c53ec747c512b1efccf6f25596dac9c3e41.tar.bz2
opensim-SC_OLD-d90b0c53ec747c512b1efccf6f25596dac9c3e41.tar.xz
Fix bumping into sim borders and check estate bans for walking crossings
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs87
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs49
4 files changed, 112 insertions, 32 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 8bf2bf8..7804b7f 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -53,6 +53,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
53 protected bool m_Enabled = false; 53 protected bool m_Enabled = false;
54 protected Scene m_aScene; 54 protected Scene m_aScene;
55 protected List<UUID> m_agentsInTransit; 55 protected List<UUID> m_agentsInTransit;
56 private ExpiringCache<UUID, ExpiringCache<ulong, DateTime>> m_bannedRegions =
57 new ExpiringCache<UUID, ExpiringCache<ulong, DateTime>>();
58
56 59
57 #region ISharedRegionModule 60 #region ISharedRegionModule
58 61
@@ -575,7 +578,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
575 578
576 #region Agent Crossings 579 #region Agent Crossings
577 580
578 public void Cross(ScenePresence agent, bool isFlying) 581 public bool Cross(ScenePresence agent, bool isFlying)
579 { 582 {
580 Scene scene = agent.Scene; 583 Scene scene = agent.Scene;
581 Vector3 pos = agent.AbsolutePosition; 584 Vector3 pos = agent.AbsolutePosition;
@@ -611,6 +614,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
611 } 614 }
612 else 615 else
613 { 616 {
617 agent.InTransit();
618
614 neighboury = b.TriggerRegionY; 619 neighboury = b.TriggerRegionY;
615 neighbourx = b.TriggerRegionX; 620 neighbourx = b.TriggerRegionX;
616 621
@@ -620,7 +625,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
620 agent.ControllingClient.SendAgentAlertMessage( 625 agent.ControllingClient.SendAgentAlertMessage(
621 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); 626 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
622 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); 627 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
623 return; 628 return true;
624 } 629 }
625 } 630 }
626 631
@@ -632,6 +637,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
632 } 637 }
633 else 638 else
634 { 639 {
640 agent.InTransit();
641
635 neighboury = ba.TriggerRegionY; 642 neighboury = ba.TriggerRegionY;
636 neighbourx = ba.TriggerRegionX; 643 neighbourx = ba.TriggerRegionX;
637 644
@@ -644,7 +651,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
644 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); 651 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
645 652
646 653
647 return; 654 return true;
648 } 655 }
649 656
650 } 657 }
@@ -664,6 +671,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
664 } 671 }
665 else 672 else
666 { 673 {
674 agent.InTransit();
675
667 neighboury = ba.TriggerRegionY; 676 neighboury = ba.TriggerRegionY;
668 neighbourx = ba.TriggerRegionX; 677 neighbourx = ba.TriggerRegionX;
669 Vector3 newposition = pos; 678 Vector3 newposition = pos;
@@ -672,7 +681,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
672 agent.ControllingClient.SendAgentAlertMessage( 681 agent.ControllingClient.SendAgentAlertMessage(
673 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); 682 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
674 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); 683 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
675 return; 684 return true;
676 } 685 }
677 } 686 }
678 else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) 687 else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
@@ -694,6 +703,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
694 } 703 }
695 else 704 else
696 { 705 {
706 agent.InTransit();
707
697 neighboury = b.TriggerRegionY; 708 neighboury = b.TriggerRegionY;
698 neighbourx = b.TriggerRegionX; 709 neighbourx = b.TriggerRegionX;
699 Vector3 newposition = pos; 710 Vector3 newposition = pos;
@@ -702,7 +713,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
702 agent.ControllingClient.SendAgentAlertMessage( 713 agent.ControllingClient.SendAgentAlertMessage(
703 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); 714 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
704 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); 715 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
705 return; 716 return true;
706 } 717 }
707 } 718 }
708 else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) 719 else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
@@ -738,9 +749,51 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
738 } 749 }
739 */ 750 */
740 751
752 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
753
754 int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize);
755
756 ExpiringCache<ulong, DateTime> r;
757 DateTime banUntil;
758
759 if (m_bannedRegions.TryGetValue(agent.ControllingClient.AgentId, out r))
760 {
761 if (r.TryGetValue(neighbourHandle, out banUntil))
762 {
763 if (DateTime.Now < banUntil)
764 return false;
765 r.Remove(neighbourHandle);
766 }
767 }
768 else
769 {
770 r = null;
771 }
772
773 GridRegion neighbourRegion = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y);
774
775 if (!scene.SimulationService.QueryAccess(neighbourRegion, agent.ControllingClient.AgentId))
776 {
777 if (r == null)
778 {
779 r = new ExpiringCache<ulong, DateTime>();
780 r.Add(neighbourHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15));
781
782 m_bannedRegions.Add(agent.ControllingClient.AgentId, r, TimeSpan.FromSeconds(45));
783 }
784 else
785 {
786 r.Add(neighbourHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15));
787 }
788 return false;
789 }
790
791 agent.InTransit();
792
741 CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync; 793 CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync;
742 d.BeginInvoke(agent, newpos, neighbourx, neighboury, isFlying, CrossAgentToNewRegionCompleted, d); 794 d.BeginInvoke(agent, newpos, neighbourx, neighboury, neighbourRegion, isFlying, CrossAgentToNewRegionCompleted, d);
743 795
796 return true;
744 } 797 }
745 798
746 799
@@ -751,7 +804,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
751 private void InformClientToInitateTeleportToLocation(ScenePresence agent, uint regionX, uint regionY, Vector3 position, Scene initiatingScene) 804 private void InformClientToInitateTeleportToLocation(ScenePresence agent, uint regionX, uint regionY, Vector3 position, Scene initiatingScene)
752 { 805 {
753 806
754 // This assumes that we know what our neighbors are. 807 // This assumes that we know what our neighbours are.
755 808
756 InformClientToInitateTeleportToLocationDelegate d = InformClientToInitiateTeleportToLocationAsync; 809 InformClientToInitateTeleportToLocationDelegate d = InformClientToInitiateTeleportToLocationAsync;
757 d.BeginInvoke(agent, regionX, regionY, position, initiatingScene, 810 d.BeginInvoke(agent, regionX, regionY, position, initiatingScene,
@@ -795,21 +848,19 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
795 icon.EndInvoke(iar); 848 icon.EndInvoke(iar);
796 } 849 }
797 850
798 public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying); 851 public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, GridRegion neighbourRegion, bool isFlying);
799 852
800 /// <summary> 853 /// <summary>
801 /// This Closes child agents on neighboring regions 854 /// This Closes child agents on neighbouring regions
802 /// Calls an asynchronous method to do so.. so it doesn't lag the sim. 855 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
803 /// </summary> 856 /// </summary>
804 protected ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying) 857 protected ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, GridRegion neighbourRegion, bool isFlying)
805 { 858 {
859 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
860
806 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury); 861 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury);
807 862
808 Scene m_scene = agent.Scene; 863 Scene m_scene = agent.Scene;
809 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
810
811 int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize);
812 GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
813 864
814 if (neighbourRegion != null && agent.ValidateAttachments()) 865 if (neighbourRegion != null && agent.ValidateAttachments())
815 { 866 {
@@ -920,7 +971,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
920 971
921 #region Enable Child Agent 972 #region Enable Child Agent
922 /// <summary> 973 /// <summary>
923 /// This informs a single neighboring region about agent "avatar". 974 /// This informs a single neighbouring region about agent "avatar".
924 /// Calls an asynchronous method to do so.. so it doesn't lag the sim. 975 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
925 /// </summary> 976 /// </summary>
926 public void EnableChildAgent(ScenePresence sp, GridRegion region) 977 public void EnableChildAgent(ScenePresence sp, GridRegion region)
@@ -977,7 +1028,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
977 ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent); 1028 ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent);
978 1029
979 /// <summary> 1030 /// <summary>
980 /// This informs all neighboring regions about agent "avatar". 1031 /// This informs all neighbouring regions about agent "avatar".
981 /// Calls an asynchronous method to do so.. so it doesn't lag the sim. 1032 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
982 /// </summary> 1033 /// </summary>
983 public void EnableChildAgents(ScenePresence sp) 1034 public void EnableChildAgents(ScenePresence sp)
@@ -1108,7 +1159,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1108 catch (ArgumentOutOfRangeException) 1159 catch (ArgumentOutOfRangeException)
1109 { 1160 {
1110 m_log.ErrorFormat( 1161 m_log.ErrorFormat(
1111 "[ENTITY 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}).", 1162 "[ENTITY TRANSFER MODULE]: Neighbour Regions response included the current region in the neighbour list. The following region will not display to the client: {0} for region {1} ({2}, {3}).",
1112 neighbour.ExternalHostName, 1163 neighbour.ExternalHostName,
1113 neighbour.RegionHandle, 1164 neighbour.RegionHandle,
1114 neighbour.RegionLocX, 1165 neighbour.RegionLocX,
@@ -1188,7 +1239,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1188 } 1239 }
1189 #endregion 1240 #endregion
1190 1241
1191 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: {0} is sending {1} EnableSimulator for neighbor region {2} @ {3} " + 1242 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: {0} is sending {1} EnableSimulator for neighbour region {2} @ {3} " +
1192 "and EstablishAgentCommunication with seed cap {4}", 1243 "and EstablishAgentCommunication with seed cap {4}",
1193 m_scene.RegionInfo.RegionName, sp.Name, reg.RegionName, reg.RegionHandle, capsPath); 1244 m_scene.RegionInfo.RegionName, sp.Name, reg.RegionName, reg.RegionHandle, capsPath);
1194 1245
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
index e8738c4..8b96de4 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
@@ -42,7 +42,7 @@ namespace OpenSim.Region.Framework.Interfaces
42 42
43 void TeleportHome(UUID id, IClientAPI client); 43 void TeleportHome(UUID id, IClientAPI client);
44 44
45 void Cross(ScenePresence agent, bool isFlying); 45 bool Cross(ScenePresence agent, bool isFlying);
46 46
47 void AgentArrivedAtDestination(UUID agent); 47 void AgentArrivedAtDestination(UUID agent);
48 48
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index dc08b49..4325ab8 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -3861,14 +3861,16 @@ namespace OpenSim.Region.Framework.Scenes
3861 RequestTeleportLocation(remoteClient, info.RegionHandle, position, Vector3.Zero, (uint)(TPFlags.SetLastToTarget | TPFlags.ViaLandmark)); 3861 RequestTeleportLocation(remoteClient, info.RegionHandle, position, Vector3.Zero, (uint)(TPFlags.SetLastToTarget | TPFlags.ViaLandmark));
3862 } 3862 }
3863 3863
3864 public void CrossAgentToNewRegion(ScenePresence agent, bool isFlying) 3864 public bool CrossAgentToNewRegion(ScenePresence agent, bool isFlying)
3865 { 3865 {
3866 if (m_teleportModule != null) 3866 if (m_teleportModule != null)
3867 m_teleportModule.Cross(agent, isFlying); 3867 return m_teleportModule.Cross(agent, isFlying);
3868 else 3868 else
3869 { 3869 {
3870 m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule"); 3870 m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule");
3871 } 3871 }
3872
3873 return false;
3872 } 3874 }
3873 3875
3874 public void SendOutChildAgentUpdates(AgentPosition cadu, ScenePresence presence) 3876 public void SendOutChildAgentUpdates(AgentPosition cadu, ScenePresence presence)
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 1c276fa..cd70de8 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -2725,29 +2725,57 @@ namespace OpenSim.Region.Framework.Scenes
2725 // Makes sure avatar does not end up outside region 2725 // Makes sure avatar does not end up outside region
2726 if (neighbor <= 0) 2726 if (neighbor <= 0)
2727 { 2727 {
2728 if (!needsTransit) 2728 if (needsTransit)
2729 { 2729 {
2730 if (m_requestedSitTargetUUID == UUID.Zero) 2730 if (m_requestedSitTargetUUID == UUID.Zero)
2731 { 2731 {
2732 bool isFlying = m_physicsActor.Flying;
2733 RemoveFromPhysicalScene();
2734
2732 Vector3 pos = AbsolutePosition; 2735 Vector3 pos = AbsolutePosition;
2733 if (AbsolutePosition.X < 0) 2736 if (AbsolutePosition.X < 0)
2734 pos.X += Velocity.X; 2737 pos.X += Velocity.X * 2;
2735 else if (AbsolutePosition.X > Constants.RegionSize) 2738 else if (AbsolutePosition.X > Constants.RegionSize)
2736 pos.X -= Velocity.X; 2739 pos.X -= Velocity.X * 2;
2737 if (AbsolutePosition.Y < 0) 2740 if (AbsolutePosition.Y < 0)
2738 pos.Y += Velocity.Y; 2741 pos.Y += Velocity.Y * 2;
2739 else if (AbsolutePosition.Y > Constants.RegionSize) 2742 else if (AbsolutePosition.Y > Constants.RegionSize)
2740 pos.Y -= Velocity.Y; 2743 pos.Y -= Velocity.Y * 2;
2744 Velocity = Vector3.Zero;
2741 AbsolutePosition = pos; 2745 AbsolutePosition = pos;
2746
2747 AddToPhysicalScene(isFlying);
2742 } 2748 }
2743 } 2749 }
2744 } 2750 }
2745 else if (neighbor > 0) 2751 else if (neighbor > 0)
2746 CrossToNewRegion(); 2752 {
2753 if (!CrossToNewRegion())
2754 {
2755 if (m_requestedSitTargetUUID == UUID.Zero)
2756 {
2757 bool isFlying = m_physicsActor.Flying;
2758 RemoveFromPhysicalScene();
2759
2760 Vector3 pos = AbsolutePosition;
2761 if (AbsolutePosition.X < 0)
2762 pos.X += Velocity.X * 2;
2763 else if (AbsolutePosition.X > Constants.RegionSize)
2764 pos.X -= Velocity.X * 2;
2765 if (AbsolutePosition.Y < 0)
2766 pos.Y += Velocity.Y * 2;
2767 else if (AbsolutePosition.Y > Constants.RegionSize)
2768 pos.Y -= Velocity.Y * 2;
2769 Velocity = Vector3.Zero;
2770 AbsolutePosition = pos;
2771
2772 AddToPhysicalScene(isFlying);
2773 }
2774 }
2775 }
2747 } 2776 }
2748 else 2777 else
2749 { 2778 {
2750 RemoveFromPhysicalScene();
2751 // This constant has been inferred from experimentation 2779 // This constant has been inferred from experimentation
2752 // I'm not sure what this value should be, so I tried a few values. 2780 // I'm not sure what this value should be, so I tried a few values.
2753 timeStep = 0.04f; 2781 timeStep = 0.04f;
@@ -2796,16 +2824,15 @@ namespace OpenSim.Region.Framework.Scenes
2796 /// If the neighbor accepts, remove the agent's viewable avatar from this scene 2824 /// If the neighbor accepts, remove the agent's viewable avatar from this scene
2797 /// set them to a child agent. 2825 /// set them to a child agent.
2798 /// </summary> 2826 /// </summary>
2799 protected void CrossToNewRegion() 2827 protected bool CrossToNewRegion()
2800 { 2828 {
2801 InTransit();
2802 try 2829 try
2803 { 2830 {
2804 m_scene.CrossAgentToNewRegion(this, m_physicsActor.Flying); 2831 return m_scene.CrossAgentToNewRegion(this, m_physicsActor.Flying);
2805 } 2832 }
2806 catch 2833 catch
2807 { 2834 {
2808 m_scene.CrossAgentToNewRegion(this, false); 2835 return m_scene.CrossAgentToNewRegion(this, false);
2809 } 2836 }
2810 } 2837 }
2811 2838