aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Framework/EntityTransfer
diff options
context:
space:
mode:
authorUbitUmarov2015-09-01 14:54:35 +0100
committerUbitUmarov2015-09-01 14:54:35 +0100
commit371c9dd2af01a2e7422ec901ee1f80757284a78c (patch)
tree058d2a513cacb12efcce0c0df0ae14ad135dbfe2 /OpenSim/Region/CoreModules/Framework/EntityTransfer
parentremove lixo (diff)
parentdont change camera on crossings (diff)
downloadopensim-SC-371c9dd2af01a2e7422ec901ee1f80757284a78c.zip
opensim-SC-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.gz
opensim-SC-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.bz2
opensim-SC-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.xz
bad merge?
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework/EntityTransfer')
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs1027
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs4
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs20
3 files changed, 788 insertions, 263 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 4be19f0..7937383 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -154,12 +154,25 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
154 // Add this agent in this region as a banned person 154 // Add this agent in this region as a banned person
155 public void Add(ulong pRegionHandle, UUID pAgentID) 155 public void Add(ulong pRegionHandle, UUID pAgentID)
156 { 156 {
157<<<<<<< HEAD
157 if (!m_bannedRegions.TryGetValue(pAgentID, out m_idCache)) 158 if (!m_bannedRegions.TryGetValue(pAgentID, out m_idCache))
158 { 159 {
159 m_idCache = new ExpiringCache<ulong, DateTime>(); 160 m_idCache = new ExpiringCache<ulong, DateTime>();
160 m_bannedRegions.Add(pAgentID, m_idCache, TimeSpan.FromSeconds(45)); 161 m_bannedRegions.Add(pAgentID, m_idCache, TimeSpan.FromSeconds(45));
161 } 162 }
162 m_idCache.Add(pRegionHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15)); 163 m_idCache.Add(pRegionHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15));
164=======
165 this.Add(pRegionHandle, pAgentID, 45, 15);
166 }
167 public void Add(ulong pRegionHandle, UUID pAgentID, double newTime, double extendTime)
168 {
169 if (!m_bannedRegions.TryGetValue(pAgentID, out m_idCache))
170 {
171 m_idCache = new ExpiringCache<ulong, DateTime>();
172 m_bannedRegions.Add(pAgentID, m_idCache, TimeSpan.FromSeconds(newTime));
173 }
174 m_idCache.Add(pRegionHandle, DateTime.Now + TimeSpan.FromSeconds(extendTime), TimeSpan.FromSeconds(extendTime));
175>>>>>>> avn/ubitvar
163 } 176 }
164 // Remove the agent from the region's banned list 177 // Remove the agent from the region's banned list
165 public void Remove(ulong pRegionHandle, UUID pAgentID) 178 public void Remove(ulong pRegionHandle, UUID pAgentID)
@@ -209,6 +222,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
209 { 222 {
210 string transferVersionName = "SIMULATION"; 223 string transferVersionName = "SIMULATION";
211 float maxTransferVersion = 0.3f; 224 float maxTransferVersion = 0.3f;
225<<<<<<< HEAD
212 226
213 IConfig hypergridConfig = source.Configs["Hypergrid"]; 227 IConfig hypergridConfig = source.Configs["Hypergrid"];
214 if (hypergridConfig != null) 228 if (hypergridConfig != null)
@@ -221,6 +235,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
221 if (m_GatekeeperURI != string.Empty && !m_GatekeeperURI.EndsWith("/")) 235 if (m_GatekeeperURI != string.Empty && !m_GatekeeperURI.EndsWith("/"))
222 m_GatekeeperURI += '/'; 236 m_GatekeeperURI += '/';
223 } 237 }
238=======
239>>>>>>> avn/ubitvar
224 240
225 IConfig transferConfig = source.Configs["EntityTransfer"]; 241 IConfig transferConfig = source.Configs["EntityTransfer"];
226 if (transferConfig != null) 242 if (transferConfig != null)
@@ -491,16 +507,23 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
491 } 507 }
492 508
493 // TODO: Get proper AVG Height 509 // TODO: Get proper AVG Height
494 float localAVHeight = 1.56f; 510 float localHalfAVHeight = 0.8f;
511 if (sp.Appearance != null)
512 localHalfAVHeight = sp.Appearance.AvatarHeight / 2;
513
495 float posZLimit = 22; 514 float posZLimit = 22;
496 515
497 // TODO: Check other Scene HeightField 516 // TODO: Check other Scene HeightField
498 posZLimit = (float)sp.Scene.Heightmap[(int)position.X, (int)position.Y]; 517 posZLimit = (float)sp.Scene.Heightmap[(int)position.X, (int)position.Y];
518<<<<<<< HEAD
519=======
520
521 posZLimit += localHalfAVHeight + 0.1f;
522>>>>>>> avn/ubitvar
499 523
500 float newPosZ = posZLimit + localAVHeight; 524 if ((position.Z < posZLimit) && !(Single.IsInfinity(posZLimit) || Single.IsNaN(posZLimit)))
501 if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
502 { 525 {
503 position.Z = newPosZ; 526 position.Z = posZLimit;
504 } 527 }
505 528
506 if (sp.Flying) 529 if (sp.Flying)
@@ -599,9 +622,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
599 Util.RegionHandleToRegionLoc(regionHandle, out regX, out regY); 622 Util.RegionHandleToRegionLoc(regionHandle, out regX, out regY);
600 623
601 MapBlockData block = new MapBlockData(); 624 MapBlockData block = new MapBlockData();
625<<<<<<< HEAD
602 block.X = (ushort)regX; 626 block.X = (ushort)regX;
603 block.Y = (ushort)regY; 627 block.Y = (ushort)regY;
604 block.Access = (byte)SimAccess.Down; 628 block.Access = (byte)SimAccess.Down;
629=======
630 block.X = (ushort)(regX);
631 block.Y = (ushort)(regY);
632 block.Access = (byte)SimAccess.Down; // == not there
633>>>>>>> avn/ubitvar
605 634
606 List<MapBlockData> blocks = new List<MapBlockData>(); 635 List<MapBlockData> blocks = new List<MapBlockData>();
607 blocks.Add(block); 636 blocks.Add(block);
@@ -736,10 +765,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
736 return; 765 return;
737 } 766 }
738 767
768<<<<<<< HEAD
739 uint newRegionX, newRegionY, oldRegionX, oldRegionY; 769 uint newRegionX, newRegionY, oldRegionX, oldRegionY;
740 Util.RegionHandleToRegionLoc(reg.RegionHandle, out newRegionX, out newRegionY); 770 Util.RegionHandleToRegionLoc(reg.RegionHandle, out newRegionX, out newRegionY);
741 Util.RegionHandleToRegionLoc(sp.Scene.RegionInfo.RegionHandle, out oldRegionX, out oldRegionY); 771 Util.RegionHandleToRegionLoc(sp.Scene.RegionInfo.RegionHandle, out oldRegionX, out oldRegionY);
742 772
773=======
774>>>>>>> avn/ubitvar
743 ulong destinationHandle = finalDestination.RegionHandle; 775 ulong destinationHandle = finalDestination.RegionHandle;
744 776
745 // Let's do DNS resolution only once in this process, please! 777 // Let's do DNS resolution only once in this process, please!
@@ -762,7 +794,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
762 string version; 794 string version;
763 string myversion = string.Format("{0}/{1}", OutgoingTransferVersionName, MaxOutgoingTransferVersion); 795 string myversion = string.Format("{0}/{1}", OutgoingTransferVersionName, MaxOutgoingTransferVersion);
764 if (!Scene.SimulationService.QueryAccess( 796 if (!Scene.SimulationService.QueryAccess(
797<<<<<<< HEAD
765 finalDestination, sp.ControllingClient.AgentId, homeURI, true, position, myversion, sp.Scene.GetFormatsOffered(), out version, out reason)) 798 finalDestination, sp.ControllingClient.AgentId, homeURI, true, position, myversion, sp.Scene.GetFormatsOffered(), out version, out reason))
799=======
800 finalDestination, sp.ControllingClient.AgentId, homeURI, true, position, myversion, out version, out reason))
801>>>>>>> avn/ubitvar
766 { 802 {
767 sp.ControllingClient.SendTeleportFailed(reason); 803 sp.ControllingClient.SendTeleportFailed(reason);
768 804
@@ -808,7 +844,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
808 AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo(); 844 AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo();
809 agentCircuit.startpos = position; 845 agentCircuit.startpos = position;
810 agentCircuit.child = true; 846 agentCircuit.child = true;
811 agentCircuit.Appearance = sp.Appearance; 847
848// agentCircuit.Appearance = sp.Appearance;
849// agentCircuit.Appearance = new AvatarAppearance(sp.Appearance, true, false);
850 agentCircuit.Appearance = new AvatarAppearance();
851 agentCircuit.Appearance.AvatarHeight = sp.Appearance.AvatarHeight;
852
812 if (currentAgentCircuit != null) 853 if (currentAgentCircuit != null)
813 { 854 {
814 agentCircuit.ServiceURLs = currentAgentCircuit.ServiceURLs; 855 agentCircuit.ServiceURLs = currentAgentCircuit.ServiceURLs;
@@ -819,14 +860,48 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
819 agentCircuit.Id0 = currentAgentCircuit.Id0; 860 agentCircuit.Id0 = currentAgentCircuit.Id0;
820 } 861 }
821 862
863<<<<<<< HEAD
822 // if (NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY)) 864 // if (NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY))
823 float dist = (float)Math.Max(sp.Scene.DefaultDrawDistance, 865 float dist = (float)Math.Max(sp.Scene.DefaultDrawDistance,
824 (float)Math.Max(sp.Scene.RegionInfo.RegionSizeX, sp.Scene.RegionInfo.RegionSizeY)); 866 (float)Math.Max(sp.Scene.RegionInfo.RegionSizeX, sp.Scene.RegionInfo.RegionSizeY));
825 if (NeedsNewAgent(dist, oldRegionX, newRegionX, oldRegionY, newRegionY)) 867 if (NeedsNewAgent(dist, oldRegionX, newRegionX, oldRegionY, newRegionY))
868=======
869 IClientIPEndpoint ipepClient;
870
871 uint newRegionX, newRegionY, oldRegionX, oldRegionY;
872 Util.RegionHandleToRegionLoc(destinationHandle, out newRegionX, out newRegionY);
873 Util.RegionHandleToRegionLoc(sourceRegion.RegionHandle, out oldRegionX, out oldRegionY);
874 int oldSizeX = (int)sourceRegion.RegionSizeX;
875 int oldSizeY = (int)sourceRegion.RegionSizeY;
876 int newSizeX = finalDestination.RegionSizeX;
877 int newSizeY = finalDestination.RegionSizeY;
878
879 bool OutSideViewRange = NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY,
880 oldSizeX, oldSizeY, newSizeX, newSizeY);
881
882 if (OutSideViewRange)
883>>>>>>> avn/ubitvar
826 { 884 {
827 // brand new agent, let's create a new caps seed 885 m_log.DebugFormat(
886 "[ENTITY TRANSFER MODULE]: Determined that region {0} at {1},{2} needs new child agent for agent {3} from {4}",
887 finalDestination.RegionName, newRegionX, newRegionY, sp.Name, Scene.Name);
888
889 //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent...");
890 #region IP Translation for NAT
891 // Uses ipepClient above
892 if (sp.ClientView.TryGet(out ipepClient))
893 {
894 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
895 }
896 #endregion
828 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); 897 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
829 } 898 }
899 else
900 {
901 agentCircuit.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, reg.RegionHandle);
902 if (agentCircuit.CapsPath == null)
903 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
904 }
830 905
831 // We're going to fallback to V1 if the destination gives us anything smaller than 0.2 or we're forcing 906 // We're going to fallback to V1 if the destination gives us anything smaller than 0.2 or we're forcing
832 // use of the earlier protocol 907 // use of the earlier protocol
@@ -836,13 +911,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
836 float.TryParse(versionComponents[1], out versionNumber); 911 float.TryParse(versionComponents[1], out versionNumber);
837 912
838 if (versionNumber >= 0.2f && MaxOutgoingTransferVersion >= versionNumber) 913 if (versionNumber >= 0.2f && MaxOutgoingTransferVersion >= versionNumber)
914<<<<<<< HEAD
839 TransferAgent_V2(sp, agentCircuit, reg, finalDestination, endPoint, teleportFlags, oldRegionX, newRegionX, oldRegionY, newRegionY, version, out reason); 915 TransferAgent_V2(sp, agentCircuit, reg, finalDestination, endPoint, teleportFlags, oldRegionX, newRegionX, oldRegionY, newRegionY, version, out reason);
916=======
917 TransferAgent_V2(sp, agentCircuit, reg, finalDestination, endPoint, teleportFlags, OutSideViewRange , version, out reason);
918>>>>>>> avn/ubitvar
840 else 919 else
841 TransferAgent_V1(sp, agentCircuit, reg, finalDestination, endPoint, teleportFlags, oldRegionX, newRegionX, oldRegionY, newRegionY, version, out reason); 920 TransferAgent_V1(sp, agentCircuit, reg, finalDestination, endPoint, teleportFlags, OutSideViewRange, version, out reason);
842 } 921 }
843 922
844 private void TransferAgent_V1(ScenePresence sp, AgentCircuitData agentCircuit, GridRegion reg, GridRegion finalDestination, 923 private void TransferAgent_V1(ScenePresence sp, AgentCircuitData agentCircuit, GridRegion reg, GridRegion finalDestination,
845 IPEndPoint endPoint, uint teleportFlags, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, string version, out string reason) 924 IPEndPoint endPoint, uint teleportFlags, bool OutSideViewRange, string version, out string reason)
846 { 925 {
847 ulong destinationHandle = finalDestination.RegionHandle; 926 ulong destinationHandle = finalDestination.RegionHandle;
848 AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); 927 AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
@@ -851,6 +930,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
851 "[ENTITY TRANSFER MODULE]: Using TP V1 for {0} going from {1} to {2}", 930 "[ENTITY TRANSFER MODULE]: Using TP V1 for {0} going from {1} to {2}",
852 sp.Name, Scene.Name, finalDestination.RegionName); 931 sp.Name, Scene.Name, finalDestination.RegionName);
853 932
933 string capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
934
854 // Let's create an agent there if one doesn't exist yet. 935 // Let's create an agent there if one doesn't exist yet.
855 // NOTE: logout will always be false for a non-HG teleport. 936 // NOTE: logout will always be false for a non-HG teleport.
856 bool logout = false; 937 bool logout = false;
@@ -892,6 +973,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
892 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring); 973 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring);
893 974
894 // OK, it got this agent. Let's close some child agents 975 // OK, it got this agent. Let's close some child agents
976<<<<<<< HEAD
895 sp.CloseChildAgents(newRegionX, newRegionY); 977 sp.CloseChildAgents(newRegionX, newRegionY);
896 978
897 IClientIPEndpoint ipepClient; 979 IClientIPEndpoint ipepClient;
@@ -903,17 +985,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
903 m_log.DebugFormat( 985 m_log.DebugFormat(
904 "[ENTITY TRANSFER MODULE]: Determined that region {0} at {1},{2} needs new child agent for incoming agent {3} from {4}", 986 "[ENTITY TRANSFER MODULE]: Determined that region {0} at {1},{2} needs new child agent for incoming agent {3} from {4}",
905 finalDestination.RegionName, newRegionX, newRegionY, sp.Name, Scene.Name); 987 finalDestination.RegionName, newRegionX, newRegionY, sp.Name, Scene.Name);
988=======
989>>>>>>> avn/ubitvar
906 990
907 //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent...");
908 #region IP Translation for NAT
909 // Uses ipepClient above
910 if (sp.ClientView.TryGet(out ipepClient))
911 {
912 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
913 }
914 #endregion
915 capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
916 991
992 if (OutSideViewRange)
993 {
917 if (m_eqModule != null) 994 if (m_eqModule != null)
918 { 995 {
919 // The EnableSimulator message makes the client establish a connection with the destination 996 // The EnableSimulator message makes the client establish a connection with the destination
@@ -943,15 +1020,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
943 sp.ControllingClient.InformClientOfNeighbour(destinationHandle, endPoint); 1020 sp.ControllingClient.InformClientOfNeighbour(destinationHandle, endPoint);
944 } 1021 }
945 } 1022 }
946 else
947 {
948 agentCircuit.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, reg.RegionHandle);
949 capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
950 }
951 1023
952 // Let's send a full update of the agent. This is a synchronous call. 1024 // Let's send a full update of the agent. This is a synchronous call.
953 AgentData agent = new AgentData(); 1025 AgentData agent = new AgentData();
954 sp.CopyTo(agent); 1026 sp.CopyTo(agent);
1027
1028 if ((teleportFlags & (uint)TeleportFlags.IsFlying) != 0)
1029 agent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
1030
955 agent.Position = agentCircuit.startpos; 1031 agent.Position = agentCircuit.startpos;
956 SetCallbackURL(agent, sp.Scene.RegionInfo); 1032 SetCallbackURL(agent, sp.Scene.RegionInfo);
957 1033
@@ -1053,7 +1129,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1053 return; 1129 return;
1054 } 1130 }
1055 1131
1056 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp);
1057 1132
1058 // For backwards compatibility 1133 // For backwards compatibility
1059 if (version == "Unknown" || version == string.Empty) 1134 if (version == "Unknown" || version == string.Empty)
@@ -1063,18 +1138,30 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1063 CrossAttachmentsIntoNewRegion(finalDestination, sp, true); 1138 CrossAttachmentsIntoNewRegion(finalDestination, sp, true);
1064 } 1139 }
1065 1140
1141 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp);
1142
1143
1066 // May need to logout or other cleanup 1144 // May need to logout or other cleanup
1067 AgentHasMovedAway(sp, logout); 1145// AgentHasMovedAway(sp, logout);
1146// AgentHasMovedAway(sp, true); // until logout use is checked
1068 1147
1069 // Well, this is it. The agent is over there. 1148 // Well, this is it. The agent is over there.
1070 KillEntity(sp.Scene, sp.LocalId); 1149// KillEntity(sp.Scene, sp.LocalId);
1150
1151 sp.HasMovedAway(!OutSideViewRange);
1152
1153 sp.CloseChildAgents(destinationHandle,finalDestination.RegionSizeX,finalDestination.RegionSizeY);
1071 1154
1072 // Now let's make it officially a child agent 1155 // Now let's make it officially a child agent
1073 sp.MakeChildAgent(); 1156 sp.MakeChildAgent(destinationHandle);
1074 1157
1075 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone 1158 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
1076 1159
1160<<<<<<< HEAD
1077 if (NeedsClosing(sp.Scene.DefaultDrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) 1161 if (NeedsClosing(sp.Scene.DefaultDrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY, reg))
1162=======
1163 if (OutSideViewRange)
1164>>>>>>> avn/ubitvar
1078 { 1165 {
1079 if (!sp.Scene.IncomingPreCloseClient(sp)) 1166 if (!sp.Scene.IncomingPreCloseClient(sp))
1080 return; 1167 return;
@@ -1089,19 +1176,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1089 1176
1090 sp.Scene.CloseAgent(sp.UUID, false); 1177 sp.Scene.CloseAgent(sp.UUID, false);
1091 } 1178 }
1092 else
1093 {
1094 // now we have a child agent in this region.
1095 sp.Reset();
1096 }
1097 } 1179 }
1098 1180
1099 private void TransferAgent_V2(ScenePresence sp, AgentCircuitData agentCircuit, GridRegion reg, GridRegion finalDestination, 1181 private void TransferAgent_V2(ScenePresence sp, AgentCircuitData agentCircuit, GridRegion reg, GridRegion finalDestination,
1100 IPEndPoint endPoint, uint teleportFlags, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, string version, out string reason) 1182 IPEndPoint endPoint, uint teleportFlags, bool OutSideViewRange, string version, out string reason)
1101 { 1183 {
1102 ulong destinationHandle = finalDestination.RegionHandle; 1184 ulong destinationHandle = finalDestination.RegionHandle;
1103 AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); 1185 AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
1104 1186
1187 string capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);;
1188
1105 // Let's create an agent there if one doesn't exist yet. 1189 // Let's create an agent there if one doesn't exist yet.
1106 // NOTE: logout will always be false for a non-HG teleport. 1190 // NOTE: logout will always be false for a non-HG teleport.
1107 bool logout = false; 1191 bool logout = false;
@@ -1142,6 +1226,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1142 // Past this point we have to attempt clean up if the teleport fails, so update transfer state. 1226 // Past this point we have to attempt clean up if the teleport fails, so update transfer state.
1143 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring); 1227 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring);
1144 1228
1229<<<<<<< HEAD
1145 IClientIPEndpoint ipepClient; 1230 IClientIPEndpoint ipepClient;
1146 string capsPath = String.Empty; 1231 string capsPath = String.Empty;
1147 float dist = (float)Math.Max(sp.Scene.DefaultDrawDistance, 1232 float dist = (float)Math.Max(sp.Scene.DefaultDrawDistance,
@@ -1168,6 +1253,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1168 capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); 1253 capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
1169 } 1254 }
1170 1255
1256=======
1257>>>>>>> avn/ubitvar
1171 // We need to set this here to avoid an unlikely race condition when teleporting to a neighbour simulator, 1258 // We need to set this here to avoid an unlikely race condition when teleporting to a neighbour simulator,
1172 // where that neighbour simulator could otherwise request a child agent create on the source which then 1259 // where that neighbour simulator could otherwise request a child agent create on the source which then
1173 // closes our existing agent which is still signalled as root. 1260 // closes our existing agent which is still signalled as root.
@@ -1189,6 +1276,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1189 AgentData agent = new AgentData(); 1276 AgentData agent = new AgentData();
1190 sp.CopyTo(agent); 1277 sp.CopyTo(agent);
1191 agent.Position = agentCircuit.startpos; 1278 agent.Position = agentCircuit.startpos;
1279
1280 if ((teleportFlags & (uint)TeleportFlags.IsFlying) != 0)
1281 agent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
1282
1192 agent.SenderWantsToWaitForRoot = true; 1283 agent.SenderWantsToWaitForRoot = true;
1193 //SetCallbackURL(agent, sp.Scene.RegionInfo); 1284 //SetCallbackURL(agent, sp.Scene.RegionInfo);
1194 1285
@@ -1224,25 +1315,29 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1224 1315
1225 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp); 1316 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp);
1226 1317
1318 sp.HasMovedAway(!OutSideViewRange);
1319
1227 // Need to signal neighbours whether child agents may need closing irrespective of whether this 1320 // Need to signal neighbours whether child agents may need closing irrespective of whether this
1228 // one needed closing. We also need to close child agents as quickly as possible to avoid complicated 1321 // one needed closing. We also need to close child agents as quickly as possible to avoid complicated
1229 // race conditions with rapid agent releporting (e.g. from A1 to a non-neighbour B, back 1322 // race conditions with rapid agent releporting (e.g. from A1 to a non-neighbour B, back
1230 // to a neighbour A2 then off to a non-neighbour C). Closing child agents any later requires complex 1323 // to a neighbour A2 then off to a non-neighbour C). Closing child agents any later requires complex
1231 // distributed checks to avoid problems in rapid reteleporting scenarios and where child agents are 1324 // distributed checks to avoid problems in rapid reteleporting scenarios and where child agents are
1232 // abandoned without proper close by viewer but then re-used by an incoming connection. 1325 // abandoned without proper close by viewer but then re-used by an incoming connection.
1233 sp.CloseChildAgents(newRegionX, newRegionY); 1326 sp.CloseChildAgents(destinationHandle, finalDestination.RegionSizeX, finalDestination.RegionSizeY);
1234
1235 // May need to logout or other cleanup
1236 AgentHasMovedAway(sp, logout);
1237 1327
1328// AgentHasMovedAway(sp, true);
1238 // Well, this is it. The agent is over there. 1329 // Well, this is it. The agent is over there.
1239 KillEntity(sp.Scene, sp.LocalId); 1330// KillEntity(sp.Scene, sp.LocalId);
1240 1331
1241 // Now let's make it officially a child agent 1332 // Now let's make it officially a child agent
1242 sp.MakeChildAgent(); 1333 sp.MakeChildAgent(destinationHandle);
1243 1334
1244 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone 1335 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
1336<<<<<<< HEAD
1245 if (NeedsClosing(sp.Scene.DefaultDrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) 1337 if (NeedsClosing(sp.Scene.DefaultDrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY, reg))
1338=======
1339 if (OutSideViewRange)
1340>>>>>>> avn/ubitvar
1246 { 1341 {
1247 if (!sp.Scene.IncomingPreCloseClient(sp)) 1342 if (!sp.Scene.IncomingPreCloseClient(sp))
1248 return; 1343 return;
@@ -1263,11 +1358,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1263 1358
1264 sp.Scene.CloseAgent(sp.UUID, false); 1359 sp.Scene.CloseAgent(sp.UUID, false);
1265 } 1360 }
1361/*
1266 else 1362 else
1267 { 1363 {
1268 // now we have a child agent in this region. 1364 // now we have a child agent in this region.
1269 sp.Reset(); 1365 sp.Reset();
1270 } 1366 }
1367 */
1271 } 1368 }
1272 1369
1273 /// <summary> 1370 /// <summary>
@@ -1351,7 +1448,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1351 protected virtual void AgentHasMovedAway(ScenePresence sp, bool logout) 1448 protected virtual void AgentHasMovedAway(ScenePresence sp, bool logout)
1352 { 1449 {
1353 if (sp.Scene.AttachmentsModule != null) 1450 if (sp.Scene.AttachmentsModule != null)
1354 sp.Scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, true); 1451 sp.Scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, logout);
1355 } 1452 }
1356 1453
1357 protected void KillEntity(Scene scene, uint localID) 1454 protected void KillEntity(Scene scene, uint localID)
@@ -1368,7 +1465,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1368 // This returns 'true' if the new region already has a child agent for our 1465 // This returns 'true' if the new region already has a child agent for our
1369 // incoming agent. The implication is that, if 'false', we have to create the 1466 // incoming agent. The implication is that, if 'false', we have to create the
1370 // child and then teleport into the region. 1467 // child and then teleport into the region.
1468<<<<<<< HEAD
1371 protected virtual bool NeedsNewAgent(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY) 1469 protected virtual bool NeedsNewAgent(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY)
1470=======
1471 protected virtual bool NeedsNewAgent(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY,
1472 int oldsizeX, int oldsizeY, int newsizeX, int newsizeY)
1473>>>>>>> avn/ubitvar
1372 { 1474 {
1373 if (m_regionCombinerModule != null && m_regionCombinerModule.IsRootForMegaregion(Scene.RegionInfo.RegionID)) 1475 if (m_regionCombinerModule != null && m_regionCombinerModule.IsRootForMegaregion(Scene.RegionInfo.RegionID))
1374 { 1476 {
@@ -1381,17 +1483,23 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1381 1483
1382 return !(newRegionX >= swCorner.X && newRegionX <= neCorner.X && newRegionY >= swCorner.Y && newRegionY <= neCorner.Y); 1484 return !(newRegionX >= swCorner.X && newRegionX <= neCorner.X && newRegionY >= swCorner.Y && newRegionY <= neCorner.Y);
1383 } 1485 }
1384 else 1486
1385 { 1487 return Util.IsOutsideView(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY,
1386 return Util.IsOutsideView(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY); 1488 oldsizeX, oldsizeY, newsizeX, newsizeY);
1387 }
1388 } 1489 }
1490<<<<<<< HEAD
1389 1491
1390 protected virtual bool NeedsClosing(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg) 1492=======
1493/*
1494 protected virtual bool NeedsClosing(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY,
1495 uint oldsizeX, uint oldsizeY, uint newsizeX, uint newsizeY, GridRegion reg)
1391 { 1496 {
1392 return Util.IsOutsideView(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY);
1393 }
1394 1497
1498 return Util.IsOutsideView(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY,
1499 oldsizeX, oldsizeY, newsizeX, newsizeY);
1500 }
1501*/
1502>>>>>>> avn/ubitvar
1395 #endregion 1503 #endregion
1396 1504
1397 #region Landmark Teleport 1505 #region Landmark Teleport
@@ -1472,14 +1580,20 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1472 1580
1473 #region Agent Crossings 1581 #region Agent Crossings
1474 1582
1583<<<<<<< HEAD
1475 // Given a position relative to the current region (which has previously been tested to 1584 // Given a position relative to the current region (which has previously been tested to
1476 // see that it is actually outside the current region), find the new region that the 1585 // see that it is actually outside the current region), find the new region that the
1477 // point is actually in. 1586 // point is actually in.
1478 // Returns the coordinates and information of the new region or 'null' of it doesn't exist. 1587 // Returns the coordinates and information of the new region or 'null' of it doesn't exist.
1479 public GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, 1588 public GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos,
1480 out string version, out Vector3 newpos, out string failureReason) 1589 out string version, out Vector3 newpos, out string failureReason)
1590=======
1591 public bool checkAgentAccessToRegion(ScenePresence agent, GridRegion destiny, Vector3 position, out string version, out string reason)
1592>>>>>>> avn/ubitvar
1481 { 1593 {
1594 reason = String.Empty;
1482 version = String.Empty; 1595 version = String.Empty;
1596<<<<<<< HEAD
1483 newpos = pos; 1597 newpos = pos;
1484 failureReason = string.Empty; 1598 failureReason = string.Empty;
1485 string homeURI = scene.GetAgentHomeURI(agentID); 1599 string homeURI = scene.GetAgentHomeURI(agentID);
@@ -1541,32 +1655,180 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1541 LogHeader, neighbourRegion.RegionName, 1655 LogHeader, neighbourRegion.RegionName,
1542 neighbourRegion.RegionLocX, neighbourRegion.RegionLocY, neighbourRegion.RegionSizeX, neighbourRegion.RegionSizeY, 1656 neighbourRegion.RegionLocX, neighbourRegion.RegionLocY, neighbourRegion.RegionSizeX, neighbourRegion.RegionSizeY,
1543 newpos.X, newpos.Y); 1657 newpos.X, newpos.Y);
1658=======
1659
1660 UUID agentID = agent.UUID;
1661 ulong destinyHandle = destiny.RegionHandle;
1662
1663 if (m_bannedRegionCache.IfBanned(destinyHandle, agentID))
1664 {
1665 reason = "Cannot connect to region";
1666 return false;
1667 }
1668
1669 Scene ascene = agent.Scene;
1670 string homeURI = ascene.GetAgentHomeURI(agentID);
1671 string myversion = string.Format("{0}/{1}", OutgoingTransferVersionName, MaxOutgoingTransferVersion);
1672
1673
1674 if (!ascene.SimulationService.QueryAccess(destiny, agentID, homeURI, false, position,
1675 myversion, out version, out reason))
1676 {
1677 m_bannedRegionCache.Add(destinyHandle, agentID, 30.0, 30.0);
1678 return false;
1679 }
1680
1681 return true;
1682 }
1683
1684 public GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, out string version, out Vector3 newpos)
1685 {
1686 string r = String.Empty;
1687 return GetDestination(scene, agentID, pos, out version, out newpos, out r);
1688 }
1689
1690 // Given a position relative to the current region (which has previously been tested to
1691 // see that it is actually outside the current region), find the new region that the
1692 // point is actually in.
1693 // Returns the coordinates and information of the new region or 'null' of it doesn't exist.
1694
1695 // now only works for crossings
1696
1697 public GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos,
1698 out string version, out Vector3 newpos, out string failureReason)
1699 {
1700 version = String.Empty;
1701 newpos = pos;
1702 failureReason = string.Empty;
1703
1704// m_log.DebugFormat(
1705// "[ENTITY TRANSFER MODULE]: Crossing agent {0} at pos {1} in {2}", agent.Name, pos, scene.Name);
1706
1707 // Compute world location of the object's position
1708 double presenceWorldX = (double)scene.RegionInfo.WorldLocX + pos.X;
1709 double presenceWorldY = (double)scene.RegionInfo.WorldLocY + pos.Y;
1710
1711 // Call the grid service to lookup the region containing the new position.
1712 GridRegion neighbourRegion = GetRegionContainingWorldLocation(scene.GridService, scene.RegionInfo.ScopeID,
1713 presenceWorldX, presenceWorldY,
1714 Math.Max(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY));
1715
1716 if (neighbourRegion != null)
1717 {
1718 // Compute the entity's position relative to the new region
1719 newpos = new Vector3((float)(presenceWorldX - (double)neighbourRegion.RegionLocX),
1720 (float)(presenceWorldY - (double)neighbourRegion.RegionLocY),
1721 pos.Z);
1722
1723 if (m_bannedRegionCache.IfBanned(neighbourRegion.RegionHandle, agentID))
1724 {
1725 failureReason = "Cannot region cross into banned parcel";
1726 neighbourRegion = null;
1727 }
1728 else
1729 {
1730 // If not banned, make sure this agent is not in the list.
1731 m_bannedRegionCache.Remove(neighbourRegion.RegionHandle, agentID);
1732 }
1733
1734 // Check to see if we have access to the target region.
1735 string myversion = string.Format("{0}/{1}", OutgoingTransferVersionName, MaxOutgoingTransferVersion);
1736 string homeURI = scene.GetAgentHomeURI(agentID);
1737 if (neighbourRegion != null
1738 && !scene.SimulationService.QueryAccess(neighbourRegion, agentID, homeURI, false, newpos, myversion, out version, out failureReason))
1739 {
1740 // remember banned
1741 m_bannedRegionCache.Add(neighbourRegion.RegionHandle, agentID);
1742 neighbourRegion = null;
1743 }
1744 }
1745 else
1746 {
1747 // The destination region just doesn't exist
1748 failureReason = "Cannot cross into non-existent region";
1749 }
1750>>>>>>> avn/ubitvar
1751
1752 if (neighbourRegion == null)
1753 m_log.DebugFormat("{0} GetDestination: region not found. Old region name={1} at <{2},{3}> of size <{4},{5}>. Old pos={6}",
1754 LogHeader, scene.RegionInfo.RegionName,
1755 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY,
1756 scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY,
1757 pos);
1758 else
1759 m_log.DebugFormat("{0} GetDestination: new region={1} at <{2},{3}> of size <{4},{5}>, newpos=<{6},{7}>",
1760 LogHeader, neighbourRegion.RegionName,
1761 neighbourRegion.RegionLocX, neighbourRegion.RegionLocY, neighbourRegion.RegionSizeX, neighbourRegion.RegionSizeY,
1762 newpos.X, newpos.Y);
1544 1763
1545 return neighbourRegion; 1764 return neighbourRegion;
1546 } 1765 }
1547 1766
1548 public bool Cross(ScenePresence agent, bool isFlying) 1767 public bool Cross(ScenePresence agent, bool isFlying)
1549 { 1768 {
1769<<<<<<< HEAD
1770=======
1771 agent.IsInTransit = true;
1772 CrossAsyncDelegate d = CrossAsync;
1773 d.BeginInvoke(agent, isFlying, CrossCompleted, d);
1774 return true;
1775 }
1776
1777 private void CrossCompleted(IAsyncResult iar)
1778 {
1779 CrossAsyncDelegate icon = (CrossAsyncDelegate)iar.AsyncState;
1780 ScenePresence agent = icon.EndInvoke(iar);
1781
1782 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname);
1783
1784 if(!agent.IsChildAgent)
1785 {
1786 // crossing failed
1787 agent.CrossToNewRegionFail();
1788 }
1789 agent.IsInTransit = false;
1790 }
1791
1792 public ScenePresence CrossAsync(ScenePresence agent, bool isFlying)
1793 {
1794 uint x;
1795 uint y;
1796>>>>>>> avn/ubitvar
1550 Vector3 newpos; 1797 Vector3 newpos;
1551 string version; 1798 string version;
1552 string failureReason; 1799 string failureReason;
1553 1800
1801<<<<<<< HEAD
1554 GridRegion neighbourRegion = GetDestination(agent.Scene, agent.UUID, agent.AbsolutePosition, 1802 GridRegion neighbourRegion = GetDestination(agent.Scene, agent.UUID, agent.AbsolutePosition,
1555 out version, out newpos, out failureReason); 1803 out version, out newpos, out failureReason);
1556 if (neighbourRegion == null) 1804 if (neighbourRegion == null)
1557 { 1805 {
1558 agent.ControllingClient.SendAlertMessage(failureReason); 1806 agent.ControllingClient.SendAlertMessage(failureReason);
1559 return false; 1807 return false;
1560 } 1808=======
1809 Vector3 pos = agent.AbsolutePosition + agent.Velocity;
1561 1810
1562 agent.IsInTransit = true; 1811 GridRegion neighbourRegion = GetDestination(agent.Scene, agent.UUID, pos,
1812 out version, out newpos, out failureReason);
1813 if (neighbourRegion == null)
1814 {
1815 if (failureReason != String.Empty)
1816 agent.ControllingClient.SendAlertMessage(failureReason);
1817 return agent;
1818>>>>>>> avn/ubitvar
1819 }
1563 1820
1564 CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync; 1821// agent.IsInTransit = true;
1565 d.BeginInvoke(agent, newpos, neighbourRegion, isFlying, version, CrossAgentToNewRegionCompleted, d);
1566 1822
1823<<<<<<< HEAD
1567 Scene.EventManager.TriggerCrossAgentToNewRegion(agent, isFlying, neighbourRegion); 1824 Scene.EventManager.TriggerCrossAgentToNewRegion(agent, isFlying, neighbourRegion);
1568 1825
1569 return true; 1826 return true;
1827=======
1828 CrossAgentToNewRegionAsync(agent, newpos, neighbourRegion, isFlying, version);
1829 agent.IsInTransit = false;
1830 return agent;
1831>>>>>>> avn/ubitvar
1570 } 1832 }
1571 1833
1572 1834
@@ -1691,12 +1953,23 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1691 1953
1692 public bool CrossAgentIntoNewRegionMain(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, bool isFlying) 1954 public bool CrossAgentIntoNewRegionMain(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, bool isFlying)
1693 { 1955 {
1956 int ts = Util.EnvironmentTickCount();
1694 try 1957 try
1695 { 1958 {
1696 AgentData cAgent = new AgentData(); 1959 AgentData cAgent = new AgentData();
1697 agent.CopyTo(cAgent); 1960 agent.CopyTo(cAgent);
1961<<<<<<< HEAD
1698 cAgent.Position = pos; 1962 cAgent.Position = pos;
1699 1963
1964=======
1965
1966// agent.Appearance.WearableCacheItems = null;
1967
1968 cAgent.Position = pos;
1969
1970 cAgent.ChildrenCapSeeds = agent.KnownRegions;
1971
1972>>>>>>> avn/ubitvar
1700 if (isFlying) 1973 if (isFlying)
1701 cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; 1974 cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
1702 1975
@@ -1716,11 +1989,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1716 neighbourRegion.RegionName, agent.Name); 1989 neighbourRegion.RegionName, agent.Name);
1717 1990
1718 ReInstantiateScripts(agent); 1991 ReInstantiateScripts(agent);
1719 agent.AddToPhysicalScene(isFlying); 1992 if(agent.ParentID == 0 && agent.ParentUUID == UUID.Zero)
1993 agent.AddToPhysicalScene(isFlying);
1720 1994
1721 return false; 1995 return false;
1722 } 1996 }
1723 1997
1998 m_log.DebugFormat("[CrossAgentIntoNewRegionMain] ok, time {0}ms",Util.EnvironmentTickCountSubtract(ts));
1999
1724 } 2000 }
1725 catch (Exception e) 2001 catch (Exception e)
1726 { 2002 {
@@ -1738,7 +2014,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1738 public void CrossAgentToNewRegionPost(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, 2014 public void CrossAgentToNewRegionPost(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion,
1739 bool isFlying, string version) 2015 bool isFlying, string version)
1740 { 2016 {
1741 agent.ControllingClient.RequestClientInfo();
1742 2017
1743 string agentcaps; 2018 string agentcaps;
1744 if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps)) 2019 if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps))
@@ -1749,6 +2024,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1749 } 2024 }
1750 2025
1751 // No turning back 2026 // No turning back
2027
1752 agent.IsChildAgent = true; 2028 agent.IsChildAgent = true;
1753 2029
1754 string capsPath = neighbourRegion.ServerURI + CapsUtil.GetCapsSeedPath(agentcaps); 2030 string capsPath = neighbourRegion.ServerURI + CapsUtil.GetCapsSeedPath(agentcaps);
@@ -1760,7 +2036,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1760 if (m_eqModule != null) 2036 if (m_eqModule != null)
1761 { 2037 {
1762 m_eqModule.CrossRegion( 2038 m_eqModule.CrossRegion(
1763 neighbourRegion.RegionHandle, pos + agent.Velocity, vel2 /* agent.Velocity */, 2039 neighbourRegion.RegionHandle, pos, vel2 /* agent.Velocity */,
1764 neighbourRegion.ExternalEndPoint, 2040 neighbourRegion.ExternalEndPoint,
1765 capsPath, agent.UUID, agent.ControllingClient.SessionId, 2041 capsPath, agent.UUID, agent.ControllingClient.SessionId,
1766 neighbourRegion.RegionSizeX, neighbourRegion.RegionSizeY); 2042 neighbourRegion.RegionSizeX, neighbourRegion.RegionSizeY);
@@ -1768,10 +2044,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1768 else 2044 else
1769 { 2045 {
1770 m_log.ErrorFormat("{0} Using old CrossRegion packet. Varregion will not work!!", LogHeader); 2046 m_log.ErrorFormat("{0} Using old CrossRegion packet. Varregion will not work!!", LogHeader);
1771 agent.ControllingClient.CrossRegion(neighbourRegion.RegionHandle, pos + agent.Velocity, agent.Velocity, neighbourRegion.ExternalEndPoint, 2047 agent.ControllingClient.CrossRegion(neighbourRegion.RegionHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint,
1772 capsPath); 2048 capsPath);
1773 } 2049 }
1774 2050
2051<<<<<<< HEAD
1775 // SUCCESS! 2052 // SUCCESS!
1776 m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.ReceivedAtDestination); 2053 m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.ReceivedAtDestination);
1777 2054
@@ -1788,6 +2065,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1788 agent.SendOtherAgentsAvatarDataToClient(); 2065 agent.SendOtherAgentsAvatarDataToClient();
1789 agent.SendOtherAgentsAppearanceToClient(); 2066 agent.SendOtherAgentsAppearanceToClient();
1790 2067
2068=======
2069>>>>>>> avn/ubitvar
1791 // Backwards compatibility. Best effort 2070 // Backwards compatibility. Best effort
1792 if (version == "Unknown" || version == string.Empty) 2071 if (version == "Unknown" || version == string.Empty)
1793 { 2072 {
@@ -1796,14 +2075,31 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1796 CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true); 2075 CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true);
1797 } 2076 }
1798 2077
2078<<<<<<< HEAD
1799 // Next, let's close the child agent connections that are too far away. 2079 // Next, let's close the child agent connections that are too far away.
1800 uint neighbourx; 2080 uint neighbourx;
1801 uint neighboury; 2081 uint neighboury;
1802 Util.RegionHandleToRegionLoc(neighbourRegion.RegionHandle, out neighbourx, out neighboury); 2082 Util.RegionHandleToRegionLoc(neighbourRegion.RegionHandle, out neighbourx, out neighboury);
2083=======
2084 // SUCCESS!
2085 m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.ReceivedAtDestination);
2086
2087 // Unlike a teleport, here we do not wait for the destination region to confirm the receipt.
2088 m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp);
1803 2089
1804 agent.CloseChildAgents(neighbourx, neighboury); 2090 // this may need the attachments
2091
2092 agent.HasMovedAway(true);
2093
2094 agent.MakeChildAgent(neighbourRegion.RegionHandle);
2095
2096 // FIXME: Possibly this should occur lower down after other commands to close other agents,
2097 // but not sure yet what the side effects would be.
2098 m_entityTransferStateMachine.ResetFromTransit(agent.UUID);
2099>>>>>>> avn/ubitvar
2100
2101 agent.CloseChildAgents(neighbourRegion.RegionHandle, neighbourRegion.RegionSizeX, neighbourRegion.RegionSizeY);
1805 2102
1806 AgentHasMovedAway(agent, false);
1807 2103
1808 // the user may change their profile information in other region, 2104 // the user may change their profile information in other region,
1809 // so the userinfo in UserProfileCache is not reliable any more, delete it 2105 // so the userinfo in UserProfileCache is not reliable any more, delete it
@@ -1843,7 +2139,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1843 #region Enable Child Agent 2139 #region Enable Child Agent
1844 2140
1845 /// <summary> 2141 /// <summary>
1846 /// This informs a single neighbouring region about agent "avatar". 2142 /// This informs a single neighbouring region about agent "avatar", and avatar about it
1847 /// Calls an asynchronous method to do so.. so it doesn't lag the sim. 2143 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
1848 /// </summary> 2144 /// </summary>
1849 /// <param name="sp"></param> 2145 /// <param name="sp"></param>
@@ -1852,22 +2148,36 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1852 { 2148 {
1853 m_log.DebugFormat("[ENTITY TRANSFER]: Enabling child agent in new neighbour {0}", region.RegionName); 2149 m_log.DebugFormat("[ENTITY TRANSFER]: Enabling child agent in new neighbour {0}", region.RegionName);
1854 2150
2151 ulong currentRegionHandler = sp.Scene.RegionInfo.RegionHandle;
2152 ulong regionhandler = region.RegionHandle;
2153
2154 Dictionary<ulong, string> seeds = new Dictionary<ulong, string>(sp.Scene.CapsModule.GetChildrenSeeds(sp.UUID));
2155
2156 if (seeds.ContainsKey(regionhandler))
2157 seeds.Remove(regionhandler);
2158/*
2159 List<ulong> oldregions = new List<ulong>(seeds.Keys);
2160
2161 if (oldregions.Contains(currentRegionHandler))
2162 oldregions.Remove(currentRegionHandler);
2163*/
2164 if (!seeds.ContainsKey(currentRegionHandler))
2165 seeds.Add(currentRegionHandler, sp.ControllingClient.RequestClientInfo().CapsPath);
2166
1855 AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); 2167 AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
1856 AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); 2168 AgentCircuitData agent = sp.ControllingClient.RequestClientInfo();
1857 agent.BaseFolder = UUID.Zero; 2169 agent.BaseFolder = UUID.Zero;
1858 agent.InventoryFolder = UUID.Zero; 2170 agent.InventoryFolder = UUID.Zero;
1859 agent.startpos = new Vector3(128, 128, 70); 2171 agent.startpos = sp.AbsolutePosition + CalculateOffset(sp, region);
1860 agent.child = true; 2172 agent.child = true;
1861 agent.Appearance = sp.Appearance; 2173 agent.Appearance = new AvatarAppearance();
1862 agent.CapsPath = CapsUtil.GetRandomCapsObjectPath(); 2174 agent.Appearance.AvatarHeight = sp.Appearance.AvatarHeight;
1863 2175
1864 agent.ChildrenCapSeeds = new Dictionary<ulong, string>(sp.Scene.CapsModule.GetChildrenSeeds(sp.UUID)); 2176 agent.CapsPath = CapsUtil.GetRandomCapsObjectPath();
1865 //m_log.DebugFormat("[XXX] Seeds 1 {0}", agent.ChildrenCapSeeds.Count);
1866 2177
1867 if (!agent.ChildrenCapSeeds.ContainsKey(sp.Scene.RegionInfo.RegionHandle)) 2178 seeds.Add(regionhandler, agent.CapsPath);
1868 agent.ChildrenCapSeeds.Add(sp.Scene.RegionInfo.RegionHandle, sp.ControllingClient.RequestClientInfo().CapsPath);
1869 //m_log.DebugFormat("[XXX] Seeds 2 {0}", agent.ChildrenCapSeeds.Count);
1870 2179
2180<<<<<<< HEAD
1871 sp.AddNeighbourRegion(region.RegionHandle, agent.CapsPath); 2181 sp.AddNeighbourRegion(region.RegionHandle, agent.CapsPath);
1872 //foreach (ulong h in agent.ChildrenCapSeeds.Keys) 2182 //foreach (ulong h in agent.ChildrenCapSeeds.Keys)
1873 // m_log.DebugFormat("[XXX] --> {0}", h); 2183 // m_log.DebugFormat("[XXX] --> {0}", h);
@@ -1881,12 +2191,19 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1881 } 2191 }
1882 2192
1883 agent.ChildrenCapSeeds[region.RegionHandle] = agent.CapsPath; 2193 agent.ChildrenCapSeeds[region.RegionHandle] = agent.CapsPath;
2194=======
2195// agent.ChildrenCapSeeds = new Dictionary<ulong, string>(seeds);
2196 agent.ChildrenCapSeeds = null;
2197>>>>>>> avn/ubitvar
1884 2198
1885 if (sp.Scene.CapsModule != null) 2199 if (sp.Scene.CapsModule != null)
1886 { 2200 {
1887 sp.Scene.CapsModule.SetChildrenSeed(sp.UUID, agent.ChildrenCapSeeds); 2201 sp.Scene.CapsModule.SetChildrenSeed(sp.UUID, seeds);
1888 } 2202 }
1889 2203
2204 sp.KnownRegions = seeds;
2205 sp.AddNeighbourRegionSizeInfo(region);
2206
1890 if (currentAgentCircuit != null) 2207 if (currentAgentCircuit != null)
1891 { 2208 {
1892 agent.ServiceURLs = currentAgentCircuit.ServiceURLs; 2209 agent.ServiceURLs = currentAgentCircuit.ServiceURLs;
@@ -1896,7 +2213,24 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1896 agent.Mac = currentAgentCircuit.Mac; 2213 agent.Mac = currentAgentCircuit.Mac;
1897 agent.Id0 = currentAgentCircuit.Id0; 2214 agent.Id0 = currentAgentCircuit.Id0;
1898 } 2215 }
1899 2216/*
2217 AgentPosition agentpos = null;
2218
2219 if (oldregions.Count > 0)
2220 {
2221 agentpos = new AgentPosition();
2222 agentpos.AgentID = new UUID(sp.UUID.Guid);
2223 agentpos.SessionID = sp.ControllingClient.SessionId;
2224 agentpos.Size = sp.Appearance.AvatarSize;
2225 agentpos.Center = sp.CameraPosition;
2226 agentpos.Far = sp.DrawDistance;
2227 agentpos.Position = sp.AbsolutePosition;
2228 agentpos.Velocity = sp.Velocity;
2229 agentpos.RegionHandle = currentRegionHandler;
2230 agentpos.Throttles = sp.ControllingClient.GetThrottlesPacked(1);
2231 agentpos.ChildrenCapSeeds = seeds;
2232 }
2233*/
1900 IPEndPoint external = region.ExternalEndPoint; 2234 IPEndPoint external = region.ExternalEndPoint;
1901 if (external != null) 2235 if (external != null)
1902 { 2236 {
@@ -1905,7 +2239,23 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1905 InformClientOfNeighbourCompleted, 2239 InformClientOfNeighbourCompleted,
1906 d); 2240 d);
1907 } 2241 }
2242/*
2243 if(oldregions.Count >0)
2244 {
2245 uint neighbourx;
2246 uint neighboury;
2247 UUID scope = sp.Scene.RegionInfo.ScopeID;
2248 foreach (ulong handler in oldregions)
2249 {
2250 // crap code
2251 Utils.LongToUInts(handler, out neighbourx, out neighboury);
2252 GridRegion neighbour = sp.Scene.GridService.GetRegionByPosition(scope, (int)neighbourx, (int)neighboury);
2253 sp.Scene.SimulationService.UpdateAgent(neighbour, agentpos);
2254 }
2255 }
2256 */
1908 } 2257 }
2258
1909 #endregion 2259 #endregion
1910 2260
1911 #region Enable Child Agents 2261 #region Enable Child Agents
@@ -1915,146 +2265,157 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1915 2265
1916 /// <summary> 2266 /// <summary>
1917 /// This informs all neighbouring regions about agent "avatar". 2267 /// This informs all neighbouring regions about agent "avatar".
2268 /// and as important informs the avatar about then
1918 /// </summary> 2269 /// </summary>
1919 /// <param name="sp"></param> 2270 /// <param name="sp"></param>
1920 public void EnableChildAgents(ScenePresence sp) 2271 public void EnableChildAgents(ScenePresence sp)
1921 { 2272 {
2273 // assumes that out of view range regions are disconnected by the previus region
2274
1922 List<GridRegion> neighbours = new List<GridRegion>(); 2275 List<GridRegion> neighbours = new List<GridRegion>();
1923 RegionInfo m_regionInfo = sp.Scene.RegionInfo; 2276 Scene spScene = sp.Scene;
2277 RegionInfo m_regionInfo = spScene.RegionInfo;
1924 2278
1925 if (m_regionInfo != null) 2279 if (m_regionInfo != null)
1926 { 2280 {
2281<<<<<<< HEAD
1927 neighbours = GetNeighbours(sp, m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); 2282 neighbours = GetNeighbours(sp, m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
2283=======
2284 neighbours = GetNeighbors(sp, m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
2285>>>>>>> avn/ubitvar
1928 } 2286 }
1929 else 2287 else
1930 { 2288 {
1931 m_log.Debug("[ENTITY TRANSFER MODULE]: m_regionInfo was null in EnableChildAgents, is this a NPC?"); 2289 m_log.Debug("[ENTITY TRANSFER MODULE]: m_regionInfo was null in EnableChildAgents, is this a NPC?");
1932 } 2290 }
1933 2291
1934 /// We need to find the difference between the new regions where there are no child agents 2292 ulong currentRegionHandler = m_regionInfo.RegionHandle;
1935 /// and the regions where there are already child agents. We only send notification to the former.
1936 List<ulong> neighbourHandles = NeighbourHandles(neighbours); // on this region
1937 neighbourHandles.Add(sp.Scene.RegionInfo.RegionHandle); // add this region too
1938 List<ulong> previousRegionNeighbourHandles;
1939 2293
1940 if (sp.Scene.CapsModule != null) 2294 LinkedList<ulong> previousRegionNeighbourHandles;
2295 Dictionary<ulong, string> seeds;
2296 ICapabilitiesModule capsModule = spScene.CapsModule;
2297
2298 if (capsModule != null)
1941 { 2299 {
1942 previousRegionNeighbourHandles = 2300 seeds = new Dictionary<ulong, string>(capsModule.GetChildrenSeeds(sp.UUID));
1943 new List<ulong>(sp.Scene.CapsModule.GetChildrenSeeds(sp.UUID).Keys); 2301 previousRegionNeighbourHandles = new LinkedList<ulong>(seeds.Keys);
1944 } 2302 }
1945 else 2303 else
1946 { 2304 {
1947 previousRegionNeighbourHandles = new List<ulong>(); 2305 seeds = new Dictionary<ulong, string>();
2306 previousRegionNeighbourHandles = new LinkedList<ulong>();
1948 } 2307 }
1949 2308
1950 List<ulong> newRegions = NewNeighbours(neighbourHandles, previousRegionNeighbourHandles); 2309 IClientAPI spClient = sp.ControllingClient;
1951 List<ulong> oldRegions = OldNeighbours(neighbourHandles, previousRegionNeighbourHandles);
1952
1953// Dump("Current Neighbors", neighbourHandles);
1954// Dump("Previous Neighbours", previousRegionNeighbourHandles);
1955// Dump("New Neighbours", newRegions);
1956// Dump("Old Neighbours", oldRegions);
1957 2310
1958 /// Update the scene presence's known regions here on this region 2311 if (!seeds.ContainsKey(currentRegionHandler))
1959 sp.DropOldNeighbours(oldRegions); 2312 seeds.Add(currentRegionHandler, spClient.RequestClientInfo().CapsPath);
1960 2313
1961 /// Collect as many seeds as possible 2314 AgentCircuitData currentAgentCircuit =
1962 Dictionary<ulong, string> seeds; 2315 spScene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
1963 if (sp.Scene.CapsModule != null)
1964 seeds = new Dictionary<ulong, string>(sp.Scene.CapsModule.GetChildrenSeeds(sp.UUID));
1965 else
1966 seeds = new Dictionary<ulong, string>();
1967 2316
1968 //m_log.Debug(" !!! No. of seeds: " + seeds.Count);
1969 if (!seeds.ContainsKey(sp.Scene.RegionInfo.RegionHandle))
1970 seeds.Add(sp.Scene.RegionInfo.RegionHandle, sp.ControllingClient.RequestClientInfo().CapsPath);
1971
1972 /// Create the necessary child agents
1973 List<AgentCircuitData> cagents = new List<AgentCircuitData>(); 2317 List<AgentCircuitData> cagents = new List<AgentCircuitData>();
2318 List<ulong> newneighbours = new List<ulong>();
2319
1974 foreach (GridRegion neighbour in neighbours) 2320 foreach (GridRegion neighbour in neighbours)
1975 { 2321 {
1976 if (neighbour.RegionHandle != sp.Scene.RegionInfo.RegionHandle) 2322 ulong handler = neighbour.RegionHandle;
2323
2324 if (previousRegionNeighbourHandles.Contains(handler))
1977 { 2325 {
1978 AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); 2326 // agent already knows this region
1979 AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); 2327 previousRegionNeighbourHandles.Remove(handler);
1980 agent.BaseFolder = UUID.Zero; 2328 continue;
1981 agent.InventoryFolder = UUID.Zero; 2329 }
1982 agent.startpos = sp.AbsolutePosition + CalculateOffset(sp, neighbour);
1983 agent.child = true;
1984 agent.Appearance = sp.Appearance;
1985 if (currentAgentCircuit != null)
1986 {
1987 agent.ServiceURLs = currentAgentCircuit.ServiceURLs;
1988 agent.IPAddress = currentAgentCircuit.IPAddress;
1989 agent.Viewer = currentAgentCircuit.Viewer;
1990 agent.Channel = currentAgentCircuit.Channel;
1991 agent.Mac = currentAgentCircuit.Mac;
1992 agent.Id0 = currentAgentCircuit.Id0;
1993 }
1994 2330
1995 if (newRegions.Contains(neighbour.RegionHandle)) 2331 if (handler == currentRegionHandler)
1996 { 2332 continue;
1997 agent.CapsPath = CapsUtil.GetRandomCapsObjectPath();
1998 sp.AddNeighbourRegion(neighbour.RegionHandle, agent.CapsPath);
1999 seeds.Add(neighbour.RegionHandle, agent.CapsPath);
2000 }
2001 else
2002 {
2003 agent.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, neighbour.RegionHandle);
2004 }
2005 2333
2006 cagents.Add(agent); 2334 // a new region to add
2335 AgentCircuitData agent = spClient.RequestClientInfo();
2336 agent.BaseFolder = UUID.Zero;
2337 agent.InventoryFolder = UUID.Zero;
2338 agent.startpos = sp.AbsolutePosition + CalculateOffset(sp, neighbour);
2339 agent.child = true;
2340 agent.Appearance = new AvatarAppearance();
2341 agent.Appearance.AvatarHeight = sp.Appearance.AvatarHeight;
2342
2343 if (currentAgentCircuit != null)
2344 {
2345 agent.ServiceURLs = currentAgentCircuit.ServiceURLs;
2346 agent.IPAddress = currentAgentCircuit.IPAddress;
2347 agent.Viewer = currentAgentCircuit.Viewer;
2348 agent.Channel = currentAgentCircuit.Channel;
2349 agent.Mac = currentAgentCircuit.Mac;
2350 agent.Id0 = currentAgentCircuit.Id0;
2007 } 2351 }
2008 }
2009 2352
2010 /// Update all child agent with everyone's seeds 2353 newneighbours.Add(handler);
2011 foreach (AgentCircuitData a in cagents) 2354 agent.CapsPath = CapsUtil.GetRandomCapsObjectPath();
2012 { 2355 seeds.Add(handler, agent.CapsPath);
2013 a.ChildrenCapSeeds = new Dictionary<ulong, string>(seeds);
2014 }
2015 2356
2016 if (sp.Scene.CapsModule != null) 2357 agent.ChildrenCapSeeds = null;
2017 { 2358 cagents.Add(agent);
2018 sp.Scene.CapsModule.SetChildrenSeed(sp.UUID, seeds);
2019 } 2359 }
2020 sp.KnownRegions = seeds;
2021 //avatar.Scene.DumpChildrenSeeds(avatar.UUID);
2022 //avatar.DumpKnownRegions();
2023 2360
2024 bool newAgent = false; 2361 if (previousRegionNeighbourHandles.Contains(currentRegionHandler))
2025 int count = 0; 2362 previousRegionNeighbourHandles.Remove(currentRegionHandler);
2026 foreach (GridRegion neighbour in neighbours) 2363
2027 { 2364 // previousRegionNeighbourHandles now contains regions to forget
2028 //m_log.WarnFormat("--> Going to send child agent to {0}", neighbour.RegionName); 2365 foreach (ulong handler in previousRegionNeighbourHandles)
2029 // Don't do it if there's already an agent in that region 2366 seeds.Remove(handler);
2030 if (newRegions.Contains(neighbour.RegionHandle)) 2367
2031 newAgent = true; 2368 /// Update all child agent with everyone's seeds
2032 else 2369 // foreach (AgentCircuitData a in cagents)
2033 newAgent = false; 2370 // a.ChildrenCapSeeds = new Dictionary<ulong, string>(seeds);
2034// continue; 2371
2372 if (capsModule != null)
2373 capsModule.SetChildrenSeed(sp.UUID, seeds);
2035 2374
2036 if (neighbour.RegionHandle != sp.Scene.RegionInfo.RegionHandle) 2375 sp.KnownRegions = seeds;
2376 sp.SetNeighbourRegionSizeInfo(neighbours);
2377
2378 AgentPosition agentpos = new AgentPosition();
2379 agentpos.AgentID = new UUID(sp.UUID.Guid);
2380 agentpos.SessionID = spClient.SessionId;
2381 agentpos.Size = sp.Appearance.AvatarSize;
2382 agentpos.Center = sp.CameraPosition;
2383 agentpos.Far = sp.DrawDistance;
2384 agentpos.Position = sp.AbsolutePosition;
2385 agentpos.Velocity = sp.Velocity;
2386 agentpos.RegionHandle = currentRegionHandler;
2387 agentpos.Throttles = spClient.GetThrottlesPacked(1);
2388 // agentpos.ChildrenCapSeeds = seeds;
2389
2390 Util.FireAndForget(delegate
2391 {
2392 Thread.Sleep(200); // the original delay that was at InformClientOfNeighbourAsync start
2393 int count = 0;
2394
2395 foreach (GridRegion neighbour in neighbours)
2037 { 2396 {
2397 ulong handler = neighbour.RegionHandle;
2038 try 2398 try
2039 { 2399 {
2040 // Let's put this back at sync, so that it doesn't clog 2400 if (newneighbours.Contains(handler))
2041 // the network, especially for regions in the same physical server. 2401 {
2042 // We're really not in a hurry here. 2402 InformClientOfNeighbourAsync(sp, cagents[count], neighbour,
2043 InformClientOfNeighbourAsync(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent); 2403 neighbour.ExternalEndPoint, true);
2044 //InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; 2404 count++;
2045 //d.BeginInvoke(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent, 2405 }
2046 // InformClientOfNeighbourCompleted, 2406 else if (!previousRegionNeighbourHandles.Contains(handler))
2047 // d); 2407 {
2408 spScene.SimulationService.UpdateAgent(neighbour, agentpos);
2409 }
2048 } 2410 }
2049
2050 catch (ArgumentOutOfRangeException) 2411 catch (ArgumentOutOfRangeException)
2051 { 2412 {
2052 m_log.ErrorFormat( 2413 m_log.ErrorFormat(
2053 "[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}).", 2414 "[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}).",
2054 neighbour.ExternalHostName, 2415 neighbour.ExternalHostName,
2055 neighbour.RegionHandle, 2416 neighbour.RegionHandle,
2056 neighbour.RegionLocX, 2417 neighbour.RegionLocX,
2057 neighbour.RegionLocY); 2418 neighbour.RegionLocY);
2058 } 2419 }
2059 catch (Exception e) 2420 catch (Exception e)
2060 { 2421 {
@@ -2071,13 +2432,106 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2071 2432
2072 // XXX: Well, decided to swallow the exception instead for now. Let us see how that goes. 2433 // XXX: Well, decided to swallow the exception instead for now. Let us see how that goes.
2073 // throw e; 2434 // throw e;
2435 }
2436 }
2437 });
2438 }
2439
2440 // Computes the difference between two region bases.
2441 // Returns a vector of world coordinates (meters) from base of first region to the second.
2442 // The first region is the home region of the passed scene presence.
2443 Vector3 CalculateOffset(ScenePresence sp, GridRegion neighbour)
2444 {
2445 return new Vector3(sp.Scene.RegionInfo.WorldLocX - neighbour.RegionLocX,
2446 sp.Scene.RegionInfo.WorldLocY - neighbour.RegionLocY,
2447 0f);
2448 }
2449
2074 2450
2451 #region NotFoundLocationCache class
2452 // A collection of not found locations to make future lookups 'not found' lookups quick.
2453 // A simple expiring cache that keeps not found locations for some number of seconds.
2454 // A 'not found' location is presumed to be anywhere in the minimum sized region that
2455 // contains that point. A conservitive estimate.
2456 private class NotFoundLocationCache
2457 {
2458 private struct NotFoundLocation
2459 {
2460 public double minX, maxX, minY, maxY;
2461 public DateTime expireTime;
2462 }
2463 private List<NotFoundLocation> m_notFoundLocations = new List<NotFoundLocation>();
2464 public NotFoundLocationCache()
2465 {
2466 }
2467 // Add an area to the list of 'not found' places. The area is the snapped region
2468 // area around the added point.
2469 public void Add(double pX, double pY)
2470 {
2471 lock (m_notFoundLocations)
2472 {
2473 if (!LockedContains(pX, pY))
2474 {
2475 NotFoundLocation nfl = new NotFoundLocation();
2476 // A not found location is not found for at least a whole region sized area
2477 nfl.minX = pX - (pX % (double)Constants.RegionSize);
2478 nfl.minY = pY - (pY % (double)Constants.RegionSize);
2479 nfl.maxX = nfl.minX + (double)Constants.RegionSize;
2480 nfl.maxY = nfl.minY + (double)Constants.RegionSize;
2481 nfl.expireTime = DateTime.Now + TimeSpan.FromSeconds(30);
2482 m_notFoundLocations.Add(nfl);
2483 }
2484 }
2485
2486 }
2487 // Test to see of this point is in any of the 'not found' areas.
2488 // Return 'true' if the point is found inside the 'not found' areas.
2489 public bool Contains(double pX, double pY)
2490 {
2491 bool ret = false;
2492 lock (m_notFoundLocations)
2493 ret = LockedContains(pX, pY);
2494 return ret;
2495 }
2496 private bool LockedContains(double pX, double pY)
2497 {
2498 bool ret = false;
2499 this.DoExpiration();
2500 foreach (NotFoundLocation nfl in m_notFoundLocations)
2501 {
2502 if (pX >= nfl.minX && pX < nfl.maxX && pY >= nfl.minY && pY < nfl.maxY)
2503 {
2504 ret = true;
2505 break;
2075 } 2506 }
2076 } 2507 }
2077 count++; 2508 return ret;
2509 }
2510 private void DoExpiration()
2511 {
2512 List<NotFoundLocation> m_toRemove = null;
2513 DateTime now = DateTime.Now;
2514 foreach (NotFoundLocation nfl in m_notFoundLocations)
2515 {
2516 if (nfl.expireTime < now)
2517 {
2518 if (m_toRemove == null)
2519 m_toRemove = new List<NotFoundLocation>();
2520 m_toRemove.Add(nfl);
2521 }
2522 }
2523 if (m_toRemove != null)
2524 {
2525 foreach (NotFoundLocation nfl in m_toRemove)
2526 m_notFoundLocations.Remove(nfl);
2527 m_toRemove.Clear();
2528 }
2078 } 2529 }
2079 } 2530 }
2531 #endregion // NotFoundLocationCache class
2532 private NotFoundLocationCache m_notFoundLocationCache = new NotFoundLocationCache();
2080 2533
2534<<<<<<< HEAD
2081 // Computes the difference between two region bases. 2535 // Computes the difference between two region bases.
2082 // Returns a vector of world coordinates (meters) from base of first region to the second. 2536 // Returns a vector of world coordinates (meters) from base of first region to the second.
2083 // The first region is the home region of the passed scene presence. 2537 // The first region is the home region of the passed scene presence.
@@ -2197,6 +2651,27 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2197 double px, double py, uint pSizeHint) 2651 double px, double py, uint pSizeHint)
2198 { 2652 {
2199 m_log.DebugFormat("{0} GetRegionContainingWorldLocation: query, loc=<{1},{2}>", LogHeader, px, py); 2653 m_log.DebugFormat("{0} GetRegionContainingWorldLocation: query, loc=<{1},{2}>", LogHeader, px, py);
2654=======
2655// needed for current OSG or old grid code
2656
2657 public GridRegion GetRegionContainingWorldLocation(IGridService pGridService, UUID pScopeID, double px, double py)
2658 {
2659 // Since we don't know how big the regions could be, we have to search a very large area
2660 // to find possible regions.
2661 return GetRegionContainingWorldLocation(pGridService, pScopeID, px, py, Constants.MaximumRegionSize);
2662 }
2663
2664 // Given a world position, get the GridRegion info for
2665 // the region containing that point.
2666 // Someday this should be a method on GridService.
2667 // 'pSizeHint' is the size of the source region but since the destination point can be anywhere
2668 // the size of the target region is unknown thus the search area might have to be very large.
2669 // Return 'null' if no such region exists.
2670 public GridRegion GetRegionContainingWorldLocation(IGridService pGridService, UUID pScopeID,
2671 double px, double py, uint pSizeHint)
2672 {
2673 m_log.DebugFormat("{0} GetRegionContainingWorldLocation: call, XY=<{1},{2}>", LogHeader, px, py);
2674>>>>>>> avn/ubitvar
2200 GridRegion ret = null; 2675 GridRegion ret = null;
2201 const double fudge = 2.0; 2676 const double fudge = 2.0;
2202 2677
@@ -2289,55 +2764,71 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2289 private void InformClientOfNeighbourAsync(ScenePresence sp, AgentCircuitData a, GridRegion reg, 2764 private void InformClientOfNeighbourAsync(ScenePresence sp, AgentCircuitData a, GridRegion reg,
2290 IPEndPoint endPoint, bool newAgent) 2765 IPEndPoint endPoint, bool newAgent)
2291 { 2766 {
2292 // Let's wait just a little to give time to originating regions to catch up with closing child agents
2293 // after a cross here
2294 Thread.Sleep(500);
2295 2767
2768<<<<<<< HEAD
2296 Scene scene = sp.Scene; 2769 Scene scene = sp.Scene;
2297 2770
2298 m_log.DebugFormat( 2771 m_log.DebugFormat(
2299 "[ENTITY TRANSFER MODULE]: Informing {0} {1} about neighbour {2} {3} at ({4},{5})", 2772 "[ENTITY TRANSFER MODULE]: Informing {0} {1} about neighbour {2} {3} at ({4},{5})",
2300 sp.Name, sp.UUID, reg.RegionName, endPoint, reg.RegionCoordX, reg.RegionCoordY); 2773 sp.Name, sp.UUID, reg.RegionName, endPoint, reg.RegionCoordX, reg.RegionCoordY);
2774=======
2775 if (newAgent)
2776 {
2777 Scene scene = sp.Scene;
2778
2779 m_log.DebugFormat(
2780 "[ENTITY TRANSFER MODULE]: Informing {0} {1} about neighbour {2} {3} at ({4},{5})",
2781 sp.Name, sp.UUID, reg.RegionName, endPoint, reg.RegionCoordX, reg.RegionCoordY);
2782>>>>>>> avn/ubitvar
2301 2783
2302 string capsPath = reg.ServerURI + CapsUtil.GetCapsSeedPath(a.CapsPath); 2784 string capsPath = reg.ServerURI + CapsUtil.GetCapsSeedPath(a.CapsPath);
2303 2785
2304 string reason = String.Empty; 2786 string reason = String.Empty;
2305 2787
2788<<<<<<< HEAD
2306 bool regionAccepted = scene.SimulationService.CreateAgent(null, reg, a, (uint)TeleportFlags.Default, out reason); 2789 bool regionAccepted = scene.SimulationService.CreateAgent(null, reg, a, (uint)TeleportFlags.Default, out reason);
2790=======
2791 bool regionAccepted = scene.SimulationService.CreateAgent(reg, a, (uint)TeleportFlags.Default, out reason);
2792>>>>>>> avn/ubitvar
2307 2793
2308 if (regionAccepted && newAgent) 2794 if (regionAccepted)
2309 {
2310 if (m_eqModule != null)
2311 { 2795 {
2312 #region IP Translation for NAT 2796 // give time for createAgent to finish, since it is async and does grid services access
2313 IClientIPEndpoint ipepClient; 2797 Thread.Sleep(500);
2314 if (sp.ClientView.TryGet(out ipepClient)) 2798
2799 if (m_eqModule != null)
2315 { 2800 {
2316 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address); 2801 #region IP Translation for NAT
2317 } 2802 IClientIPEndpoint ipepClient;
2318 #endregion 2803 if (sp.ClientView.TryGet(out ipepClient))
2804 {
2805 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
2806 }
2807 #endregion
2319 2808
2320 m_log.DebugFormat("{0} {1} is sending {2} EnableSimulator for neighbour region {3}(loc=<{4},{5}>,siz=<{6},{7}>) " + 2809 m_log.DebugFormat("{0} {1} is sending {2} EnableSimulator for neighbour region {3}(loc=<{4},{5}>,siz=<{6},{7}>) " +
2321 "and EstablishAgentCommunication with seed cap {8}", LogHeader, 2810 "and EstablishAgentCommunication with seed cap {8}", LogHeader,
2322 scene.RegionInfo.RegionName, sp.Name, 2811 scene.RegionInfo.RegionName, sp.Name,
2323 reg.RegionName, reg.RegionLocX, reg.RegionLocY, reg.RegionSizeX, reg.RegionSizeY , capsPath); 2812 reg.RegionName, reg.RegionLocX, reg.RegionLocY, reg.RegionSizeX, reg.RegionSizeY, capsPath);
2324 2813
2325 m_eqModule.EnableSimulator(reg.RegionHandle, endPoint, sp.UUID, reg.RegionSizeX, reg.RegionSizeY); 2814 m_eqModule.EnableSimulator(reg.RegionHandle, endPoint, sp.UUID, reg.RegionSizeX, reg.RegionSizeY);
2326 m_eqModule.EstablishAgentCommunication(sp.UUID, endPoint, capsPath, reg.RegionHandle, reg.RegionSizeX, reg.RegionSizeY); 2815 m_eqModule.EstablishAgentCommunication(sp.UUID, endPoint, capsPath, reg.RegionHandle, reg.RegionSizeX, reg.RegionSizeY);
2327 } 2816 }
2328 else 2817 else
2329 { 2818 {
2330 sp.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint); 2819 sp.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint);
2331 // TODO: make Event Queue disablable! 2820 // TODO: make Event Queue disablable!
2821 }
2822
2823 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Completed inform {0} {1} about neighbour {2}", sp.Name, sp.UUID, endPoint);
2332 } 2824 }
2333 2825
2334 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Completed inform {0} {1} about neighbour {2}", sp.Name, sp.UUID, endPoint); 2826 if (!regionAccepted)
2827 m_log.WarnFormat(
2828 "[ENTITY TRANSFER MODULE]: Region {0} did not accept {1} {2}: {3}",
2829 reg.RegionName, sp.Name, sp.UUID, reason);
2335 } 2830 }
2336 2831
2337 if (!regionAccepted)
2338 m_log.WarnFormat(
2339 "[ENTITY TRANSFER MODULE]: Region {0} did not accept {1} {2}: {3}",
2340 reg.RegionName, sp.Name, sp.UUID, reason);
2341 } 2832 }
2342 2833
2343 /// <summary> 2834 /// <summary>
@@ -2357,6 +2848,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2357 extent.Y = (float)Util.WorldToRegionLoc((uint)megaRegionSize.Y); 2848 extent.Y = (float)Util.WorldToRegionLoc((uint)megaRegionSize.Y);
2358 } 2849 }
2359 2850
2851<<<<<<< HEAD
2852=======
2853
2854>>>>>>> avn/ubitvar
2360 swCorner.X = Scene.RegionInfo.RegionLocX - 1; 2855 swCorner.X = Scene.RegionInfo.RegionLocX - 1;
2361 swCorner.Y = Scene.RegionInfo.RegionLocY - 1; 2856 swCorner.Y = Scene.RegionInfo.RegionLocY - 1;
2362 neCorner.X = Scene.RegionInfo.RegionLocX + extent.X; 2857 neCorner.X = Scene.RegionInfo.RegionLocX + extent.X;
@@ -2370,7 +2865,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2370 /// <param name="pRegionLocX"></param> 2865 /// <param name="pRegionLocX"></param>
2371 /// <param name="pRegionLocY"></param> 2866 /// <param name="pRegionLocY"></param>
2372 /// <returns></returns> 2867 /// <returns></returns>
2868<<<<<<< HEAD
2373 protected List<GridRegion> GetNeighbours(ScenePresence avatar, uint pRegionLocX, uint pRegionLocY) 2869 protected List<GridRegion> GetNeighbours(ScenePresence avatar, uint pRegionLocX, uint pRegionLocY)
2870=======
2871 protected List<GridRegion> GetNeighbors(ScenePresence avatar, uint pRegionLocX, uint pRegionLocY)
2872>>>>>>> avn/ubitvar
2374 { 2873 {
2375 Scene pScene = avatar.Scene; 2874 Scene pScene = avatar.Scene;
2376 RegionInfo m_regionInfo = pScene.RegionInfo; 2875 RegionInfo m_regionInfo = pScene.RegionInfo;
@@ -2381,6 +2880,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2381 // view to include everything in the megaregion 2880 // view to include everything in the megaregion
2382 if (m_regionCombinerModule == null || !m_regionCombinerModule.IsRootForMegaregion(Scene.RegionInfo.RegionID)) 2881 if (m_regionCombinerModule == null || !m_regionCombinerModule.IsRootForMegaregion(Scene.RegionInfo.RegionID))
2383 { 2882 {
2883<<<<<<< HEAD
2384 // The area to check is as big as the current region. 2884 // The area to check is as big as the current region.
2385 // We presume all adjacent regions are the same size as this region. 2885 // We presume all adjacent regions are the same size as this region.
2386 uint dd = Math.Max((uint)avatar.Scene.DefaultDrawDistance, 2886 uint dd = Math.Max((uint)avatar.Scene.DefaultDrawDistance,
@@ -2395,6 +2895,32 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2395 neighbours 2895 neighbours
2396 = avatar.Scene.GridService.GetRegionRange( 2896 = avatar.Scene.GridService.GetRegionRange(
2397 m_regionInfo.ScopeID, (int)startX, (int)endX, (int)startY, (int)endY); 2897 m_regionInfo.ScopeID, (int)startX, (int)endX, (int)startY, (int)endY);
2898=======
2899 uint dd = (uint)avatar.DrawDistance;
2900
2901 // until avatar movement updates client connections, we need to seend at least this current region imediate Neighbors
2902 uint ddX = Math.Max(dd, Constants.RegionSize);
2903 uint ddY = Math.Max(dd, Constants.RegionSize);
2904
2905 ddX--;
2906 ddY--;
2907
2908 // reference to region edges. Should be avatar position
2909 uint startX = Util.RegionToWorldLoc(pRegionLocX);
2910 uint endX = startX + m_regionInfo.RegionSizeX;
2911 uint startY = Util.RegionToWorldLoc(pRegionLocY);
2912 uint endY = startY + m_regionInfo.RegionSizeY;
2913
2914 startX -= ddX;
2915 startY -= ddY;
2916 endX += ddX;
2917 endY += ddY;
2918
2919 neighbours
2920 = avatar.Scene.GridService.GetRegionRange(
2921 m_regionInfo.ScopeID, (int)startX, (int)endX, (int)startY, (int)endY);
2922
2923>>>>>>> avn/ubitvar
2398 } 2924 }
2399 else 2925 else
2400 { 2926 {
@@ -2408,6 +2934,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2408 (int)Util.RegionToWorldLoc((uint)swCorner.Y), (int)Util.RegionToWorldLoc((uint)neCorner.Y)); 2934 (int)Util.RegionToWorldLoc((uint)swCorner.Y), (int)Util.RegionToWorldLoc((uint)neCorner.Y));
2409 } 2935 }
2410 2936
2937<<<<<<< HEAD
2411// neighbours.ForEach( 2938// neighbours.ForEach(
2412// n => 2939// n =>
2413// m_log.DebugFormat( 2940// m_log.DebugFormat(
@@ -2420,59 +2947,72 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2420 r.RegionID == m_regionInfo.RegionID 2947 r.RegionID == m_regionInfo.RegionID
2421 || (r.RegionFlags != null && (r.RegionFlags & OpenSim.Framework.RegionFlags.RegionOnline) == 0)); 2948 || (r.RegionFlags != null && (r.RegionFlags & OpenSim.Framework.RegionFlags.RegionOnline) == 0));
2422 2949
2950=======
2951 // The r.RegionFlags == null check only needs to be made for simulators before 2015-01-14 (pre 0.8.1).
2952 neighbours.RemoveAll( r => r.RegionID == m_regionInfo.RegionID );
2953
2954>>>>>>> avn/ubitvar
2423 return neighbours; 2955 return neighbours;
2424 } 2956 }
2957 #endregion
2958
2959 #region Agent Arrived
2425 2960
2426 private List<ulong> NewNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours) 2961 public void AgentArrivedAtDestination(UUID id)
2427 { 2962 {
2428 return currentNeighbours.FindAll(delegate(ulong handle) { return !previousNeighbours.Contains(handle); }); 2963 m_entityTransferStateMachine.SetAgentArrivedAtDestination(id);
2429 } 2964 }
2430 2965
2431 // private List<ulong> CommonNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours) 2966 #endregion
2432 // { 2967
2433 // return currentNeighbours.FindAll(delegate(ulong handle) { return previousNeighbours.Contains(handle); }); 2968 #region Object Transfers
2434 // }
2435 2969
2436 private List<ulong> OldNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours) 2970 public GridRegion GetObjectDestination(SceneObjectGroup grp, Vector3 targetPosition,out Vector3 newpos)
2437 { 2971 {
2438 return previousNeighbours.FindAll(delegate(ulong handle) { return !currentNeighbours.Contains(handle); }); 2972 newpos = targetPosition;
2439 }
2440 2973
2441 private List<ulong> NeighbourHandles(List<GridRegion> neighbours) 2974 Scene scene = grp.Scene;
2442 { 2975 if (scene == null)
2443 List<ulong> handles = new List<ulong>(); 2976 return null;
2444 foreach (GridRegion reg in neighbours) 2977
2978 int x = (int)targetPosition.X + (int)scene.RegionInfo.WorldLocX;
2979 if (targetPosition.X >= 0)
2980 x++;
2981 else
2982 x--;
2983
2984 int y = (int)targetPosition.Y + (int)scene.RegionInfo.WorldLocY;
2985 if (targetPosition.Y >= 0)
2986 y++;
2987 else
2988 y--;
2989
2990
2991 GridRegion neighbourRegion = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID,x,y);
2992 if (neighbourRegion == null)
2445 { 2993 {
2446 handles.Add(reg.RegionHandle); 2994 return null;
2447 } 2995 }
2448 return handles;
2449 }
2450 2996
2451// private void Dump(string msg, List<ulong> handles) 2997 float newRegionSizeX = neighbourRegion.RegionSizeX;
2452// { 2998 float newRegionSizeY = neighbourRegion.RegionSizeY;
2453// m_log.InfoFormat("-------------- HANDLE DUMP ({0}) ---------", msg); 2999 if (newRegionSizeX == 0)
2454// foreach (ulong handle in handles) 3000 newRegionSizeX = Constants.RegionSize;
2455// { 3001 if (newRegionSizeY == 0)
2456// uint x, y; 3002 newRegionSizeY = Constants.RegionSize;
2457// Utils.LongToUInts(handle, out x, out y);
2458// x = x / Constants.RegionSize;
2459// y = y / Constants.RegionSize;
2460// m_log.InfoFormat("({0}, {1})", x, y);
2461// }
2462// }
2463 3003
2464 #endregion
2465 3004
2466 #region Agent Arrived 3005 newpos.X = targetPosition.X - (neighbourRegion.RegionLocX - (int)scene.RegionInfo.WorldLocX);
3006 newpos.Y = targetPosition.Y - (neighbourRegion.RegionLocY - (int)scene.RegionInfo.WorldLocY);
2467 3007
2468 public void AgentArrivedAtDestination(UUID id)
2469 {
2470 m_entityTransferStateMachine.SetAgentArrivedAtDestination(id);
2471 }
2472 3008
2473 #endregion 3009 const float enterDistance = 0.2f;
3010 newpos.X = Util.Clamp(newpos.X, enterDistance, newRegionSizeX - enterDistance);
3011 newpos.Y = Util.Clamp(newpos.Y, enterDistance, newRegionSizeY - enterDistance);
3012
3013 return neighbourRegion;
3014 }
2474 3015
2475 #region Object Transfers
2476 3016
2477 /// <summary> 3017 /// <summary>
2478 /// Move the given scene object into a new region depending on which region its absolute position has moved 3018 /// Move the given scene object into a new region depending on which region its absolute position has moved
@@ -2496,6 +3036,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2496 if (scene == null) 3036 if (scene == null)
2497 return; 3037 return;
2498 3038
3039<<<<<<< HEAD
2499 if (grp.RootPart.DIE_AT_EDGE) 3040 if (grp.RootPart.DIE_AT_EDGE)
2500 { 3041 {
2501 // We remove the object here 3042 // We remove the object here
@@ -2510,6 +3051,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2510 return; 3051 return;
2511 } 3052 }
2512 3053
3054=======
3055>>>>>>> avn/ubitvar
2513 // Remember the old group position in case the region lookup fails so position can be restored. 3056 // Remember the old group position in case the region lookup fails so position can be restored.
2514 Vector3 oldGroupPosition = grp.RootPart.GroupPosition; 3057 Vector3 oldGroupPosition = grp.RootPart.GroupPosition;
2515 3058
@@ -2562,7 +3105,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2562 /// true if the crossing itself was successful, false on failure 3105 /// true if the crossing itself was successful, false on failure
2563 /// FIMXE: we still return true if the crossing object was not successfully deleted from the originating region 3106 /// FIMXE: we still return true if the crossing object was not successfully deleted from the originating region
2564 /// </returns> 3107 /// </returns>
2565 protected bool CrossPrimGroupIntoNewRegion(GridRegion destination, Vector3 newPosition, SceneObjectGroup grp, bool silent) 3108 public bool CrossPrimGroupIntoNewRegion(GridRegion destination, Vector3 newPosition, SceneObjectGroup grp, bool silent)
2566 { 3109 {
2567 //m_log.Debug(" >>> CrossPrimGroupIntoNewRegion <<<"); 3110 //m_log.Debug(" >>> CrossPrimGroupIntoNewRegion <<<");
2568 3111
@@ -2603,30 +3146,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2603 grp, e); 3146 grp, e);
2604 } 3147 }
2605 } 3148 }
2606/*
2607 * done on caller ( not in attachments crossing for now)
2608 else
2609 {
2610
2611 if (!grp.IsDeleted)
2612 {
2613 PhysicsActor pa = grp.RootPart.PhysActor;
2614 if (pa != null)
2615 {
2616 pa.CrossingFailure();
2617 if (grp.RootPart.KeyframeMotion != null)
2618 {
2619 // moved to KeyframeMotion.CrossingFailure
2620// grp.RootPart.Velocity = Vector3.Zero;
2621 grp.RootPart.KeyframeMotion.CrossingFailure();
2622// grp.SendGroupRootTerseUpdate();
2623 }
2624 }
2625 }
2626
2627 m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: Prim crossing failed for {0}", grp);
2628 }
2629 */
2630 } 3149 }
2631 else 3150 else
2632 { 3151 {
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs
index 6a04acf..54ec751 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs
@@ -299,7 +299,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
299 id, m_mod.Scene.RegionInfo.RegionName, currentState)); 299 id, m_mod.Scene.RegionInfo.RegionName, currentState));
300 } 300 }
301 301
302 int count = 200; 302 int count = 400;
303 303
304 // There should be no race condition here since no other code should be removing the agent transfer or 304 // There should be no race condition here since no other code should be removing the agent transfer or
305 // changing the state to another other than Transferring => ReceivedAtDestination. 305 // changing the state to another other than Transferring => ReceivedAtDestination.
@@ -354,4 +354,4 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
354 } 354 }
355 } 355 }
356 } 356 }
357} \ No newline at end of file 357}
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index fa23590..233b251 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
@@ -238,19 +238,19 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
238 238
239 return region; 239 return region;
240 } 240 }
241 241/* NEEDFIX
242 protected override bool NeedsClosing(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg) 242 protected override bool NeedsClosing(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg)
243 { 243 {
244 if (base.NeedsClosing(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) 244 if (base.NeedsClosing(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY, reg))
245 return true; 245 return true;
246 246
247 int flags = Scene.GridService.GetRegionFlags(Scene.RegionInfo.ScopeID, reg.RegionID); 247 int flags = Scene.GridService.GetRegionFlags(Scene.RegionInfo.ScopeID, reg.RegionID);
248 if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Framework.RegionFlags.Hyperlink) != 0) 248 if (flags == -1 || (flags & (int)OpenSim.Framework.RegionFlags.Hyperlink) != 0)
249 return true; 249 return true;
250 250
251 return false; 251 return false;
252 } 252 }
253 253*/
254 protected override void AgentHasMovedAway(ScenePresence sp, bool logout) 254 protected override void AgentHasMovedAway(ScenePresence sp, bool logout)
255 { 255 {
256 base.AgentHasMovedAway(sp, logout); 256 base.AgentHasMovedAway(sp, logout);
@@ -311,6 +311,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
311 return base.CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout); 311 return base.CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout);
312 } 312 }
313 313
314 public void TriggerTeleportHome(UUID id, IClientAPI client)
315 {
316 TeleportHome(id, client);
317 }
318
314 protected override bool ValidateGenericConditions(ScenePresence sp, GridRegion reg, GridRegion finalDestination, uint teleportFlags, out string reason) 319 protected override bool ValidateGenericConditions(ScenePresence sp, GridRegion reg, GridRegion finalDestination, uint teleportFlags, out string reason)
315 { 320 {
316 reason = "Please wear your grid's allowed appearance before teleporting to another grid"; 321 reason = "Please wear your grid's allowed appearance before teleporting to another grid";
@@ -429,11 +434,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
429 // return base.UpdateAgent(reg, finalDestination, agentData, sp); 434 // return base.UpdateAgent(reg, finalDestination, agentData, sp);
430 //} 435 //}
431 436
437<<<<<<< HEAD
432 public override void TriggerTeleportHome(UUID id, IClientAPI client) 438 public override void TriggerTeleportHome(UUID id, IClientAPI client)
433 { 439 {
434 TeleportHome(id, client); 440 TeleportHome(id, client);
435 } 441 }
436 442
443=======
444>>>>>>> avn/ubitvar
437 public override bool TeleportHome(UUID id, IClientAPI client) 445 public override bool TeleportHome(UUID id, IClientAPI client)
438 { 446 {
439 m_log.DebugFormat( 447 m_log.DebugFormat(
@@ -491,9 +499,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
491 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: teleporting user {0} {1} home to {2} via {3}:{4}", 499 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: teleporting user {0} {1} home to {2} via {3}:{4}",
492 aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ServerURI, homeGatekeeper.RegionName); 500 aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ServerURI, homeGatekeeper.RegionName);
493 501
494 DoTeleport( 502 DoTeleport(sp, homeGatekeeper, finalDestination, position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome));
495 sp, homeGatekeeper, finalDestination,
496 position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome));
497 return true; 503 return true;
498 } 504 }
499 505
@@ -760,4 +766,4 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
760 return region; 766 return region;
761 } 767 }
762 } 768 }
763} \ No newline at end of file 769}