aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Framework
diff options
context:
space:
mode:
authorMelanie2012-02-14 23:16:20 +0100
committerMelanie2012-02-14 23:16:20 +0100
commit2d3381b795611a8857077d1effb41323c2cb8658 (patch)
treea1b8a6d7832858d14bfb08eac29fcf3e643ef17c /OpenSim/Region/CoreModules/Framework
parentPrevent object loss and positioning outside the region with failed object sim (diff)
downloadopensim-SC-2d3381b795611a8857077d1effb41323c2cb8658.zip
opensim-SC-2d3381b795611a8857077d1effb41323c2cb8658.tar.gz
opensim-SC-2d3381b795611a8857077d1effb41323c2cb8658.tar.bz2
opensim-SC-2d3381b795611a8857077d1effb41323c2cb8658.tar.xz
Implement region crossing of sitting avatars. Edit mode and llSetPos work
but unscripted default sit anim is lost. Still some Gfx glitching. Physical crossing doesn't work yet.
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework')
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs140
1 files changed, 38 insertions, 102 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 4b1c0bc..9a6dfe1 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -681,11 +681,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
681 681
682 #region Agent Crossings 682 #region Agent Crossings
683 683
684 public bool Cross(ScenePresence agent, bool isFlying) 684 public GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, out uint xDest, out uint yDest, out string version, out Vector3 newpos)
685 { 685 {
686 Scene scene = agent.Scene; 686 version = String.Empty;
687 Vector3 pos = agent.AbsolutePosition; 687 newpos = new Vector3(pos.X, pos.Y, pos.Z);
688 Vector3 newpos = new Vector3(pos.X, pos.Y, pos.Z);
689 uint neighbourx = scene.RegionInfo.RegionLocX; 688 uint neighbourx = scene.RegionInfo.RegionLocX;
690 uint neighboury = scene.RegionInfo.RegionLocY; 689 uint neighboury = scene.RegionInfo.RegionLocY;
691 const float boundaryDistance = 1.7f; 690 const float boundaryDistance = 1.7f;
@@ -706,53 +705,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
706 } 705 }
707 else if (scene.TestBorderCross(pos + southCross, Cardinals.S)) 706 else if (scene.TestBorderCross(pos + southCross, Cardinals.S))
708 { 707 {
709 Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S); 708 neighboury--;
710 if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0) 709 newpos.Y = Constants.RegionSize - enterDistance;
711 {
712 neighboury--;
713 newpos.Y = Constants.RegionSize - enterDistance;
714 }
715 else
716 {
717 agent.IsInTransit = true;
718
719 neighboury = b.TriggerRegionY;
720 neighbourx = b.TriggerRegionX;
721
722 Vector3 newposition = pos;
723 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
724 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
725 agent.ControllingClient.SendAgentAlertMessage(
726 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
727 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
728 return true;
729 }
730 }
731
732 Border ba = scene.GetCrossedBorder(pos + westCross, Cardinals.W);
733 if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0)
734 {
735 neighbourx--;
736 newpos.X = Constants.RegionSize - enterDistance;
737 } 710 }
738 else
739 {
740 agent.IsInTransit = true;
741
742 neighboury = ba.TriggerRegionY;
743 neighbourx = ba.TriggerRegionX;
744 711
745 712 neighbourx--;
746 Vector3 newposition = pos; 713 newpos.X = Constants.RegionSize - enterDistance;
747 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
748 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
749 agent.ControllingClient.SendAgentAlertMessage(
750 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
751 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
752
753
754 return true;
755 }
756 714
757 } 715 }
758 else if (scene.TestBorderCross(pos + eastCross, Cardinals.E)) 716 else if (scene.TestBorderCross(pos + eastCross, Cardinals.E))
@@ -763,26 +721,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
763 721
764 if (scene.TestBorderCross(pos + southCross, Cardinals.S)) 722 if (scene.TestBorderCross(pos + southCross, Cardinals.S))
765 { 723 {
766 Border ba = scene.GetCrossedBorder(pos + southCross, Cardinals.S); 724 neighboury--;
767 if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0) 725 newpos.Y = Constants.RegionSize - enterDistance;
768 {
769 neighboury--;
770 newpos.Y = Constants.RegionSize - enterDistance;
771 }
772 else
773 {
774 agent.IsInTransit = true;
775
776 neighboury = ba.TriggerRegionY;
777 neighbourx = ba.TriggerRegionX;
778 Vector3 newposition = pos;
779 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
780 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
781 agent.ControllingClient.SendAgentAlertMessage(
782 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
783 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
784 return true;
785 }
786 } 726 }
787 else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) 727 else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
788 { 728 {
@@ -790,35 +730,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
790 neighboury += (uint)(int)(c.BorderLine.Z / (int)Constants.RegionSize); 730 neighboury += (uint)(int)(c.BorderLine.Z / (int)Constants.RegionSize);
791 newpos.Y = enterDistance; 731 newpos.Y = enterDistance;
792 } 732 }
793
794
795 } 733 }
796 else if (scene.TestBorderCross(pos + southCross, Cardinals.S)) 734 else if (scene.TestBorderCross(pos + southCross, Cardinals.S))
797 { 735 {
798 Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S); 736 Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S);
799 if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0) 737 neighboury--;
800 { 738 newpos.Y = Constants.RegionSize - enterDistance;
801 neighboury--;
802 newpos.Y = Constants.RegionSize - enterDistance;
803 }
804 else
805 {
806 agent.IsInTransit = true;
807
808 neighboury = b.TriggerRegionY;
809 neighbourx = b.TriggerRegionX;
810 Vector3 newposition = pos;
811 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
812 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
813 agent.ControllingClient.SendAgentAlertMessage(
814 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
815 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
816 return true;
817 }
818 } 739 }
819 else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) 740 else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
820 { 741 {
821
822 Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N); 742 Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
823 neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize); 743 neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
824 newpos.Y = enterDistance; 744 newpos.Y = enterDistance;
@@ -849,19 +769,22 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
849 } 769 }
850 */ 770 */
851 771
852 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); 772 xDest = neighbourx;
773 yDest = neighboury;
853 774
854 int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize); 775 int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize);
855 776
777 ulong neighbourHandle = Utils.UIntsToLong((uint)x, (uint)y);
778
856 ExpiringCache<ulong, DateTime> r; 779 ExpiringCache<ulong, DateTime> r;
857 DateTime banUntil; 780 DateTime banUntil;
858 781
859 if (m_bannedRegions.TryGetValue(agent.ControllingClient.AgentId, out r)) 782 if (m_bannedRegions.TryGetValue(agentID, out r))
860 { 783 {
861 if (r.TryGetValue(neighbourHandle, out banUntil)) 784 if (r.TryGetValue(neighbourHandle, out banUntil))
862 { 785 {
863 if (DateTime.Now < banUntil) 786 if (DateTime.Now < banUntil)
864 return false; 787 return null;
865 r.Remove(neighbourHandle); 788 r.Remove(neighbourHandle);
866 } 789 }
867 } 790 }
@@ -873,28 +796,43 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
873 GridRegion neighbourRegion = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y); 796 GridRegion neighbourRegion = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y);
874 797
875 string reason; 798 string reason;
876 string version; 799 if (!scene.SimulationService.QueryAccess(neighbourRegion, agentID, newpos, out version, out reason))
877 if (!scene.SimulationService.QueryAccess(neighbourRegion, agent.ControllingClient.AgentId, newpos, out version, out reason))
878 { 800 {
879 agent.ControllingClient.SendAlertMessage("Cannot region cross into banned parcel");
880 if (r == null) 801 if (r == null)
881 { 802 {
882 r = new ExpiringCache<ulong, DateTime>(); 803 r = new ExpiringCache<ulong, DateTime>();
883 r.Add(neighbourHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15)); 804 r.Add(neighbourHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15));
884 805
885 m_bannedRegions.Add(agent.ControllingClient.AgentId, r, TimeSpan.FromSeconds(45)); 806 m_bannedRegions.Add(agentID, r, TimeSpan.FromSeconds(45));
886 } 807 }
887 else 808 else
888 { 809 {
889 r.Add(neighbourHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15)); 810 r.Add(neighbourHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15));
890 } 811 }
812 return null;
813 }
814
815 return neighbourRegion;
816 }
817
818 public bool Cross(ScenePresence agent, bool isFlying)
819 {
820 uint x;
821 uint y;
822 Vector3 newpos;
823 string version;
824
825 GridRegion neighbourRegion = GetDestination(agent.Scene, agent.UUID, agent.AbsolutePosition, out x, out y, out version, out newpos);
826 if (neighbourRegion == null)
827 {
828 agent.ControllingClient.SendAlertMessage("Cannot region cross into banned parcel");
891 return false; 829 return false;
892 } 830 }
893 831
894 agent.IsInTransit = true; 832 agent.IsInTransit = true;
895 833
896 CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync; 834 CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync;
897 d.BeginInvoke(agent, newpos, neighbourx, neighboury, neighbourRegion, isFlying, version, CrossAgentToNewRegionCompleted, d); 835 d.BeginInvoke(agent, newpos, x, y, neighbourRegion, isFlying, version, CrossAgentToNewRegionCompleted, d);
898 836
899 return true; 837 return true;
900 } 838 }
@@ -951,13 +889,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
951 icon.EndInvoke(iar); 889 icon.EndInvoke(iar);
952 } 890 }
953 891
954 public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, GridRegion neighbourRegion, bool isFlying, string version);
955
956 /// <summary> 892 /// <summary>
957 /// This Closes child agents on neighbouring regions 893 /// This Closes child agents on neighbouring regions
958 /// Calls an asynchronous method to do so.. so it doesn't lag the sim. 894 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
959 /// </summary> 895 /// </summary>
960 protected ScenePresence CrossAgentToNewRegionAsync( 896 public ScenePresence CrossAgentToNewRegionAsync(
961 ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, GridRegion neighbourRegion, 897 ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, GridRegion neighbourRegion,
962 bool isFlying, string version) 898 bool isFlying, string version)
963 { 899 {