diff options
Fix bumping into sim borders and check estate bans for walking crossings
Diffstat (limited to '')
-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 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 | ||