aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie2011-01-28 01:37:37 +0100
committerMelanie2011-01-28 01:37:37 +0100
commit7492131bb60129f5ce875ee376fc10b477e3fc5f (patch)
treeac64f7844b1a1b7e06363badb1492ac5db73ec3a /OpenSim
parentMerge branch 'master' into careminster-presence-refactor (diff)
downloadopensim-SC-7492131bb60129f5ce875ee376fc10b477e3fc5f.zip
opensim-SC-7492131bb60129f5ce875ee376fc10b477e3fc5f.tar.gz
opensim-SC-7492131bb60129f5ce875ee376fc10b477e3fc5f.tar.bz2
opensim-SC-7492131bb60129f5ce875ee376fc10b477e3fc5f.tar.xz
Fix bumping into sim borders and check estate bans for walking crossings
Diffstat (limited to '')
-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 677961d..016871f 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
@@ -600,7 +603,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
600 603
601 #region Agent Crossings 604 #region Agent Crossings
602 605
603 public void Cross(ScenePresence agent, bool isFlying) 606 public bool Cross(ScenePresence agent, bool isFlying)
604 { 607 {
605 Scene scene = agent.Scene; 608 Scene scene = agent.Scene;
606 Vector3 pos = agent.AbsolutePosition; 609 Vector3 pos = agent.AbsolutePosition;
@@ -636,6 +639,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
636 } 639 }
637 else 640 else
638 { 641 {
642 agent.InTransit();
643
639 neighboury = b.TriggerRegionY; 644 neighboury = b.TriggerRegionY;
640 neighbourx = b.TriggerRegionX; 645 neighbourx = b.TriggerRegionX;
641 646
@@ -645,7 +650,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
645 agent.ControllingClient.SendAgentAlertMessage( 650 agent.ControllingClient.SendAgentAlertMessage(
646 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); 651 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
647 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); 652 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
648 return; 653 return true;
649 } 654 }
650 } 655 }
651 656
@@ -657,6 +662,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
657 } 662 }
658 else 663 else
659 { 664 {
665 agent.InTransit();
666
660 neighboury = ba.TriggerRegionY; 667 neighboury = ba.TriggerRegionY;
661 neighbourx = ba.TriggerRegionX; 668 neighbourx = ba.TriggerRegionX;
662 669
@@ -669,7 +676,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
669 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); 676 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
670 677
671 678
672 return; 679 return true;
673 } 680 }
674 681
675 } 682 }
@@ -689,6 +696,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
689 } 696 }
690 else 697 else
691 { 698 {
699 agent.InTransit();
700
692 neighboury = ba.TriggerRegionY; 701 neighboury = ba.TriggerRegionY;
693 neighbourx = ba.TriggerRegionX; 702 neighbourx = ba.TriggerRegionX;
694 Vector3 newposition = pos; 703 Vector3 newposition = pos;
@@ -697,7 +706,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
697 agent.ControllingClient.SendAgentAlertMessage( 706 agent.ControllingClient.SendAgentAlertMessage(
698 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); 707 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
699 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); 708 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
700 return; 709 return true;
701 } 710 }
702 } 711 }
703 else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) 712 else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
@@ -719,6 +728,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
719 } 728 }
720 else 729 else
721 { 730 {
731 agent.InTransit();
732
722 neighboury = b.TriggerRegionY; 733 neighboury = b.TriggerRegionY;
723 neighbourx = b.TriggerRegionX; 734 neighbourx = b.TriggerRegionX;
724 Vector3 newposition = pos; 735 Vector3 newposition = pos;
@@ -727,7 +738,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
727 agent.ControllingClient.SendAgentAlertMessage( 738 agent.ControllingClient.SendAgentAlertMessage(
728 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); 739 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
729 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); 740 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
730 return; 741 return true;
731 } 742 }
732 } 743 }
733 else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) 744 else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
@@ -763,9 +774,51 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
763 } 774 }
764 */ 775 */
765 776
777 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
778
779 int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize);
780
781 ExpiringCache<ulong, DateTime> r;
782 DateTime banUntil;
783
784 if (m_bannedRegions.TryGetValue(agent.ControllingClient.AgentId, out r))
785 {
786 if (r.TryGetValue(neighbourHandle, out banUntil))
787 {
788 if (DateTime.Now < banUntil)
789 return false;
790 r.Remove(neighbourHandle);
791 }
792 }
793 else
794 {
795 r = null;
796 }
797
798 GridRegion neighbourRegion = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y);
799
800 if (!scene.SimulationService.QueryAccess(neighbourRegion, agent.ControllingClient.AgentId))
801 {
802 if (r == null)
803 {
804 r = new ExpiringCache<ulong, DateTime>();
805 r.Add(neighbourHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15));
806
807 m_bannedRegions.Add(agent.ControllingClient.AgentId, r, TimeSpan.FromSeconds(45));
808 }
809 else
810 {
811 r.Add(neighbourHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15));
812 }
813 return false;
814 }
815
816 agent.InTransit();
817
766 CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync; 818 CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync;
767 d.BeginInvoke(agent, newpos, neighbourx, neighboury, isFlying, CrossAgentToNewRegionCompleted, d); 819 d.BeginInvoke(agent, newpos, neighbourx, neighboury, neighbourRegion, isFlying, CrossAgentToNewRegionCompleted, d);
768 820
821 return true;
769 } 822 }
770 823
771 824
@@ -776,7 +829,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
776 private void InformClientToInitateTeleportToLocation(ScenePresence agent, uint regionX, uint regionY, Vector3 position, Scene initiatingScene) 829 private void InformClientToInitateTeleportToLocation(ScenePresence agent, uint regionX, uint regionY, Vector3 position, Scene initiatingScene)
777 { 830 {
778 831
779 // This assumes that we know what our neighbors are. 832 // This assumes that we know what our neighbours are.
780 833
781 InformClientToInitateTeleportToLocationDelegate d = InformClientToInitiateTeleportToLocationAsync; 834 InformClientToInitateTeleportToLocationDelegate d = InformClientToInitiateTeleportToLocationAsync;
782 d.BeginInvoke(agent, regionX, regionY, position, initiatingScene, 835 d.BeginInvoke(agent, regionX, regionY, position, initiatingScene,
@@ -820,21 +873,19 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
820 icon.EndInvoke(iar); 873 icon.EndInvoke(iar);
821 } 874 }
822 875
823 public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying); 876 public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, GridRegion neighbourRegion, bool isFlying);
824 877
825 /// <summary> 878 /// <summary>
826 /// This Closes child agents on neighboring regions 879 /// This Closes child agents on neighbouring regions
827 /// Calls an asynchronous method to do so.. so it doesn't lag the sim. 880 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
828 /// </summary> 881 /// </summary>
829 protected ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying) 882 protected ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, GridRegion neighbourRegion, bool isFlying)
830 { 883 {
884 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
885
831 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury); 886 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury);
832 887
833 Scene m_scene = agent.Scene; 888 Scene m_scene = agent.Scene;
834 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
835
836 int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize);
837 GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
838 889
839 if (neighbourRegion != null && agent.ValidateAttachments()) 890 if (neighbourRegion != null && agent.ValidateAttachments())
840 { 891 {
@@ -949,7 +1000,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
949 1000
950 #region Enable Child Agent 1001 #region Enable Child Agent
951 /// <summary> 1002 /// <summary>
952 /// This informs a single neighboring region about agent "avatar". 1003 /// This informs a single neighbouring region about agent "avatar".
953 /// Calls an asynchronous method to do so.. so it doesn't lag the sim. 1004 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
954 /// </summary> 1005 /// </summary>
955 public void EnableChildAgent(ScenePresence sp, GridRegion region) 1006 public void EnableChildAgent(ScenePresence sp, GridRegion region)
@@ -1010,7 +1061,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1010 ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent); 1061 ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent);
1011 1062
1012 /// <summary> 1063 /// <summary>
1013 /// This informs all neighboring regions about agent "avatar". 1064 /// This informs all neighbouring regions about agent "avatar".
1014 /// Calls an asynchronous method to do so.. so it doesn't lag the sim. 1065 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
1015 /// </summary> 1066 /// </summary>
1016 public void EnableChildAgents(ScenePresence sp) 1067 public void EnableChildAgents(ScenePresence sp)
@@ -1142,7 +1193,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1142 catch (ArgumentOutOfRangeException) 1193 catch (ArgumentOutOfRangeException)
1143 { 1194 {
1144 m_log.ErrorFormat( 1195 m_log.ErrorFormat(
1145 "[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}).", 1196 "[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}).",
1146 neighbour.ExternalHostName, 1197 neighbour.ExternalHostName,
1147 neighbour.RegionHandle, 1198 neighbour.RegionHandle,
1148 neighbour.RegionLocX, 1199 neighbour.RegionLocX,
@@ -1222,7 +1273,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1222 } 1273 }
1223 #endregion 1274 #endregion
1224 1275
1225 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: {0} is sending {1} EnableSimulator for neighbor region {2} @ {3} " + 1276 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: {0} is sending {1} EnableSimulator for neighbour region {2} @ {3} " +
1226 "and EstablishAgentCommunication with seed cap {4}", 1277 "and EstablishAgentCommunication with seed cap {4}",
1227 m_scene.RegionInfo.RegionName, sp.Name, reg.RegionName, reg.RegionHandle, capsPath); 1278 m_scene.RegionInfo.RegionName, sp.Name, reg.RegionName, reg.RegionHandle, capsPath);
1228 1279
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
index 45ca5c5..3eb38b8 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 bool TeleportHome(UUID id, IClientAPI client); 43 bool 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 bb9a748..5caf06c 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -4022,14 +4022,16 @@ namespace OpenSim.Region.Framework.Scenes
4022 RequestTeleportLocation(remoteClient, info.RegionHandle, position, Vector3.Zero, (uint)(TPFlags.SetLastToTarget | TPFlags.ViaLandmark)); 4022 RequestTeleportLocation(remoteClient, info.RegionHandle, position, Vector3.Zero, (uint)(TPFlags.SetLastToTarget | TPFlags.ViaLandmark));
4023 } 4023 }
4024 4024
4025 public void CrossAgentToNewRegion(ScenePresence agent, bool isFlying) 4025 public bool CrossAgentToNewRegion(ScenePresence agent, bool isFlying)
4026 { 4026 {
4027 if (m_teleportModule != null) 4027 if (m_teleportModule != null)
4028 m_teleportModule.Cross(agent, isFlying); 4028 return m_teleportModule.Cross(agent, isFlying);
4029 else 4029 else
4030 { 4030 {
4031 m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule"); 4031 m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule");
4032 } 4032 }
4033
4034 return false;
4033 } 4035 }
4034 4036
4035 public void SendOutChildAgentUpdates(AgentPosition cadu, ScenePresence presence) 4037 public void SendOutChildAgentUpdates(AgentPosition cadu, ScenePresence presence)
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index db9a95b..a1ca9c5 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -3102,29 +3102,57 @@ namespace OpenSim.Region.Framework.Scenes
3102 // Makes sure avatar does not end up outside region 3102 // Makes sure avatar does not end up outside region
3103 if (neighbor <= 0) 3103 if (neighbor <= 0)
3104 { 3104 {
3105 if (!needsTransit) 3105 if (needsTransit)
3106 { 3106 {
3107 if (m_requestedSitTargetUUID == UUID.Zero) 3107 if (m_requestedSitTargetUUID == UUID.Zero)
3108 { 3108 {
3109 bool isFlying = m_physicsActor.Flying;
3110 RemoveFromPhysicalScene();
3111
3109 Vector3 pos = AbsolutePosition; 3112 Vector3 pos = AbsolutePosition;
3110 if (AbsolutePosition.X < 0) 3113 if (AbsolutePosition.X < 0)
3111 pos.X += Velocity.X; 3114 pos.X += Velocity.X * 2;
3112 else if (AbsolutePosition.X > Constants.RegionSize) 3115 else if (AbsolutePosition.X > Constants.RegionSize)
3113 pos.X -= Velocity.X; 3116 pos.X -= Velocity.X * 2;
3114 if (AbsolutePosition.Y < 0) 3117 if (AbsolutePosition.Y < 0)
3115 pos.Y += Velocity.Y; 3118 pos.Y += Velocity.Y * 2;
3116 else if (AbsolutePosition.Y > Constants.RegionSize) 3119 else if (AbsolutePosition.Y > Constants.RegionSize)
3117 pos.Y -= Velocity.Y; 3120 pos.Y -= Velocity.Y * 2;
3121 Velocity = Vector3.Zero;
3118 AbsolutePosition = pos; 3122 AbsolutePosition = pos;
3123
3124 AddToPhysicalScene(isFlying);
3119 } 3125 }
3120 } 3126 }
3121 } 3127 }
3122 else if (neighbor > 0) 3128 else if (neighbor > 0)
3123 CrossToNewRegion(); 3129 {
3130 if (!CrossToNewRegion())
3131 {
3132 if (m_requestedSitTargetUUID == UUID.Zero)
3133 {
3134 bool isFlying = m_physicsActor.Flying;
3135 RemoveFromPhysicalScene();
3136
3137 Vector3 pos = AbsolutePosition;
3138 if (AbsolutePosition.X < 0)
3139 pos.X += Velocity.X * 2;
3140 else if (AbsolutePosition.X > Constants.RegionSize)
3141 pos.X -= Velocity.X * 2;
3142 if (AbsolutePosition.Y < 0)
3143 pos.Y += Velocity.Y * 2;
3144 else if (AbsolutePosition.Y > Constants.RegionSize)
3145 pos.Y -= Velocity.Y * 2;
3146 Velocity = Vector3.Zero;
3147 AbsolutePosition = pos;
3148
3149 AddToPhysicalScene(isFlying);
3150 }
3151 }
3152 }
3124 } 3153 }
3125 else 3154 else
3126 { 3155 {
3127 RemoveFromPhysicalScene();
3128 // This constant has been inferred from experimentation 3156 // This constant has been inferred from experimentation
3129 // I'm not sure what this value should be, so I tried a few values. 3157 // I'm not sure what this value should be, so I tried a few values.
3130 timeStep = 0.04f; 3158 timeStep = 0.04f;
@@ -3173,16 +3201,15 @@ namespace OpenSim.Region.Framework.Scenes
3173 /// If the neighbor accepts, remove the agent's viewable avatar from this scene 3201 /// If the neighbor accepts, remove the agent's viewable avatar from this scene
3174 /// set them to a child agent. 3202 /// set them to a child agent.
3175 /// </summary> 3203 /// </summary>
3176 protected void CrossToNewRegion() 3204 protected bool CrossToNewRegion()
3177 { 3205 {
3178 InTransit();
3179 try 3206 try
3180 { 3207 {
3181 m_scene.CrossAgentToNewRegion(this, m_physicsActor.Flying); 3208 return m_scene.CrossAgentToNewRegion(this, m_physicsActor.Flying);
3182 } 3209 }
3183 catch 3210 catch
3184 { 3211 {
3185 m_scene.CrossAgentToNewRegion(this, false); 3212 return m_scene.CrossAgentToNewRegion(this, false);
3186 } 3213 }
3187 } 3214 }
3188 3215