diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 87 |
1 files changed, 69 insertions, 18 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 | ||