diff options
author | BlueWall | 2011-02-09 14:45:40 -0500 |
---|---|---|
committer | BlueWall | 2011-02-09 14:45:40 -0500 |
commit | 0f736e5601a738b4da435b392774ba211647da9c (patch) | |
tree | edb1f9d90c01841eea86b2ce0b2fbf410dc416ee /OpenSim/Region/CoreModules/Framework | |
parent | Merge branch 'master' of /home/opensim/src/OpenSim/Core (diff) | |
parent | Flash out the prim count module (diff) | |
download | opensim-SC_OLD-0f736e5601a738b4da435b392774ba211647da9c.zip opensim-SC_OLD-0f736e5601a738b4da435b392774ba211647da9c.tar.gz opensim-SC_OLD-0f736e5601a738b4da435b392774ba211647da9c.tar.bz2 opensim-SC_OLD-0f736e5601a738b4da435b392774ba211647da9c.tar.xz |
Merge branch 'master' of /home/opensim/src/OpenSim/Core
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 94 |
1 files changed, 76 insertions, 18 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 8bf2bf8..54b95f7 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 | ||
@@ -281,6 +284,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
281 | return; | 284 | return; |
282 | } | 285 | } |
283 | 286 | ||
287 | if (!m_aScene.SimulationService.QueryAccess(finalDestination, sp.ControllingClient.AgentId, Vector3.Zero)) | ||
288 | { | ||
289 | sp.ControllingClient.SendTeleportFailed("The destination region has refused access"); | ||
290 | return; | ||
291 | } | ||
292 | |||
284 | sp.ControllingClient.SendTeleportStart(teleportFlags); | 293 | sp.ControllingClient.SendTeleportStart(teleportFlags); |
285 | 294 | ||
286 | // the avatar.Close below will clear the child region list. We need this below for (possibly) | 295 | // the avatar.Close below will clear the child region list. We need this below for (possibly) |
@@ -575,7 +584,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
575 | 584 | ||
576 | #region Agent Crossings | 585 | #region Agent Crossings |
577 | 586 | ||
578 | public void Cross(ScenePresence agent, bool isFlying) | 587 | public bool Cross(ScenePresence agent, bool isFlying) |
579 | { | 588 | { |
580 | Scene scene = agent.Scene; | 589 | Scene scene = agent.Scene; |
581 | Vector3 pos = agent.AbsolutePosition; | 590 | Vector3 pos = agent.AbsolutePosition; |
@@ -611,6 +620,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
611 | } | 620 | } |
612 | else | 621 | else |
613 | { | 622 | { |
623 | agent.InTransit(); | ||
624 | |||
614 | neighboury = b.TriggerRegionY; | 625 | neighboury = b.TriggerRegionY; |
615 | neighbourx = b.TriggerRegionX; | 626 | neighbourx = b.TriggerRegionX; |
616 | 627 | ||
@@ -620,7 +631,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
620 | agent.ControllingClient.SendAgentAlertMessage( | 631 | agent.ControllingClient.SendAgentAlertMessage( |
621 | String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); | 632 | String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); |
622 | InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); | 633 | InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); |
623 | return; | 634 | return true; |
624 | } | 635 | } |
625 | } | 636 | } |
626 | 637 | ||
@@ -632,6 +643,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
632 | } | 643 | } |
633 | else | 644 | else |
634 | { | 645 | { |
646 | agent.InTransit(); | ||
647 | |||
635 | neighboury = ba.TriggerRegionY; | 648 | neighboury = ba.TriggerRegionY; |
636 | neighbourx = ba.TriggerRegionX; | 649 | neighbourx = ba.TriggerRegionX; |
637 | 650 | ||
@@ -644,7 +657,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
644 | InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); | 657 | InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); |
645 | 658 | ||
646 | 659 | ||
647 | return; | 660 | return true; |
648 | } | 661 | } |
649 | 662 | ||
650 | } | 663 | } |
@@ -664,6 +677,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
664 | } | 677 | } |
665 | else | 678 | else |
666 | { | 679 | { |
680 | agent.InTransit(); | ||
681 | |||
667 | neighboury = ba.TriggerRegionY; | 682 | neighboury = ba.TriggerRegionY; |
668 | neighbourx = ba.TriggerRegionX; | 683 | neighbourx = ba.TriggerRegionX; |
669 | Vector3 newposition = pos; | 684 | Vector3 newposition = pos; |
@@ -672,7 +687,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
672 | agent.ControllingClient.SendAgentAlertMessage( | 687 | agent.ControllingClient.SendAgentAlertMessage( |
673 | String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); | 688 | String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); |
674 | InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); | 689 | InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); |
675 | return; | 690 | return true; |
676 | } | 691 | } |
677 | } | 692 | } |
678 | else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) | 693 | else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) |
@@ -694,6 +709,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
694 | } | 709 | } |
695 | else | 710 | else |
696 | { | 711 | { |
712 | agent.InTransit(); | ||
713 | |||
697 | neighboury = b.TriggerRegionY; | 714 | neighboury = b.TriggerRegionY; |
698 | neighbourx = b.TriggerRegionX; | 715 | neighbourx = b.TriggerRegionX; |
699 | Vector3 newposition = pos; | 716 | Vector3 newposition = pos; |
@@ -702,7 +719,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
702 | agent.ControllingClient.SendAgentAlertMessage( | 719 | agent.ControllingClient.SendAgentAlertMessage( |
703 | String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); | 720 | String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); |
704 | InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); | 721 | InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); |
705 | return; | 722 | return true; |
706 | } | 723 | } |
707 | } | 724 | } |
708 | else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) | 725 | else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) |
@@ -738,9 +755,52 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
738 | } | 755 | } |
739 | */ | 756 | */ |
740 | 757 | ||
758 | ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); | ||
759 | |||
760 | int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize); | ||
761 | |||
762 | ExpiringCache<ulong, DateTime> r; | ||
763 | DateTime banUntil; | ||
764 | |||
765 | if (m_bannedRegions.TryGetValue(agent.ControllingClient.AgentId, out r)) | ||
766 | { | ||
767 | if (r.TryGetValue(neighbourHandle, out banUntil)) | ||
768 | { | ||
769 | if (DateTime.Now < banUntil) | ||
770 | return false; | ||
771 | r.Remove(neighbourHandle); | ||
772 | } | ||
773 | } | ||
774 | else | ||
775 | { | ||
776 | r = null; | ||
777 | } | ||
778 | |||
779 | GridRegion neighbourRegion = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y); | ||
780 | |||
781 | if (!scene.SimulationService.QueryAccess(neighbourRegion, agent.ControllingClient.AgentId, newpos)) | ||
782 | { | ||
783 | agent.ControllingClient.SendAlertMessage("Cannot region cross into banned parcel"); | ||
784 | if (r == null) | ||
785 | { | ||
786 | r = new ExpiringCache<ulong, DateTime>(); | ||
787 | r.Add(neighbourHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15)); | ||
788 | |||
789 | m_bannedRegions.Add(agent.ControllingClient.AgentId, r, TimeSpan.FromSeconds(45)); | ||
790 | } | ||
791 | else | ||
792 | { | ||
793 | r.Add(neighbourHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15)); | ||
794 | } | ||
795 | return false; | ||
796 | } | ||
797 | |||
798 | agent.InTransit(); | ||
799 | |||
741 | CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync; | 800 | CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync; |
742 | d.BeginInvoke(agent, newpos, neighbourx, neighboury, isFlying, CrossAgentToNewRegionCompleted, d); | 801 | d.BeginInvoke(agent, newpos, neighbourx, neighboury, neighbourRegion, isFlying, CrossAgentToNewRegionCompleted, d); |
743 | 802 | ||
803 | return true; | ||
744 | } | 804 | } |
745 | 805 | ||
746 | 806 | ||
@@ -751,7 +811,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
751 | private void InformClientToInitateTeleportToLocation(ScenePresence agent, uint regionX, uint regionY, Vector3 position, Scene initiatingScene) | 811 | private void InformClientToInitateTeleportToLocation(ScenePresence agent, uint regionX, uint regionY, Vector3 position, Scene initiatingScene) |
752 | { | 812 | { |
753 | 813 | ||
754 | // This assumes that we know what our neighbors are. | 814 | // This assumes that we know what our neighbours are. |
755 | 815 | ||
756 | InformClientToInitateTeleportToLocationDelegate d = InformClientToInitiateTeleportToLocationAsync; | 816 | InformClientToInitateTeleportToLocationDelegate d = InformClientToInitiateTeleportToLocationAsync; |
757 | d.BeginInvoke(agent, regionX, regionY, position, initiatingScene, | 817 | d.BeginInvoke(agent, regionX, regionY, position, initiatingScene, |
@@ -795,21 +855,19 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
795 | icon.EndInvoke(iar); | 855 | icon.EndInvoke(iar); |
796 | } | 856 | } |
797 | 857 | ||
798 | public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying); | 858 | public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, GridRegion neighbourRegion, bool isFlying); |
799 | 859 | ||
800 | /// <summary> | 860 | /// <summary> |
801 | /// This Closes child agents on neighboring regions | 861 | /// This Closes child agents on neighbouring regions |
802 | /// Calls an asynchronous method to do so.. so it doesn't lag the sim. | 862 | /// Calls an asynchronous method to do so.. so it doesn't lag the sim. |
803 | /// </summary> | 863 | /// </summary> |
804 | protected ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying) | 864 | protected ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, GridRegion neighbourRegion, bool isFlying) |
805 | { | 865 | { |
866 | ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); | ||
867 | |||
806 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury); | 868 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury); |
807 | 869 | ||
808 | Scene m_scene = agent.Scene; | 870 | 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 | 871 | ||
814 | if (neighbourRegion != null && agent.ValidateAttachments()) | 872 | if (neighbourRegion != null && agent.ValidateAttachments()) |
815 | { | 873 | { |
@@ -920,7 +978,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
920 | 978 | ||
921 | #region Enable Child Agent | 979 | #region Enable Child Agent |
922 | /// <summary> | 980 | /// <summary> |
923 | /// This informs a single neighboring region about agent "avatar". | 981 | /// This informs a single neighbouring region about agent "avatar". |
924 | /// Calls an asynchronous method to do so.. so it doesn't lag the sim. | 982 | /// Calls an asynchronous method to do so.. so it doesn't lag the sim. |
925 | /// </summary> | 983 | /// </summary> |
926 | public void EnableChildAgent(ScenePresence sp, GridRegion region) | 984 | public void EnableChildAgent(ScenePresence sp, GridRegion region) |
@@ -977,7 +1035,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
977 | ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent); | 1035 | ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent); |
978 | 1036 | ||
979 | /// <summary> | 1037 | /// <summary> |
980 | /// This informs all neighboring regions about agent "avatar". | 1038 | /// This informs all neighbouring regions about agent "avatar". |
981 | /// Calls an asynchronous method to do so.. so it doesn't lag the sim. | 1039 | /// Calls an asynchronous method to do so.. so it doesn't lag the sim. |
982 | /// </summary> | 1040 | /// </summary> |
983 | public void EnableChildAgents(ScenePresence sp) | 1041 | public void EnableChildAgents(ScenePresence sp) |
@@ -1108,7 +1166,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1108 | catch (ArgumentOutOfRangeException) | 1166 | catch (ArgumentOutOfRangeException) |
1109 | { | 1167 | { |
1110 | m_log.ErrorFormat( | 1168 | 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}).", | 1169 | "[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, | 1170 | neighbour.ExternalHostName, |
1113 | neighbour.RegionHandle, | 1171 | neighbour.RegionHandle, |
1114 | neighbour.RegionLocX, | 1172 | neighbour.RegionLocX, |
@@ -1188,7 +1246,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1188 | } | 1246 | } |
1189 | #endregion | 1247 | #endregion |
1190 | 1248 | ||
1191 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: {0} is sending {1} EnableSimulator for neighbor region {2} @ {3} " + | 1249 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: {0} is sending {1} EnableSimulator for neighbour region {2} @ {3} " + |
1192 | "and EstablishAgentCommunication with seed cap {4}", | 1250 | "and EstablishAgentCommunication with seed cap {4}", |
1193 | m_scene.RegionInfo.RegionName, sp.Name, reg.RegionName, reg.RegionHandle, capsPath); | 1251 | m_scene.RegionInfo.RegionName, sp.Name, reg.RegionName, reg.RegionHandle, capsPath); |
1194 | 1252 | ||